VAPOR3 3.9.4
DCCF.h
Go to the documentation of this file.
1#include <vector>
2#include <algorithm>
3#include <map>
4#include <iostream>
5#include <memory>
6#include <vapor/MyBase.h>
8#include <vapor/Proj4API.h>
10#include <vapor/utils.h>
11#include <vapor/DC.h>
12
13#ifndef _DCCF_H_
14 #define _DCCF_H_
15
16namespace VAPoR {
17
18
30class VDF_API DCCF : public VAPoR::DC {
31public:
36 virtual ~DCCF();
37
40
41protected:
42 NetCDFCFCollection *_ncdfc = nullptr;
43 vector<string> _paths;
44
60 //
61 virtual int initialize(const vector<string> &paths, const std::vector<string> &options);
62 virtual int initialize_impl(const vector<string> &paths, const std::vector<string> &options,
63 std::unique_ptr<NetCDFCFCollection> ncdfc);
64
67 virtual bool getDimension(string dimname, DC::Dimension &dimension) const;
68
71 virtual std::vector<string> getDimensionNames() const;
72
75 std::vector<string> getMeshNames() const;
76
79 virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const;
80
83 virtual bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const;
84
87 virtual bool getDataVarInfo(string varname, DC::DataVar &datavar) const;
88
91 virtual bool getAuxVarInfo(string varname, DC::AuxVar &var) const;
92
94 //
95 virtual bool getBaseVarInfo(string varname, DC::BaseVar &var) const;
96
99 virtual std::vector<string> getDataVarNames() const;
100
101 virtual std::vector<string> getAuxVarNames() const;
102
105 virtual std::vector<string> getCoordVarNames() const;
106
109 virtual size_t getNumRefLevels(string varname) const { return (1); }
110
113 virtual string getMapProjection() const
114 {
115 // Projections not supported yet :-(
116 //
117 return (_proj4String);
118 }
119
122 virtual bool getAtt(string varname, string attname, vector<double> &values) const;
123 virtual bool getAtt(string varname, string attname, vector<long> &values) const;
124 virtual bool getAtt(string varname, string attname, string &values) const;
125
128 virtual std::vector<string> getAttNames(string varname) const;
129
132 virtual XType getAttType(string varname, string attname) const;
133
136 virtual int getDimLensAtLevel(string varname, int level, std::vector<size_t> &dims_at_level, std::vector<size_t> &bs_at_level) const;
137
140 virtual int openVariableRead(size_t ts, string varname, int, int) { return (DCCF::openVariableRead(ts, varname)); }
141
142 virtual int openVariableRead(size_t ts, string varname);
143
146 virtual int closeVariable(int fd);
147
149 //
150 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, float *region) { return (_readRegionTemplate(fd, min, max, region)); }
151 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, double *region) { return (_readRegionTemplate(fd, min, max, region)); }
152 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, int *region) { return (_readRegionTemplate(fd, min, max, region)); }
153
156 virtual bool variableExists(size_t ts, string varname, int reflevel = 0, int lod = 0) const;
157
158 virtual int initDimensions(NetCDFCFCollection *ncdfc, std::map<string, DC::Dimension> &dimsMap);
159
160 virtual int initCoordinates(NetCDFCFCollection *ncdfc, std::map<string, DC::CoordVar> &coordVarsMap);
161
162 virtual int addCoordvars(NetCDFCFCollection *ncdfc, const vector<string> &cvars, std::map<string, DC::CoordVar> &coordVarsMap);
163
164 virtual int initDataVars(NetCDFCFCollection *ncdfc, std::map<string, DC::DataVar> &dataVarsMap);
165
166 virtual int initAuxilliaryVars(NetCDFCFCollection *ncdfc, std::map<string, DC::AuxVar> &auxVarsMap);
167
168 virtual int initMesh(NetCDFCFCollection *ncdfc, std::map<string, DC::Mesh> &_meshMap);
169
170 virtual int getVarCoordinates(NetCDFCFCollection *ncdfc, string varname, vector<string> &sdimnames, vector<string> &scoordvars, string &time_dim_name, string &time_coordvar) const;
171
172
173private:
174 VAPoR::UDUnits _udunits;
175
176 string _proj4String;
177 std::map<string, DC::Dimension> _dimsMap;
178 std::map<string, DC::CoordVar> _coordVarsMap;
179 std::map<string, DC::Mesh> _meshMap;
180 std::map<string, DC::DataVar> _dataVarsMap;
181 std::map<string, DC::AuxVar> _auxVarsMap;
182
183 int _initHorizontalCoordinates(NetCDFCFCollection *ncdfc, std::map<string, DC::CoordVar> &coordVarsMap);
184
185 int _initVerticalCoordinates(NetCDFCFCollection *ncdfc, std::map<string, DC::CoordVar> &coordVarsMap);
186
187 int _initTimeCoordinates(NetCDFCFCollection *ncdfc, std::map<string, DC::CoordVar> &coordVarsMap);
188
189 // Return true if a 1D variable has uniform, absolute deltas between elements
190 //
191 bool _isUniform(NetCDFCFCollection *ncdfc, string varname);
192
193
194 template<class T> int _readRegionTemplate(int fd, const vector<size_t> &min, const vector<size_t> &max, T *region);
195
196 template<class T> bool _getAttTemplate(string varname, string attname, T &values) const;
197
198};
199}; // namespace VAPoR
200
201#endif
Class for reading a NetCDF Climate Forecast (CF) data set stored as a series of NetCDF files.
Definition: DCCF.h:30
virtual XType getAttType(string varname, string attname) const
std::vector< string > getMeshNames() const
virtual bool getAuxVarInfo(string varname, DC::AuxVar &var) const
virtual int getDimLensAtLevel(string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level) const
virtual int openVariableRead(size_t ts, string varname, int, int)
Definition: DCCF.h:140
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, double *region)
Definition: DCCF.h:151
virtual int getVarCoordinates(NetCDFCFCollection *ncdfc, string varname, vector< string > &sdimnames, vector< string > &scoordvars, string &time_dim_name, string &time_coordvar) const
virtual bool getAtt(string varname, string attname, vector< long > &values) const
virtual int openVariableRead(size_t ts, string varname)
virtual std::vector< string > getCoordVarNames() const
virtual bool getDataVarInfo(string varname, DC::DataVar &datavar) const
virtual std::vector< string > getAttNames(string varname) const
virtual int initAuxilliaryVars(NetCDFCFCollection *ncdfc, std::map< string, DC::AuxVar > &auxVarsMap)
virtual bool getAtt(string varname, string attname, vector< double > &values) const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, int *region)
Definition: DCCF.h:152
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, float *region)
Definition: DCCF.h:150
virtual bool getDimension(string dimname, DC::Dimension &dimension) const
int Reinitialize()
virtual string getMapProjection() const
Definition: DCCF.h:113
virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const
virtual ~DCCF()
virtual bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const
virtual int initialize(const vector< string > &paths, const std::vector< string > &options)
virtual int initialize_impl(const vector< string > &paths, const std::vector< string > &options, std::unique_ptr< NetCDFCFCollection > ncdfc)
virtual std::vector< string > getDataVarNames() const
virtual std::vector< string > getDimensionNames() const
vector< string > _paths
Definition: DCCF.h:43
virtual std::vector< string > getAuxVarNames() const
virtual bool getAtt(string varname, string attname, string &values) const
virtual int closeVariable(int fd)
virtual bool variableExists(size_t ts, string varname, int reflevel=0, int lod=0) const
virtual size_t getNumRefLevels(string varname) const
Definition: DCCF.h:109
int BuildCache()
virtual int initDimensions(NetCDFCFCollection *ncdfc, std::map< string, DC::Dimension > &dimsMap)
virtual bool getBaseVarInfo(string varname, DC::BaseVar &var) const
virtual int initMesh(NetCDFCFCollection *ncdfc, std::map< string, DC::Mesh > &_meshMap)
virtual int initDataVars(NetCDFCFCollection *ncdfc, std::map< string, DC::DataVar > &dataVarsMap)
virtual int addCoordvars(NetCDFCFCollection *ncdfc, const vector< string > &cvars, std::map< string, DC::CoordVar > &coordVarsMap)
virtual int initCoordinates(NetCDFCFCollection *ncdfc, std::map< string, DC::CoordVar > &coordVarsMap)
Auxiliary variable metadata.
Definition: DC.h:1230
Base class for storing variable metadata.
Definition: DC.h:754
Coordinate variable metadata.
Definition: DC.h:881
Data variable metadata.
Definition: DC.h:987
Metadata describing a named dimension length.
Definition: DC.h:163
Metadata describing a computational mesh.
Definition: DC.h:310
A Template Method design pattern for reading a collection of data.
Definition: DC.h:150
XType
External storage types for primitive data.
Definition: DC.h:154
Wrapper for a collection of netCDF files.
#define VDF_API
Definition: common.h:73