VAPOR3 3.9.4
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>
7
8#ifndef _VDC_H_
9 #define _VDC_H_
10
11namespace VAPoR {
12
165class VDF_API VDC : public VAPoR::DC {
166public:
169 enum AccessMode { R, W, A };
170
175 virtual ~VDC() {}
176
177protected:
228 //
229 virtual int initialize(const std::vector<string> &paths, const std::vector<string> &options, AccessMode mode, vector<size_t> bs);
230 virtual int initialize(const std::vector<string> &paths, const std::vector<string> &options) { return (initialize(paths, options, R, vector<size_t>())); }
231
232public:
274 //
275 int SetCompressionBlock(string wname, std::vector<size_t> cratios);
276
286 //
287 void GetCompressionBlock(std::vector<size_t> &bs, string &wname, std::vector<size_t> &cratios) const;
288
300 void SetPeriodicBoundary(std::vector<bool> periodic)
301 {
302 _periodic = periodic;
303 for (int i = _periodic.size(); i < 3; i++) _periodic.push_back(false);
304 }
305
309 //
310 std::vector<bool> GetPeriodicBoundary() const { return (_periodic); };
311
339 //
340 int DefineDimension(string dimname, size_t length);
341
360 //
361 int DefineDimension(string dimname, size_t length, int axis);
362
363protected:
365 //
366 bool getDimension(string dimname, DC::Dimension &dimension) const;
367
369 //
370 std::vector<string> getDimensionNames() const;
371
373 //
374 std::vector<string> getMeshNames() const;
375
376 virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const;
377
379 //
380 bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const;
381
383 //
384 bool getDataVarInfo(string varname, DC::DataVar &datavar) const;
385
387 //
388 bool getAuxVarInfo(string varname, DC::AuxVar &var) const { return (false); }
389
391 //
392 bool getBaseVarInfo(string varname, DC::BaseVar &var) const;
393
394 virtual std::vector<string> getDataVarNames() const;
395
396 virtual std::vector<string> getAuxVarNames() const { return (vector<string>()); }
397
398 virtual std::vector<string> getCoordVarNames() const;
399
401 //
402 size_t getNumRefLevels(string varname) const;
403
404 bool getAtt(string varname, string attname, vector<double> &values) const;
405 bool getAtt(string varname, string attname, vector<long> &values) const;
406 bool getAtt(string varname, string attname, string &values) const;
407
408 std::vector<string> getAttNames(string varname) const;
409
410 XType getAttType(string varname, string attname) const;
411
412 virtual vector<size_t> getBlockSize() const { return (_bs); }
413
414 virtual int getDimLensAtLevel(string varname, int level, std::vector<size_t> &dims_at_level, std::vector<size_t> &bs_at_level) const = 0;
415
416 virtual string getMapProjection(string varname) const;
417
418 virtual string getMapProjection() const;
419
420 virtual string getMapProjectionDefault() const { return (getMapProjection()); }
421
422 virtual int openVariableRead(size_t ts, string varname, int level = 0, int lod = 0) = 0;
423
424 virtual int closeVariable(int fd) = 0;
425
426 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, float *region) = 0;
427 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, double *region) = 0;
428
429public:
473 //
474 int DefineCoordVar(string varname, std::vector<string> dimnames, string time_dim_name, string units, int axis, XType type, bool compressed);
475
517 //
518 int DefineCoordVarUniform(string varname, std::vector<string> dimname, string time_dim_name, string units, int axis, XType type, bool compressed);
519
551 int DefineDataVar(string varname, std::vector<string> dimnames, std::vector<string> coordvars, string units, XType type, bool compressed);
552
577 int DefineDataVar(string varname, std::vector<string> dimnames, std::vector<string> coordvars, string units, XType type, double missing_value, string maskvar);
578
596 //
597 int PutAtt(string varname, string attname, XType type, const vector<double> &values);
598 int PutAtt(string varname, string attname, XType type, const vector<long> &values);
599 int PutAtt(string varname, string attname, XType type, const string &values);
600
616 //
617 int CopyAtt(const DC &src, string varname, string attname);
618
634 //
635 int CopyAtt(const DC &src, string varname);
636
643 //
644 virtual int SetMapProjection(string varname, string projstring);
645
652 virtual int SetMapProjection(string projstring);
653
672
695 virtual int GetPath(string varname, size_t ts, string &path, size_t &file_ts, size_t &max_ts
696
697 ) const = 0;
698
730 //
731 virtual int OpenVariableWrite(size_t ts, string varname, int lod = -1) = 0;
732
733 virtual int CloseVariableWrite(int fd) = 0;
734
747 //
748 virtual int Write(int fd, const float *data) = 0;
749 virtual int Write(int fd, const int *data) = 0;
750
772 virtual int WriteSlice(int fd, const float *slice) = 0;
773 virtual int WriteSlice(int fd, const int *slice) = 0;
774 virtual int WriteSlice(int fd, const unsigned char *slice) = 0;
775
797 //
798 virtual int PutVar(string varname, int lod, const float *data) = 0;
799 virtual int PutVar(string varname, int lod, const int *data) = 0;
800
824 //
825 virtual int PutVar(size_t ts, string varname, int lod, const float *data) = 0;
826 virtual int PutVar(size_t ts, string varname, int lod, const int *data) = 0;
827
841 virtual int CopyVar(DC &dc, string varname, int srclod, int dstlod) = 0;
842
845 //
846 virtual int CopyVar(DC &dc, size_t ts, string varname, int srclod, int dstlod) = 0;
847
867 virtual bool CompressionInfo(vector<size_t> bs, string wname, size_t &nlevels, size_t &maxcratio) const = 0;
868
881 //
882 virtual bool variableExists(size_t ts, string varname, int reflevel = 0, int lod = 0) const = 0;
883
884 friend std::ostream &operator<<(std::ostream &o, const VDC &vdc);
885
886private:
887 string _proj4StringOption;
888 std::vector<string> _newUniformVars;
889
890protected:
894 std::vector<size_t> _bs;
895 string _wname;
896 std::vector<size_t> _cratios;
897 vector<bool> _periodic;
899
900 std::map<string, Dimension> _dimsMap;
901 std::map<string, Attribute> _atts;
902 std::map<string, CoordVar> _coordVars;
903 std::map<string, DataVar> _dataVars;
904 std::map<string, Mesh> _meshes;
905
906 #ifndef DOXYGEN_SKIP_THIS
907
908 bool _ValidDefineDimension(string name, size_t length) const;
909
910 bool _ValidDefineCoordVar(string varname, vector<string> dimnames, string time_dim_name, string units, int axis, XType type, bool compressed) const;
911
912 bool _valid_blocking(const vector<DC::Dimension> &dimensions, const vector<size_t> &bs, const vector<string> &coordvars) const;
913
914 bool _valid_mask_var(string varname, vector<DC::Dimension> dimensions, vector<size_t> bs, bool compressed, string maskvar) const;
915
916 bool _ValidDefineDataVar(string varname, vector<string> dimnames, vector<string> coordnames, string units, XType type, bool compressed, bool has_missing, string maskvar) const;
917
918 bool _ValidCompressionBlock(vector<size_t> bs, string wname, vector<size_t> cratios) const;
919
920 bool _valid_dims(const vector<DC::Dimension> &dims0, const vector<size_t> &bs0, const vector<DC::Dimension> &dims1, const vector<size_t> &bs1) const;
921
922 virtual int _WriteMasterMeta() = 0;
923 virtual int _ReadMasterMeta() = 0;
924
925 void _DefineMesh(string meshname, vector<string> dim_names, vector<string> coord_vars);
926
927 int _DefineDataVar(string varname, std::vector<string> dimnames, std::vector<string> coordvars, string units, XType type, bool compressed, bool has_missing, double mv, string maskvar);
928
929 vector<string> _GetCoordVarDimNames(const CoordVar &var, bool &time_varying) const;
930
931 vector<string> _GetDataVarDimNames(const DataVar &var, bool &time_varying) const;
932
933 int _DefineImplicitCoordVars(vector<string> dim_names, vector<string> coord_vars_in, vector<string> &coord_vars_out);
934
935 #endif
936};
937}; // namespace VAPoR
938
939#endif
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
Defines API for reading, writing, and appending data to a VAPOR Data Collection (Version 3)
Definition: VDC.h:165
virtual int initialize(const std::vector< string > &paths, const std::vector< string > &options, AccessMode mode, vector< size_t > bs)
virtual int PutVar(string varname, int lod, const float *data)=0
virtual ~VDC()
Definition: VDC.h:175
std::vector< string > getAttNames(string varname) const
std::vector< size_t > _bs
Definition: VDC.h:894
int PutAtt(string varname, string attname, XType type, const vector< double > &values)
virtual string getMapProjection() const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, double *region)=0
virtual int CopyVar(DC &dc, size_t ts, string varname, int srclod, int dstlod)=0
friend std::ostream & operator<<(std::ostream &o, const VDC &vdc)
bool getDataVarInfo(string varname, DC::DataVar &datavar) const
bool getAtt(string varname, string attname, vector< long > &values) const
int CopyAtt(const DC &src, string varname)
virtual string getMapProjectionDefault() const
Definition: VDC.h:420
VAPoR::UDUnits _udunits
Definition: VDC.h:898
virtual int Write(int fd, const float *data)=0
int DefineDimension(string dimname, size_t length, int axis)
bool getAtt(string varname, string attname, vector< double > &values) const
virtual int SetMapProjection(string projstring)
virtual int WriteSlice(int fd, const int *slice)=0
bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const
virtual int closeVariable(int fd)=0
virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const
XType getAttType(string varname, string attname) const
bool getDimension(string dimname, DC::Dimension &dimension) const
std::vector< string > getDimensionNames() const
virtual int SetMapProjection(string varname, string projstring)
int CopyAtt(const DC &src, string varname, string attname)
virtual int WriteSlice(int fd, const unsigned char *slice)=0
AccessMode
Definition: VDC.h:169
int PutAtt(string varname, string attname, XType type, const string &values)
void SetPeriodicBoundary(std::vector< bool > periodic)
Definition: VDC.h:300
virtual std::vector< string > getCoordVarNames() const
vector< bool > _periodic
Definition: VDC.h:897
virtual int PutVar(string varname, int lod, const int *data)=0
std::map< string, Dimension > _dimsMap
Definition: VDC.h:900
std::map< string, CoordVar > _coordVars
Definition: VDC.h:902
bool getAtt(string varname, string attname, string &values) const
size_t getNumRefLevels(string varname) const
bool getBaseVarInfo(string varname, DC::BaseVar &var) const
string _wname
Definition: VDC.h:895
int PutAtt(string varname, string attname, XType type, const vector< long > &values)
std::map< string, DataVar > _dataVars
Definition: VDC.h:903
virtual string getMapProjection(string varname) const
AccessMode _mode
Definition: VDC.h:892
int SetCompressionBlock(string wname, std::vector< size_t > cratios)
virtual std::vector< string > getDataVarNames() const
int DefineCoordVarUniform(string varname, std::vector< string > dimname, string time_dim_name, string units, int axis, XType type, bool compressed)
std::vector< bool > GetPeriodicBoundary() const
Definition: VDC.h:310
virtual int initialize(const std::vector< string > &paths, const std::vector< string > &options)
Definition: VDC.h:230
std::map< string, Attribute > _atts
Definition: VDC.h:901
virtual int OpenVariableWrite(size_t ts, string varname, int lod=-1)=0
int DefineDataVar(string varname, std::vector< string > dimnames, std::vector< string > coordvars, string units, XType type, double missing_value, string maskvar)
virtual int CloseVariableWrite(int fd)=0
std::map< string, Mesh > _meshes
Definition: VDC.h:904
virtual int Write(int fd, const int *data)=0
bool _defineMode
Definition: VDC.h:893
virtual int WriteSlice(int fd, const float *slice)=0
virtual bool CompressionInfo(vector< size_t > bs, string wname, size_t &nlevels, size_t &maxcratio) const =0
virtual int openVariableRead(size_t ts, string varname, int level=0, int lod=0)=0
int DefineDataVar(string varname, std::vector< string > dimnames, std::vector< string > coordvars, string units, XType type, bool compressed)
int DefineCoordVar(string varname, std::vector< string > dimnames, string time_dim_name, string units, int axis, XType type, bool compressed)
int DefineDimension(string dimname, size_t length)
std::vector< size_t > _cratios
Definition: VDC.h:896
virtual int PutVar(size_t ts, string varname, int lod, const int *data)=0
virtual int getDimLensAtLevel(string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level) const =0
virtual int PutVar(size_t ts, string varname, int lod, const float *data)=0
virtual int CopyVar(DC &dc, string varname, int srclod, int dstlod)=0
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, float *region)=0
bool getAuxVarInfo(string varname, DC::AuxVar &var) const
Definition: VDC.h:388
virtual vector< size_t > getBlockSize() const
Definition: VDC.h:412
std::vector< string > getMeshNames() const
virtual int GetPath(string varname, size_t ts, string &path, size_t &file_ts, size_t &max_ts) const =0
void GetCompressionBlock(std::vector< size_t > &bs, string &wname, std::vector< size_t > &cratios) const
virtual std::vector< string > getAuxVarNames() const
Definition: VDC.h:396
string _master_path
Definition: VDC.h:891
int EndDefine()
virtual bool variableExists(size_t ts, string varname, int reflevel=0, int lod=0) const =0
#define VDF_API
Definition: common.h:73