155 enum XType {INVALID = -1, FLOAT, DOUBLE, INT32, INT64, TEXT};
218 return(_name == rhs._name && _length==rhs._length && _axis==rhs._axis);
221 return(! (*
this==rhs));
223 friend std::ostream &operator<<(
224 std::ostream &o,
const Dimension &dimension
239 Attribute() {_name =
""; _type = FLOAT; _values.clear(); };
247 Attribute(
string name,
XType type,
const std::vector <float> &values);
248 Attribute(
string name,
XType type,
const std::vector <double> &values);
249 Attribute(
string name,
XType type,
const std::vector <int> &values);
250 Attribute(
string name,
XType type,
const std::vector <long> &values);
253 _name = name; _type = type; _values.clear();
270 void GetValues(std::vector <float> &values)
const;
271 void GetValues(std::vector <double> &values)
const;
272 void GetValues(std::vector <int> &values)
const;
273 void GetValues(std::vector <long> &values)
const;
274 void GetValues(
string &values)
const;
281 void SetValues(
const std::vector <float> &values);
282 void SetValues(
const std::vector <double> &values);
283 void SetValues(
const std::vector <int> &values);
284 void SetValues(
const std::vector <long> &values);
285 void SetValues(
const string &values);
287 friend std::ostream &operator<<(std::ostream &o,
const Attribute &attr);
299 std::vector <podunion> _values;
350 string name, std::vector <DC::Dimension> dimensions,
351 string units,
XType type,
352 std::vector <size_t> bs,
string wname,
353 std::vector <size_t> cratios, std::vector <bool> periodic
356 _dimensions(dimensions),
364 if (_cratios.size()==0) _cratios.push_back(1);
365 for (
int i=_bs.size(); i<_dimensions.size(); i++) _bs.push_back(1);
385 string name, std::vector <DC::Dimension> dimensions,
386 string units,
XType type, std::vector <bool> periodic
400 _dimensions = dimensions;
416 std::vector <size_t>
GetBS()
const {
return (_bs); };
417 void SetBS(std::vector <size_t> bs) {_bs = bs; };
426 std::vector <size_t>
GetCRatios()
const {
return (_cratios); };
429 if (_cratios.size()==0) _cratios.push_back(1);
435 void SetPeriodic(std::vector <bool> periodic) { _periodic = periodic; };
449 for (
int i=0; i<_dimensions.size(); i++) {
450 if (_dimensions[i].GetAxis() == 3)
return(
true);
455 friend std::ostream &operator<<(std::ostream &o,
const BaseVar &var);
459 std::vector <DC::Dimension> _dimensions;
463 std::vector <size_t> _cratios;
465 std::vector <bool> _periodic;
466 std::map <string, Attribute> _atts;
497 string name, std::vector <DC::Dimension> dimensions,
498 string units,
XType type,
499 std::vector <size_t> bs,
string wname,
500 std::vector <size_t> cratios, std::vector <bool> periodic,
501 int axis,
bool uniform
504 name, dimensions, units, type, bs,
523 string name, std::vector <DC::Dimension> dimensions,
524 string units,
XType type,
525 std::vector <bool> periodic,
526 int axis,
bool uniform
528 BaseVar(name, dimensions, units, type, periodic),
545 friend std::ostream &operator<<(std::ostream &o,
const CoordVar &var);
565 _has_missing =
false;
566 _missing_value = 0.0;
585 string name, std::vector <DC::Dimension> dimensions,
586 string units,
XType type,
587 std::vector <size_t> bs,
string wname,
588 std::vector <size_t> cratios,
589 std::vector <bool> periodic, std::vector <string> coordvars,
593 name, dimensions, units, type,
594 bs, wname, cratios, periodic
596 _coordvars(coordvars),
599 _missing_value(missing_value)
623 string name, std::vector <DC::Dimension> dimensions,
624 string units,
XType type,
625 std::vector <size_t> bs,
string wname,
626 std::vector <size_t> cratios,
627 std::vector <bool> periodic, std::vector <string> coordvars,
628 double missing_value,
string maskvar
631 name, dimensions, units, type,
632 bs, wname, cratios, periodic
634 _coordvars(coordvars),
637 _missing_value(missing_value)
652 string name, std::vector <DC::Dimension> dimensions,
653 string units,
XType type,
654 std::vector <size_t> bs,
string wname,
655 std::vector <size_t> cratios,
656 std::vector <bool> periodic, std::vector <string> coordvars
659 name, dimensions, units, type,
660 bs, wname, cratios, periodic
662 _coordvars(coordvars),
679 string name, std::vector <DC::Dimension> dimensions,
680 string units,
XType type,
681 std::vector <bool> periodic, std::vector <string> coordvars,
685 name, dimensions, units, type, periodic
687 _coordvars(coordvars),
690 _missing_value(missing_value)
712 string name, std::vector <DC::Dimension> dimensions,
713 string units,
XType type,
714 std::vector <bool> periodic, std::vector <string> coordvars,
715 double missing_value,
string maskvar
718 name, dimensions, units, type, periodic
720 _coordvars(coordvars),
723 _missing_value(missing_value)
736 string name, std::vector <DC::Dimension> dimensions,
737 string units,
XType type,
738 std::vector <bool> periodic, std::vector <string> coordvars
741 name, dimensions, units, type, periodic
743 _coordvars(coordvars),
755 void SetCoordvars(std::vector <string> coordvars) {_coordvars = coordvars; };
772 VDF_API friend std::ostream &operator<<(std::ostream &o,
const DataVar &var);
775 std::vector <string> _coordvars;
778 double _missing_value;
803 virtual int Initialize(
const vector <string> &paths) = 0;
817 virtual bool GetDimension(
826 virtual std::vector <string> GetDimensionNames()
const = 0;
840 virtual bool GetCoordVarInfo(
string varname,
DC::CoordVar &cvar)
const = 0;
854 virtual bool GetDataVarInfo(
string varname,
DC::DataVar &datavar)
const = 0;
867 virtual bool GetBaseVarInfo(
string varname,
DC::BaseVar &var)
const = 0;
875 virtual std::vector <string> GetDataVarNames()
const = 0;
883 virtual std::vector <string> GetCoordVarNames()
const = 0;
901 virtual int GetNumRefLevels(
string varname)
const = 0;
923 string varname,
string attname, vector <double> &values
926 string varname,
string attname, vector <long> &values
929 string varname,
string attname,
string &values
945 virtual std::vector <string> GetAttNames(
string varname)
const = 0;
958 virtual XType GetAttType(
string varname,
string attname)
const = 0;
983 virtual int GetDimLensAtLevel(
984 string varname,
int level, std::vector <size_t> &dims_at_level,
985 std::vector <size_t> &bs_at_level
1003 virtual int GetMapProjection(
1004 string lonname,
string latname,
string &projstring
1040 virtual int OpenVariableRead(
1041 size_t ts,
string varname,
int level=0,
int lod=0
1051 virtual int CloseVariable() = 0;
1069 int virtual Read(
float *data) = 0;
1095 virtual int ReadSlice(
float *slice) = 0;
1120 virtual int ReadRegion(
1121 const vector <size_t> &min,
const vector <size_t> &max,
float *region
1137 virtual int ReadRegionBlock(
1138 const vector <size_t> &min,
const vector <size_t> &max,
float *region
1165 virtual int GetVar(
string varname,
int level,
int lod,
float *data) = 0;
1195 size_t ts,
string varname,
int level,
int lod,
float *data
1212 virtual bool VariableExists(
1241 virtual bool GetDimension(
1242 string dimname,
size_t &length,
int &axis
1255 virtual std::vector <string> GetDataVarNames(
int ndim,
bool spatial)
const;
1269 virtual std::vector <string> GetCoordVarNames(
int ndim,
bool spatial)
const;
1281 virtual bool IsTimeVarying(
string varname)
const;
1294 virtual bool IsCompressed(
string varname)
const;
1309 virtual int GetNumTimeSteps(
string varname)
const;
1324 virtual int GetCRatios(
string varname, vector <size_t> &cratios)
const;
1335 vector <string> names = GetDataVarNames();
1336 return(find(names.begin(), names.end(), varname) != names.end());
1348 vector <string> names = GetDataVarNames();
1349 return(find(names.begin(), names.end(), varname) != names.end());
1368 virtual int GetMapProjection(
string varname,
string &projstring)
const;
1386 static bool ParseDimensions(
1387 const vector <DC::Dimension> &dimensions,
1388 vector <size_t> &sdims,
size_t &numts
Attribute(string name, XType type)
bool operator!=(const Dimension &rhs) const
bool GetUniform() const
Access coordinate variable uniform sampling flag.
void SetPeriodic(std::vector< bool > periodic)
std::vector< string > GetCoordvars() const
Access data variable's coordinate variable names.
void SetXType(XType type)
std::vector< size_t > GetBS() const
Access variable's block size.
void SetAttributes(std::map< string, Attribute > &atts)
bool IsCompressed() const
Return true if no wavelet is defined.
void SetCRatios(std::vector< size_t > cratios)
void SetUniform(bool uniform)
string GetUnits() const
Access variable units.
Base class for storing variable metadata.
virtual bool IsDataVar(string varname) const
void SetName(string name)
Set dimension name.
DataVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< size_t > bs, string wname, std::vector< size_t > cratios, std::vector< bool > periodic, std::vector< string > coordvars, double missing_value, string maskvar)
DataVar()
constructor for default Data variable definition
std::vector< size_t > GetCRatios() const
Access variable's compression ratios.
void SetMissingValue(double missing_value)
int GetAxis() const
Access coordinate variable axis.
bool IsTimeVarying() const
Return true if a time dimension is present.
CoordVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< bool > periodic, int axis, bool uniform)
void SetDimensions(std::vector< DC::Dimension > dimensions)
DataVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< bool > periodic, std::vector< string > coordvars, double missing_value)
Coordinate variable metadata.
std::vector< bool > GetPeriodic() const
Access variable bounary periodic.
void SetCoordvars(std::vector< string > coordvars)
int GetAxis() const
Access dimension axis.
CoordVar()
Default Coordinate Variable metadata constructor.
std::vector< DC::Dimension > GetDimensions() const
Access variable's dimension names.
DataVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< bool > periodic, std::vector< string > coordvars)
void SetName(string name)
Metadata describing a coordinate dimension.
void SetUnits(string units)
DataVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< size_t > bs, string wname, std::vector< size_t > cratios, std::vector< bool > periodic, std::vector< string > coordvars)
Dimension(std::string name, size_t length, int axis)
void SetBS(std::vector< size_t > bs)
CoordVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< size_t > bs, string wname, std::vector< size_t > cratios, std::vector< bool > periodic, int axis, bool uniform)
size_t GetLength() const
Access dimension length.
virtual bool IsCoordVar(string varname) const
BaseVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< size_t > bs, string wname, std::vector< size_t > cratios, std::vector< bool > periodic)
string GetMaskvar() const
Access data variable's mask variable names.
XType
External storage types for primitive data.
DataVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< bool > periodic, std::vector< string > coordvars, double missing_value, string maskvar)
Defines API for reading a collection of data.
string GetName() const
Get variable name.
void SetAxis(int axis)
Set dimension axis.
std::map< string, Attribute > GetAttributes() const
Access variable attributes.
string GetName() const
Get attribute name.
void SetLength(size_t length)
Set dimension length.
string GetName() const
Get dimension name.
XType GetXType() const
Access variable external storage type.
double GetMissingValue() const
Access data variable's missing data value.
XType GetXType() const
Get an attribute's external representation type.
void SetMaskvar(string maskvar)
Variable or global metadata.
void SetHasMissing(bool has_missing)
string GetWName() const
Access variable's wavelet family name.
bool operator==(const Dimension &rhs) const
DataVar(string name, std::vector< DC::Dimension > dimensions, string units, XType type, std::vector< size_t > bs, string wname, std::vector< size_t > cratios, std::vector< bool > periodic, std::vector< string > coordvars, double missing_value)
void SetWName(string wname)
bool GetHasMissing() const
Access data variable's missing data flag.