VAPOR3 3.9.4
NetCDFCFCollection.h
Go to the documentation of this file.
1//
2// $Id$
3//
4
5#ifndef _NetCDFCFCollection_h_
6#define _NetCDFCFCollection_h_
7
8#include <vector>
9#include <map>
10#include <algorithm>
11
12#include <sstream>
13#include <vapor/MyBase.h>
14#include <vapor/UDUnitsClass.h>
16
17union ut_unit;
18struct ut_system;
19
20namespace VAPoR {
21
22//
32//
33
35public:
38
39 virtual int Initialize(const std::vector<string> &files);
40
54 //
55 virtual bool IsCoordVarCF(string var) const { return (std::find(_coordinateVars.begin(), _coordinateVars.end(), var) != _coordinateVars.end()); }
56
72 //
73 virtual bool IsAuxCoordVarCF(string var) const { return (std::find(_auxCoordinateVars.begin(), _auxCoordinateVars.end(), var) != _auxCoordinateVars.end()); }
74
75
81 //
82 virtual bool IsCoordinateVar(string varName) const { return (IsCoordVarCF(varName) || IsAuxCoordVarCF(varName)); }
83
84
85
93 //
94 virtual bool IsLatCoordVar(string var) const { return (std::find(_latCoordVars.begin(), _latCoordVars.end(), var) != _latCoordVars.end()); }
95
103 //
104 virtual bool IsLonCoordVar(string var) const { return (std::find(_lonCoordVars.begin(), _lonCoordVars.end(), var) != _lonCoordVars.end()); }
105
113 //
114 virtual bool IsTimeCoordVar(string var) const { return (std::find(_timeCoordVars.begin(), _timeCoordVars.end(), var) != _timeCoordVars.end()); }
115
124 //
125 virtual bool IsVertCoordVar(string var) const { return (std::find(_vertCoordVars.begin(), _vertCoordVars.end(), var) != _vertCoordVars.end()); }
126
136 //
137 virtual bool IsVertCoordVarPressure(string var) const;
138
148 //
149 virtual bool IsVertCoordVarLength(string var) const;
150
166 virtual bool IsVertCoordVarUp(string var) const;
167
170 virtual std::vector<string> GetLatCoordVars() const { return (_latCoordVars); };
171
174 virtual std::vector<string> GetLonCoordVars() const { return (_lonCoordVars); };
175
178 virtual std::vector<string> GetTimeCoordVars() const { return (_timeCoordVars); };
179
182 virtual std::vector<string> GetVertCoordVars() const { return (_vertCoordVars); };
183
206 //
207 virtual std::vector<string> GetDataVariableNames(int ndim, bool spatial) const;
208
241 //
242 virtual int GetVarCoordVarNames(string var, std::vector<string> &cvars) const;
243
257 virtual int GetVarUnits(string var, string &units) const;
258
262 const UDUnits *GetUDUnits() const { return (_udunit); };
263
282 virtual int Convert(const string from, const string to, const double *src, double *dst, size_t n) const;
283 virtual int Convert(const string from, const string to, const float *src, float *dst, size_t n) const;
284
301 virtual bool GetMissingValue(string varname, double &mv) const;
302
305 virtual int OpenRead(size_t ts, string varname);
306
314 virtual bool IsVertDimensionless(string cvar) const;
315
323 //
324 bool GetMapProjectionProj4(string varname, string &proj4string) const;
325
326 void FormatTimeStr(double time, string &str) const;
327
328 friend std::ostream &operator<<(std::ostream &o, const NetCDFCFCollection &ncdfc);
329
330private:
331 std::vector<std::string> _coordinateVars;
332 std::vector<std::string> _auxCoordinateVars;
333 std::vector<std::string> _lonCoordVars;
334 std::vector<std::string> _latCoordVars;
335 std::vector<std::string> _vertCoordVars;
336 std::vector<std::string> _timeCoordVars;
337
338 UDUnits *_udunit;
339
340 //
341 // Map a variable name to it's missing value (if any)
342 //
343 std::map<string, double> _missingValueMap;
344
345 std::vector<std::string> _GetCoordAttrs(const NetCDFSimple::Variable &varinfo) const;
346
347 int _Initialize(const std::vector<string> &files);
348
356 //
357 bool _IsCoordinateVar(const NetCDFSimple::Variable &varinfo) const;
358
375
376 bool _IsLonCoordVar(const NetCDFSimple::Variable &varinfo) const;
377
388 bool _IsLatCoordVar(const NetCDFSimple::Variable &varinfo) const;
389
403 bool _IsVertCoordVar(const NetCDFSimple::Variable &varinfo) const;
404
415 bool _IsTimeCoordVar(const NetCDFSimple::Variable &varinfo) const;
416
417 bool _GetMissingValue(string varname, string attname, double &mv) const;
418 void _GetMissingValueMap(map<string, double> &missingValueMap) const;
419
420};
421}; // namespace VAPoR
422
423#endif
Wrapper for a collection of netCDF files.
virtual bool IsCoordVarCF(string var) const
virtual bool IsTimeCoordVar(string var) const
virtual std::vector< string > GetDataVariableNames(int ndim, bool spatial) const
virtual bool IsLonCoordVar(string var) const
virtual int OpenRead(size_t ts, string varname)
virtual std::vector< string > GetLatCoordVars() const
virtual bool IsAuxCoordVarCF(string var) const
virtual bool GetMissingValue(string varname, double &mv) const
virtual bool IsVertDimensionless(string cvar) const
virtual bool IsLatCoordVar(string var) const
virtual bool IsCoordinateVar(string varName) const
const UDUnits * GetUDUnits() const
virtual int Convert(const string from, const string to, const float *src, float *dst, size_t n) const
virtual bool IsVertCoordVarLength(string var) const
virtual std::vector< string > GetVertCoordVars() const
virtual std::vector< string > GetTimeCoordVars() const
virtual bool IsVertCoordVarUp(string var) const
virtual bool IsVertCoordVarPressure(string var) const
virtual int GetVarUnits(string var, string &units) const
void FormatTimeStr(double time, string &str) const
bool GetMapProjectionProj4(string varname, string &proj4string) const
virtual int Convert(const string from, const string to, const double *src, double *dst, size_t n) const
virtual bool IsVertCoordVar(string var) const
virtual int GetVarCoordVarNames(string var, std::vector< string > &cvars) const
virtual std::vector< string > GetLonCoordVars() const
friend std::ostream & operator<<(std::ostream &o, const NetCDFCFCollection &ncdfc)
virtual int Initialize(const std::vector< string > &files)
Wrapper for a collection of netCDF files.
NetCDFSimple API interface.
Definition: NetCDFSimple.h:43
#define VDF_API
Definition: common.h:73
union ut_unit ut_unit
Definition: udunits2.h:17
struct ut_system ut_system
Definition: udunits2.h:16