FileLoaderNetCDF.h
2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef FILELOADERNETCDF_H
#define FILELOADERNETCDF_H
#include "FileLoaderAbstract.h"
#include "netcdf.h"
namespace TREPS
{
namespace File
{
//netCDF dimension
typedef struct
{
//dimension id
int id;
//dimension is unlimited?
bool isUnlimited;
//dimension length
size_t length;
} t_NetCDFDim;
//NetCDF dimension list
typedef list<t_NetCDFDim> t_NetCDFDimList;
//NetCDF variable information
typedef struct
{
//variable id
int id;
//variable name
char name[NC_MAX_NAME+1];
//variable type
nc_type type;
//variable type size
size_t typeSize;
//variable value size - always = 1 except for type NC_CHAR = string size
int valSize;
//variable number of value by record
int nbValByRecord;
//variable is a field (ie depends to the unlimited dimension)
bool isField;
//list of variable dimensions
t_NetCDFDimList dims;
//sttributes
map<string,string> attributes;
} t_NetCDFVar;
//NetCDF variables list
typedef list<t_NetCDFVar> t_NetCDFVarList;
class FileLoaderNetCDFClass : public FileLoaderAbstractClass
{
public :
FileLoaderNetCDFClass(void);
~FileLoaderNetCDFClass(void);
//open a NetCDF file
bool open(const char *file_path);
//close a NetCDF file
bool close(void);
//test if a NetCDF file is opened
bool isOpened(void);
//get file format
t_FileFormat getFormat(void);
//detect frames
t_StringList getFrames(const t_FieldList *fields);
//detect fields
t_FieldList getFields(long int nbRecords);
//get number of records in netCDF file
long int getNbRecords(void);
//add NetCDF specific vectors
void addSpecificFormatVectors(const t_FieldList *fields, t_VectorList &vectors);
//get global attributes
map<string,string> getAttributes(void);
//get data
bool getData(int start, int limit, DataRecordListClass *data, int &total);
private :
//NetCDF identifier
int ncid;
//get CDF variables list
t_NetCDFVarList getVarList(void);
//get a variable type
void getFieldType(nc_type type, t_FieldType &fieldType, t_TimeFormat &timeformat);
//extract data
string extractValToStr(void *pt, const t_NetCDFVar *var);
};
}
}
#endif