VAPOR3 3.9.4
DCWRF.h
Go to the documentation of this file.
1#include <vector>
2#include <algorithm>
3#include <map>
4#include <iostream>
5#include <vapor/MyBase.h>
9#include <vapor/DerivedVar.h>
10#include <vapor/DC.h>
11
12#ifndef _DCWRF_H_
13 #define _DCWRF_H_
14
15namespace VAPoR {
16
17class DerivedCoordVar_CF1D;
18class DerivedCoordVar_WRFTime;
19class DerivedCoordVar_Staggered;
20
31class VDF_API DCWRF : public VAPoR::DC {
32public:
37 virtual ~DCWRF();
38
39protected:
55 //
56 virtual int initialize(const vector<string> &paths, const std::vector<string> &options);
57
60 virtual bool getDimension(string dimname, DC::Dimension &dimension) const;
61
64 virtual std::vector<string> getDimensionNames() const;
65
68 std::vector<string> getMeshNames() const;
69
72 virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const;
73
76 virtual bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const;
77
80 virtual bool getDataVarInfo(string varname, DC::DataVar &datavar) const;
81
83 //
84 virtual bool getAuxVarInfo(string varname, DC::AuxVar &var) const { return (false); }
85
87 //
88 virtual bool getBaseVarInfo(string varname, DC::BaseVar &var) const;
89
92 virtual std::vector<string> getDataVarNames() const;
93
96 virtual std::vector<string> getCoordVarNames() const;
97
98 virtual std::vector<string> getAuxVarNames() const { return (vector<string>()); }
99
102 virtual size_t getNumRefLevels(string varname) const { return (1); }
103
106 virtual string getMapProjection() const;
107
110 virtual bool getAtt(string varname, string attname, vector<double> &values) const;
111 virtual bool getAtt(string varname, string attname, vector<long> &values) const;
112 virtual bool getAtt(string varname, string attname, string &values) const;
113
116 virtual std::vector<string> getAttNames(string varname) const;
117
120 virtual XType getAttType(string varname, string attname) const;
121
124 virtual int getDimLensAtLevel(string varname, int level, std::vector<size_t> &dims_at_level, std::vector<size_t> &bs_at_level) const;
125
128 virtual int openVariableRead(size_t ts, string varname, int, int) { return (DCWRF::openVariableRead(ts, varname)); }
129
130 virtual int openVariableRead(size_t ts, string varname);
131
134 virtual int closeVariable(int fd);
135
137 //
138 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, float *region) { return (_readRegionTemplate(fd, min, max, region)); }
139 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, double *region) { return (_readRegionTemplate(fd, min, max, region)); }
140 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, int *region) { return (_readRegionTemplate(fd, min, max, region)); }
141
144 virtual bool variableExists(size_t ts, string varname, int reflevel = 0, int lod = 0) const;
145
146private:
147 NetCDFCollection *_ncdfc;
148 VAPoR::UDUnits _udunits;
149
150 //
151 // Various attributes from a WRF data file needed for computing map
152 // projections
153 //
154 float _dx;
155 float _dy;
156 float _cen_lat;
157 float _cen_lon;
158 float _true_lat1;
159 float _true_lat2;
160 float _pole_lat;
161 float _pole_lon;
162 float _grav;
163 float _radius;
164 float _p2si;
165 float _mapProj;
166
167 string _proj4String;
168 DerivedVarMgr _dvm;
169
170 class WRFFileObject : public DC::FileTable::FileObject {
171 public:
172 WRFFileObject(size_t ts, string varname, int level, int lod, int fd, bool derivedFlag) : FileObject(ts, varname, level, lod, fd), _derivedFlag(derivedFlag) {}
173
174 bool GetDerivedFlag() const { return (_derivedFlag); }
175
176 private:
177 bool _derivedFlag;
178 };
179
180 std::vector<DerivedVar *> _derivedVars;
181
182 DerivedCoordVar_WRFTime *_derivedTime;
183
184 std::map<string, DC::Dimension> _dimsMap;
185 std::map<string, DC::CoordVar> _coordVarsMap;
186 std::map<string, DC::Mesh> _meshMap;
187 std::map<string, DC::DataVar> _dataVarsMap;
188 std::vector<size_t> _timeLookup;
189
190 vector<size_t> _GetSpatialDims(NetCDFCollection *ncdfc, string varname) const;
191
192 vector<string> _GetSpatialDimNames(NetCDFCollection *ncdfc, string varname) const;
193
194 int _InitAtts(NetCDFCollection *ncdfc);
195
196 int _GetProj4String(NetCDFCollection *ncdfc, float radius, int map_proj, string &projstring);
197
198 bool _isConstantValuedVariable(NetCDFCollection *ncdfc, string varname) const;
199
200 bool _isIdealized(NetCDFCollection *ncdfc) const;
201
202 bool _isWRFSFIRE(NetCDFCollection *ncdfc) const;
203
204 int _InitProjection(NetCDFCollection *ncdfc, float radius);
205
206 DerivedCoordVar_CF2D *_makeDerivedHorizontalIdealized(NetCDFCollection *ncdfc, string name, string &timeDimName, vector<string> &spaceDimNames);
207
208 DerivedCoordVar_Staggered *_makeDerivedHorizontalStaggered(NetCDFCollection *ncdfc, string name, string &timeDimName, vector<string> &spaceDimNames);
209
210 int _InitHorizontalCoordinatesHelper(NetCDFCollection *ncdfc, string name, int axis);
211
212 int _InitHorizontalCoordinates(NetCDFCollection *ncdfc);
213
214 DerivedCoordVar_CF1D *_InitVerticalCoordinatesHelper(string varName, string dimName);
215
216 int _InitVerticalCoordinates(NetCDFCollection *ncdfc);
217
218 int _InitTime(NetCDFCollection *ncdfc);
219
220 int _InitDimensions(NetCDFCollection *ncdfc);
221
222 int _GetCoordVars(NetCDFCollection *ncdfc, string varname, vector<string> &cvarnames);
223
224 bool _GetVarCoordinates(NetCDFCollection *ncdfc, string varname, std::vector<string> &dimnames, std::vector<string> &coordvars, string &time_dim_name, string &time_coordvar);
225
226 int _InitVars(NetCDFCollection *ncdfc);
227
228 template<class T> int _readRegionTemplate(int fd, const vector<size_t> &min, const vector<size_t> &max, T *region);
229
230 template<class T> bool _getAttTemplate(string varname, string attname, T &values) const;
231
232};
233}; // namespace VAPoR
234
235#endif
Class for reading a WRF data set stored as a series of NetCDF files.
Definition: DCWRF.h:31
virtual bool getDataVarInfo(string varname, DC::DataVar &datavar) const
virtual std::vector< string > getCoordVarNames() const
virtual int closeVariable(int fd)
virtual bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const
virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const
virtual bool getAtt(string varname, string attname, vector< double > &values) const
virtual int openVariableRead(size_t ts, string varname)
std::vector< string > getMeshNames() const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, int *region)
Definition: DCWRF.h:140
virtual std::vector< string > getAuxVarNames() const
Definition: DCWRF.h:98
virtual size_t getNumRefLevels(string varname) const
Definition: DCWRF.h:102
virtual bool getAtt(string varname, string attname, vector< long > &values) const
virtual bool getBaseVarInfo(string varname, DC::BaseVar &var) const
virtual int initialize(const vector< string > &paths, const std::vector< string > &options)
virtual std::vector< string > getAttNames(string varname) const
virtual bool getAuxVarInfo(string varname, DC::AuxVar &var) const
Definition: DCWRF.h:84
virtual int getDimLensAtLevel(string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level) const
virtual bool variableExists(size_t ts, string varname, int reflevel=0, int lod=0) const
virtual bool getDimension(string dimname, DC::Dimension &dimension) const
virtual XType getAttType(string varname, string attname) const
virtual int openVariableRead(size_t ts, string varname, int, int)
Definition: DCWRF.h:128
virtual string getMapProjection() const
virtual bool getAtt(string varname, string attname, string &values) const
virtual ~DCWRF()
virtual std::vector< string > getDimensionNames() const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, double *region)
Definition: DCWRF.h:139
virtual std::vector< string > getDataVarNames() const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, float *region)
Definition: DCWRF.h:138
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
Derived variables constructed from other variables.
Definition: DerivedVarMgr.h:20
Wrapper for a collection of netCDF files.
#define VDF_API
Definition: common.h:73