VAPoR  3.0.0
VDC.h
Go to the documentation of this file.
1 #include <vector>
2 #include <map>
3 #include <iostream>
4 #include <vapor/DC.h>
5 #include <vapor/MyBase.h>
6 #include <vapor/UDUnitsClass.h>
7 
8 #ifndef _VDC_H_
9 #define _VDC_H_
10 
11 namespace VAPoR {
12 
177 class VDF_API VDC : public VAPoR::DC {
178 public:
179 
182  enum AccessMode {R,W,A};
183 
187  VDC();
188  virtual ~VDC() {}
189 
228  //
229  virtual int Initialize(const std::vector <string> &paths, AccessMode mode);
230  virtual int Initialize(const std::vector <string> &paths) {
231  return(Initialize(paths, R));
232  }
233 
289  //
290  int SetCompressionBlock(
291  std::vector <size_t> bs, string wname, std::vector <size_t> cratios
292  );
293 
303  //
304  void GetCompressionBlock(
305  std::vector <size_t> &bs, string &wname,
306  std::vector <size_t> &cratios
307  ) const;
308 
309 
310 
322  void SetPeriodicBoundary(std::vector <bool> periodic) {
323  _periodic = periodic;
324  for (int i=_periodic.size(); i<3; i++) _periodic.push_back(false);
325  }
326 
330  //
331  std::vector <bool> GetPeriodicBoundary() const { return(_periodic); };
332 
374  //
375  int DefineDimension(string dimname, size_t length, int axis);
376 
377 
389  bool GetDimension(
390  string dimname, DC::Dimension &dimension
391  ) const;
392 
400  std::vector <string> GetDimensionNames() const;
401 
402 
445  //
446  int DefineCoordVar(
447  string varname, std::vector <string> dimnames,
448  string units, int axis, XType type, bool compressed
449  );
450 
451 
492  //
493  int DefineCoordVarUniform(
494  string varname, std::vector <string> dimname,
495  string units, int axis, XType type, bool compressed
496  );
497 
520  bool GetCoordVarInfo(
521  string varname, std::vector <string> &dimnames,
522  string &units, int &axis, XType &type, bool &compressed, bool &uniform
523  ) const;
524 
540  bool GetCoordVarInfo(string varname, DC::CoordVar &cvar) const;
541 
573  int DefineDataVar(
574  string varname, std::vector <string> dimnames,
575  std::vector <string> coordvars,
576  string units, XType type, bool compressed
577  );
578 
602  int DefineDataVar(
603  string varname, std::vector <string> dimnames,
604  std::vector <string> coordvars,
605  string units, XType type, double missing_value, string maskvar
606  );
607 
608 
629  bool GetDataVarInfo(
630  string varname, std::vector <string> &dimnames,
631  std::vector <string> &coordvars,
632  string &units, XType &type, bool &compressed,
633  string &maskvar
634  ) const;
635 
651  bool GetDataVarInfo( string varname, DC::DataVar &datavar) const;
652 
663  //
664  bool GetBaseVarInfo(string varname, DC::BaseVar &var) const;
665 
666 
672  //
673  virtual std::vector <string> GetDataVarNames() const;
674 
680  //
681  virtual std::vector <string> GetCoordVarNames() const;
682 
683 
698  //
699  int GetNumRefLevels(string varname) const;
700 
701 
719  //
720  int PutAtt(
721  string varname, string attname, XType type, const vector <double> &values
722  );
723  int PutAtt(
724  string varname, string attname, XType type, const vector <long> &values
725  );
726  int PutAtt(
727  string varname, string attname, XType type, const string &values
728  );
729 
748  //
749  int GetAtt(
750  string varname, string attname, vector <double> &values
751  ) const;
752  int GetAtt(
753  string varname, string attname, vector <long> &values
754  ) const;
755  int GetAtt(
756  string varname, string attname, string &values
757  ) const;
758 
771  //
772  std::vector <string> GetAttNames(string varname) const;
773 
785  XType GetAttType(string varname, string attname) const;
786 
789  virtual int GetMapProjection(
790  string lonname, string latname, string &projstring
791  ) const;
792 
800  //
801  virtual int SetMapProjection(
802  string lonname, string latname, string projstring
803  );
804 
822  int EndDefine();
823 
846  virtual int GetPath(
847  string varname, size_t ts, string &path, size_t &file_ts,
848  size_t &max_ts
849 
850  ) const = 0;
851 
874  //
875  virtual int GetDimLensAtLevel(
876  string varname, int level, std::vector <size_t> &dims_at_level,
877  std::vector <size_t> &bs_at_level
878  ) const = 0;
879 
880 
912  //
913  virtual int OpenVariableRead(
914  size_t ts, string varname, int level=0, int lod=0
915  ) = 0;
916 
948  //
949  virtual int OpenVariableWrite(size_t ts, string varname, int lod=-1) = 0;
950 
957  //
958  virtual int CloseVariable() = 0;
959 
960 
973  //
974  virtual int Write(const float *data) = 0;
975 
997  virtual int WriteSlice(const float *slice) = 0;
998 
1014  //
1015  int virtual Read(float *data) = 0;
1016 
1041  virtual int ReadSlice(float *slice) = 0;
1042 
1065  //
1066  virtual int ReadRegion(
1067  const vector <size_t> &min, const vector <size_t> &max, float *region
1068  ) = 0;
1069 
1083  virtual int ReadRegionBlock(
1084  const vector <size_t> &min, const vector <size_t> &max, float *region
1085  ) = 0;
1086 
1108  //
1109  virtual int PutVar(string varname, int lod, const float *data) = 0;
1110 
1134  //
1135  virtual int PutVar(size_t ts, string varname, int lod, const float *data) = 0;
1136 
1161  //
1162  virtual int GetVar(string varname, int level, int lod, float *data) = 0;
1163 
1191  //
1192  virtual int GetVar(
1193  size_t ts, string varname, int level, int lod, float *data
1194  ) = 0;
1195 
1215  virtual bool CompressionInfo(
1216  vector <size_t> bs, string wname, size_t &nlevels, size_t &maxcratio
1217  ) const = 0;
1218 
1219 
1232  //
1233  virtual bool VariableExists(
1234  size_t ts,
1235  string varname,
1236  int reflevel = 0,
1237  int lod = 0
1238  ) const = 0;
1239 
1240 
1241  friend std::ostream &operator<<(std::ostream &o, const VDC &vdc);
1242 
1243 private:
1244  std::vector <string> _newUniformVars;
1245 
1246 protected:
1250  std::vector <size_t> _bs;
1251  string _wname;
1252  std::vector <size_t> _cratios;
1253  vector <bool> _periodic;
1254  VAPoR::UDUnits _udunits;
1255 
1256  std::map <string, Dimension> _dimsMap;
1257  std::map <string, Attribute> _atts;
1258  std::map <string, CoordVar> _coordVars;
1259  std::map <string, DataVar> _dataVars;
1260 
1261 #ifndef DOXYGEN_SKIP_THIS
1262 
1263  bool _ValidDefineDimension(string name, size_t length, int axis) const;
1264 
1265  bool _ValidDefineCoordVar(
1266  string varname, vector <string> dimnames,
1267  string units, int axis, XType type, bool compressed
1268  ) const;
1269 
1270 
1271  bool _valid_blocking(
1272  const vector <DC::Dimension> &dimensions,
1273  const vector <string> &coordvars,
1274  const vector <size_t> &bs
1275  ) const;
1276 
1277  bool _valid_mask_var(
1278  string varname, vector <DC::Dimension> dimensions,
1279  vector <size_t> bs, bool compressed, string maskvar
1280  ) const;
1281 
1282  bool _ValidDefineDataVar(
1283  string varname, vector <string> dimnames, vector <string> coordnames,
1284  string units, XType type, bool compressed, string maskvar
1285  ) const;
1286 
1287 
1288  bool _ValidCompressionBlock(
1289  vector <size_t> bs, string wname, vector <size_t> cratios
1290  ) const;
1291 
1292  virtual int _WriteMasterMeta() = 0;
1293  virtual int _ReadMasterMeta() = 0;
1294 
1295  int _DefineDataVar(
1296  string varname, std::vector <string> dimnames,
1297  std::vector <string> coordvars,
1298  string units, XType type, bool compressed, double mv, string maskvar
1299  );
1300 
1301 #endif
1302 
1303 };
1304 };
1305 
1306 #endif
Defines API for reading, writing, and appending data to a VAPOR Data Collection (Version 3) ...
Definition: VDC.h:177
std::vector< bool > GetPeriodicBoundary() const
Definition: VDC.h:331
void SetPeriodicBoundary(std::vector< bool > periodic)
Definition: VDC.h:322
std::map< string, Dimension > _dimsMap
Definition: VDC.h:1256
Base class for storing variable metadata.
Definition: DC.h:307
string _wname
Definition: VDC.h:1251
AccessMode _mode
Definition: VDC.h:1248
bool _defineMode
Definition: VDC.h:1249
Coordinate variable metadata.
Definition: DC.h:472
std::vector< size_t > _bs
Definition: VDC.h:1250
Metadata describing a coordinate dimension.
Definition: DC.h:161
vector< bool > _periodic
Definition: VDC.h:1253
string _master_path
Definition: VDC.h:1247
std::map< string, DataVar > _dataVars
Definition: VDC.h:1259
XType
External storage types for primitive data.
Definition: DC.h:155
Defines API for reading a collection of data.
Definition: DC.h:150
std::map< string, Attribute > _atts
Definition: VDC.h:1257
virtual int Initialize(const std::vector< string > &paths)
Definition: VDC.h:230
#define VDF_API
VAPoR::UDUnits _udunits
Definition: VDC.h:1254
Definition: DC.h:10
Data variable metadata.
Definition: DC.h:557
virtual ~VDC()
Definition: VDC.h:188
std::map< string, CoordVar > _coordVars
Definition: VDC.h:1258
AccessMode
Definition: VDC.h:182
std::vector< size_t > _cratios
Definition: VDC.h:1252