VAPOR3 3.9.4
|
Defines API for reading, writing, and appending data to a VAPOR Data Collection (Version 3) More...
#include <VDC.h>
Public Types | |
enum | AccessMode { R , W , A } |
Public Types inherited from VAPoR::DC | |
enum | XType { INVALID = -1 , FLOAT , DOUBLE , UINT8 , INT8 , INT32 , INT64 , TEXT } |
External storage types for primitive data. More... | |
Public Types inherited from Wasp::MyBase | |
typedef void(* | ErrMsgCB_T) (const char *msg, int err_code) |
typedef void(* | DiagMsgCB_T) (const char *msg) |
Public Member Functions | |
VDC () | |
virtual | ~VDC () |
int | SetCompressionBlock (string wname, std::vector< size_t > cratios) |
void | GetCompressionBlock (std::vector< size_t > &bs, string &wname, std::vector< size_t > &cratios) const |
void | SetPeriodicBoundary (std::vector< bool > periodic) |
std::vector< bool > | GetPeriodicBoundary () const |
int | DefineDimension (string dimname, size_t length) |
int | DefineDimension (string dimname, size_t length, int axis) |
int | DefineCoordVar (string varname, std::vector< string > dimnames, string time_dim_name, string units, int axis, XType type, bool compressed) |
int | DefineCoordVarUniform (string varname, std::vector< string > dimname, string time_dim_name, string units, int axis, XType type, bool compressed) |
int | DefineDataVar (string varname, std::vector< string > dimnames, std::vector< string > coordvars, string units, XType type, bool compressed) |
int | DefineDataVar (string varname, std::vector< string > dimnames, std::vector< string > coordvars, string units, XType type, double missing_value, string maskvar) |
int | PutAtt (string varname, string attname, XType type, const vector< double > &values) |
int | PutAtt (string varname, string attname, XType type, const vector< long > &values) |
int | PutAtt (string varname, string attname, XType type, const string &values) |
int | CopyAtt (const DC &src, string varname, string attname) |
int | CopyAtt (const DC &src, string varname) |
virtual int | SetMapProjection (string varname, string projstring) |
virtual int | SetMapProjection (string projstring) |
int | EndDefine () |
virtual int | GetPath (string varname, size_t ts, string &path, size_t &file_ts, size_t &max_ts) const =0 |
virtual int | OpenVariableWrite (size_t ts, string varname, int lod=-1)=0 |
virtual int | CloseVariableWrite (int fd)=0 |
virtual int | Write (int fd, const float *data)=0 |
virtual int | Write (int fd, const int *data)=0 |
virtual int | WriteSlice (int fd, const float *slice)=0 |
virtual int | WriteSlice (int fd, const int *slice)=0 |
virtual int | WriteSlice (int fd, const unsigned char *slice)=0 |
virtual int | PutVar (string varname, int lod, const float *data)=0 |
virtual int | PutVar (string varname, int lod, const int *data)=0 |
virtual int | PutVar (size_t ts, string varname, int lod, const float *data)=0 |
virtual int | PutVar (size_t ts, string varname, int lod, const int *data)=0 |
virtual int | CopyVar (DC &dc, string varname, int srclod, int dstlod)=0 |
virtual int | CopyVar (DC &dc, size_t ts, string varname, int srclod, int dstlod)=0 |
virtual bool | CompressionInfo (vector< size_t > bs, string wname, size_t &nlevels, size_t &maxcratio) const =0 |
virtual bool | variableExists (size_t ts, string varname, int reflevel=0, int lod=0) const =0 |
Public Member Functions inherited from VAPoR::DC | |
DC () | |
virtual | ~DC () |
virtual int | Initialize (const std::vector< string > &paths, const std::vector< string > &options=std::vector< string >()) |
virtual bool | GetDimension (string dimname, DC::Dimension &dimension, long ts) const |
virtual std::vector< string > | GetDimensionNames () const |
virtual std::vector< string > | GetMeshNames () const |
virtual bool | GetMesh (string mesh_name, DC::Mesh &mesh) const |
virtual bool | GetMeshDimLens (const string &mesh_name, std::vector< size_t > &dims, long ts=-1) const |
virtual bool | GetMeshDimNames (const string &mesh_name, std::vector< string > &dimnames) const |
virtual bool | GetCoordVarInfo (string varname, DC::CoordVar &cvar) const |
virtual bool | GetDataVarInfo (string varname, DC::DataVar &datavar) const |
virtual bool | GetAuxVarInfo (string varname, DC::AuxVar &var) const |
virtual bool | GetBaseVarInfo (string varname, DC::BaseVar &var) const |
virtual std::vector< string > | GetDataVarNames () const |
virtual std::vector< string > | GetCoordVarNames () const |
virtual std::vector< string > | GetAuxVarNames () const |
virtual size_t | GetNumRefLevels (string varname) const |
virtual bool | GetAtt (string varname, string attname, vector< double > &values) const |
virtual bool | GetAtt (string varname, string attname, vector< long > &values) const |
virtual bool | GetAtt (string varname, string attname, string &values) const |
virtual std::vector< string > | GetAttNames (string varname) const |
virtual XType | GetAttType (string varname, string attname) const |
virtual int | GetDimLensAtLevel (string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level, long ts=-1) const |
virtual int | GetDimLens (string varname, std::vector< size_t > &dims, long ts=-1) |
virtual string | GetMapProjection () const |
virtual int | OpenVariableRead (size_t ts, string varname, int level=0, int lod=0) |
virtual int | CloseVariable (int fd) |
virtual int | Read (int fd, float *data) |
virtual int | Read (int fd, double *data) |
virtual int | Read (int fd, int *data) |
virtual int | ReadSlice (int fd, float *slice) |
virtual int | ReadSlice (int fd, double *slice) |
virtual int | ReadSlice (int fd, int *slice) |
virtual int | ReadRegion (int fd, const vector< size_t > &min, const vector< size_t > &max, float *region) |
virtual int | ReadRegion (int fd, const vector< size_t > &min, const vector< size_t > &max, double *region) |
virtual int | ReadRegion (int fd, const vector< size_t > &min, const vector< size_t > &max, int *region) |
virtual int | GetVar (string varname, int level, int lod, float *data) |
virtual int | GetVar (string varname, int level, int lod, double *data) |
virtual int | GetVar (string varname, int level, int lod, int *data) |
virtual int | GetVar (size_t ts, string varname, int level, int lod, float *data) |
virtual int | GetVar (size_t ts, string varname, int level, int lod, double *data) |
virtual int | GetVar (size_t ts, string varname, int level, int lod, int *data) |
virtual bool | VariableExists (size_t ts, string varname, int reflevel=0, int lod=0) const |
virtual int | GetHyperSliceInfo (string varname, int level, std::vector< size_t > &dims, size_t &nslice, long ts=-1) |
virtual std::vector< string > | GetDataVarNames (int ndim) const |
virtual bool | GetVarDimensions (string varname, bool spatial, vector< DC::Dimension > &dimensions, long ts) const |
virtual bool | GetVarDimLens (string varname, bool spatial, vector< size_t > &dimlens, long ts=-1) const |
virtual bool | GetVarDimLens (string varname, vector< size_t > &sdimlens, size_t &time_dimlen, long ts=-1) const |
virtual bool | GetVarDimNames (string varname, bool spatial, vector< string > &dimnames) const |
virtual bool | GetVarDimNames (string varname, vector< string > &sdimnames, string &time_dimname) const |
virtual size_t | GetVarTopologyDim (string varname) const |
virtual size_t | GetVarGeometryDim (string varname) const |
virtual bool | IsTimeVarying (string varname) const |
virtual bool | IsCompressed (string varname) const |
virtual int | GetNumTimeSteps (string varname) const |
virtual std::vector< size_t > | GetCRatios (string varname) const |
virtual bool | IsDataVar (string varname) const |
virtual bool | IsCoordVar (string varname) const |
virtual bool | IsAuxVar (string varname) const |
virtual bool | GetVarCoordVars (string varname, bool spatial, std::vector< string > &coord_vars) const |
bool | GetVarConnVars (string varname, string &face_node_var, string &node_face_var, string &face_edge_var, string &face_face_var, string &edge_node_var, string &edge_face_var) const |
virtual size_t | GetNumDimensions (string varname) const |
std::vector< string > | GetTimeCoordVarNames () const |
Public Member Functions inherited from Wasp::MyBase | |
MyBase () | |
const string & | getClassName () const |
Protected Member Functions | |
virtual int | initialize (const std::vector< string > &paths, const std::vector< string > &options, AccessMode mode, vector< size_t > bs) |
virtual int | initialize (const std::vector< string > &paths, const std::vector< string > &options) |
bool | getDimension (string dimname, DC::Dimension &dimension) const |
std::vector< string > | getDimensionNames () const |
std::vector< string > | getMeshNames () const |
virtual bool | getMesh (string mesh_name, DC::Mesh &mesh) const |
bool | getCoordVarInfo (string varname, DC::CoordVar &cvar) const |
bool | getDataVarInfo (string varname, DC::DataVar &datavar) const |
bool | getAuxVarInfo (string varname, DC::AuxVar &var) const |
bool | getBaseVarInfo (string varname, DC::BaseVar &var) const |
virtual std::vector< string > | getDataVarNames () const |
virtual std::vector< string > | getAuxVarNames () const |
virtual std::vector< string > | getCoordVarNames () const |
size_t | getNumRefLevels (string varname) const |
bool | getAtt (string varname, string attname, vector< double > &values) const |
bool | getAtt (string varname, string attname, vector< long > &values) const |
bool | getAtt (string varname, string attname, string &values) const |
std::vector< string > | getAttNames (string varname) const |
XType | getAttType (string varname, string attname) const |
virtual vector< size_t > | getBlockSize () const |
virtual int | getDimLensAtLevel (string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level) const =0 |
virtual string | getMapProjection (string varname) const |
virtual string | getMapProjection () const |
virtual string | getMapProjectionDefault () const |
virtual int | openVariableRead (size_t ts, string varname, int level=0, int lod=0)=0 |
virtual int | closeVariable (int fd)=0 |
virtual int | readRegion (int fd, const vector< size_t > &min, const vector< size_t > &max, float *region)=0 |
virtual int | readRegion (int fd, const vector< size_t > &min, const vector< size_t > &max, double *region)=0 |
Protected Member Functions inherited from VAPoR::DC | |
virtual int | initialize (const std::vector< string > &paths, const std::vector< string > &options=std::vector< string >())=0 |
virtual bool | getDimension (string dimname, DC::Dimension &dimension) const =0 |
virtual bool | getDimension (string dimname, DC::Dimension &dimension, long ts) const |
virtual std::vector< string > | getDimensionNames () const =0 |
virtual std::vector< string > | getMeshNames () const =0 |
virtual bool | getMesh (string mesh_name, DC::Mesh &mesh) const =0 |
virtual bool | getCoordVarInfo (string varname, DC::CoordVar &cvar) const =0 |
virtual bool | getDataVarInfo (string varname, DC::DataVar &datavar) const =0 |
virtual bool | getAuxVarInfo (string varname, DC::AuxVar &var) const =0 |
virtual bool | getBaseVarInfo (string varname, DC::BaseVar &var) const =0 |
virtual std::vector< string > | getDataVarNames () const =0 |
virtual std::vector< string > | getCoordVarNames () const =0 |
virtual std::vector< string > | getAuxVarNames () const =0 |
virtual size_t | getNumRefLevels (string varname) const =0 |
virtual bool | getAtt (string varname, string attname, vector< double > &values) const =0 |
virtual bool | getAtt (string varname, string attname, vector< long > &values) const =0 |
virtual bool | getAtt (string varname, string attname, string &values) const =0 |
virtual std::vector< string > | getAttNames (string varname) const =0 |
virtual XType | getAttType (string varname, string attname) const =0 |
virtual vector< size_t > | getBlockSize () const |
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 | getDimLensAtLevel (string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level, long ts) const |
virtual string | getMapProjection () const =0 |
virtual int | openVariableRead (size_t ts, string varname, int level=0, int lod=0)=0 |
virtual int | closeVariable (int fd)=0 |
virtual int | readRegion (int fd, const vector< size_t > &min, const vector< size_t > &max, float *region)=0 |
virtual int | readRegion (int fd, const vector< size_t > &min, const vector< size_t > &max, double *region)=0 |
virtual int | readRegion (int fd, const vector< size_t > &min, const vector< size_t > &max, int *region)=0 |
virtual bool | variableExists (size_t ts, string varname, int reflevel=0, int lod=0) const =0 |
Protected Member Functions inherited from Wasp::MyBase | |
void | SetClassName (const string &name) |
Protected Attributes | |
string | _master_path |
AccessMode | _mode |
bool | _defineMode |
std::vector< size_t > | _bs |
string | _wname |
std::vector< size_t > | _cratios |
vector< bool > | _periodic |
VAPoR::UDUnits | _udunits |
std::map< string, Dimension > | _dimsMap |
std::map< string, Attribute > | _atts |
std::map< string, CoordVar > | _coordVars |
std::map< string, DataVar > | _dataVars |
std::map< string, Mesh > | _meshes |
Protected Attributes inherited from VAPoR::DC | |
DC::FileTable | _fileTable |
Friends | |
std::ostream & | operator<< (std::ostream &o, const VDC &vdc) |
Additional Inherited Members | |
Static Public Member Functions inherited from Wasp::MyBase | |
static void | SetErrMsg (const char *format,...) |
Record a formatted error message. | |
static void | SetErrMsg (int errcode, const char *format,...) |
Record a formatted error message and an error code. | |
static const char * | GetErrMsg () |
static void | SetErrCode (int err_code) |
Record an error code. | |
static int | GetErrCode () |
Retrieve the current error code. | |
static void | SetErrMsgCB (ErrMsgCB_T cb) |
static ErrMsgCB_T | GetErrMsgCB () |
static void | SetErrMsgFilePtr (FILE *fp) |
static const FILE * | SetErrMsgFilePtr () |
static void | SetDiagMsg (const char *format,...) |
Record a formatted diagnostic message. | |
static const char * | GetDiagMsg () |
static void | SetDiagMsgCB (DiagMsgCB_T cb) |
static DiagMsgCB_T | GetDiagMsgCB () |
static void | SetDiagMsgFilePtr (FILE *fp) |
static bool | EnableErrMsg (bool enable) |
static bool | GetEnableErrMsg () |
Static Public Attributes inherited from Wasp::MyBase | |
static char * | ErrMsg |
static int | ErrCode |
static int | ErrMsgSize |
static FILE * | ErrMsgFilePtr |
static ErrMsgCB_T | ErrMsgCB |
static char * | DiagMsg |
static int | DiagMsgSize |
static FILE * | DiagMsgFilePtr |
static DiagMsgCB_T | DiagMsgCB |
static bool | Enabled |
Defines API for reading, writing, and appending data to a VAPOR Data Collection (Version 3)
This abstract class efines API for reading, writing, and appending data to a VAPOR Data Collection (Version 3). The VDC class is an abstract virtual class, providing a public API, but performing no actual storage operations. Derived implementations of the VDC base class are required to support the API.
In version 3 of the VDC the metadata (.vdf) file found in VDC version 1 and 2 is replaced with a "master" file that describes the contents of the entire VDC. The master file imposes structure on the organization of the files containing data, determining, for example, which data files contain which variables and time steps.
Unlike the .vdf file, it is intended that the master file will be stored in the same scientific data file format as the data themselves (though this depends on the implementation of the derived class). Another important change in version 3 is that both the master file and the accompanying data files are intended to be accessible using the native file format API. I.e. users may operate on files in the VDC using, for example, the NetCDF API, or they may use the API provided by the VDC class object. The latter is only required when reading or writing compressed variables (not all variables in a VDC version 3 must be compressed). Thus if NetCDF is chosen as the underlying format the NetCDF API may be used directly to read and write NetCDF "attributes" and variables (provided the variables are not compressed).
Variables in a VDC may have 1, 2, or 3 spatial dimensions, and 0 or 1 temporal dimensions.
The VDC is structured in the spirit of the "NetCDF Climate and Forecast (CF) Metadata Conventions", version 1.6, 5, December 2011. It supports only a subset of the CF functionality (e.g. there is no support for "Discrete Sampling Geometries"). Moreover, it is more restrictive than the CF in a number of areas. Particular items of note include:
This class inherits from Wasp::MyBase. Unless otherwise documented any method that returns an integer value is returning status. A negative value indicates failure. Error messages are logged via Wasp::MyBase::SetErrMsg(). Methods that return a boolean do not, unless otherwise documented, log an error message upon failure (return of false).
level | Grid refinement level for multiresolution variables. Compressed variables in the VDC have a multi-resolution representation: the sampling grid for multi-resolution variables is hierarchical, and the dimension lengths of adjacent levels in the hierarchy differ by a factor of two. The To provide maximum flexibility as well as compatibility with previous versions of the VDC the interpretation of For positive values of For negative values of |
lod | The level-of-detail parameter, For positive values of For negative values of |
cratios | A monotonically decreasing vector of compression ratios. Compressed variables in the VDC are stored with a fixed, finite number of compression factors. The cratios vector is used to specify the available compression factors (ratios). A compression factor of 1 indicates no compression (1:1). A value of 2 indciates two to one compression (2:1), and so on. The minimum valid value of cratios is 1. The maximum value is determined by a number of factors and can be obtained using the CompressionInfo() method. |
wname | Name of wavelet used for transforming compressed variables between wavelet and physical space. Valid values are "bior1.1", "bior1.3", "bior1.5", "bior2.2", "bior2.4", "bior2.6", "bior2.8", "bior3.1", "bior3.3", "bior3.5", "bior3.7", "bior3.9", "bior4.4" |
enum VAPoR::VDC::AccessMode |
VAPoR::VDC::VDC | ( | ) |
Class constuctor
|
protectedpure virtual |
Close the currently opened variable
Close the handle for variable opened with OpenVariableRead()
[in] | fd | A valid file descriptor returned by OpenVariableRead() |
Implements VAPoR::DC.
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
This method computes and returns the depth (number of levels) in a a multi-resolution hierarch for a given wavelet, wname
, and decomposition block, bs
. It also computes the maximum compression ratio, cratio
, possible for the the specified combination of block size, bs
, and wavelet, wname
. The maximum compression ratio is cratio:1
.
[in] | bs | Dimensions of native decomposition block. The rank of bs may be less than or equal to the rank of dims . |
[in] | wname | wavelet name. Empty string if no compression is to be performed. |
[out] | nlevels | Number of levels in hierarchy |
[out] | maxcratio | Maximum compression ratio |
bool | If bs , wname , or the combination there of is invalid false is returned and the values of nlevels and maxcratio are undefined. Upon success true is returned. |
int VAPoR::VDC::CopyAtt | ( | const DC & | src, |
string | varname | ||
) |
Copy attributes
This method copies attributes from the src DC. The attributes can either be "global", if varname
is the empty string, or bound to a variable if varname
indentifies a variable in the src DC. All attributes associated with varname
are copied.
[in] | src | The source DC from which to copy. |
[in] | varname | The name of the variable the attribute is bound to, or the empty string if the attribute is global |
status | A negative int is returned on failure. 0 returned on success. |
int VAPoR::VDC::CopyAtt | ( | const DC & | src, |
string | varname, | ||
string | attname | ||
) |
Copy an attribute
This method copies an attribute from the src DC. The attribute can either be "global", if varname
is the empty string, or bound to a variable if varname
indentifies a variable in the src DC.
[in] | src | The source DC from which to copy. |
[in] | varname | The name of the variable the attribute is bound to, or the empty string if the attribute is global |
[in] | attname | The attributes name |
status | A negative int is returned on failure. 0 returned on success. |
|
pure virtual |
Copy a variable from another data collection to this data collection at a single time step
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Copy a variable from another data collection to this data collection
This method copies the variable named varname
from the data collection specified by dc to this data collection. The variable must have previously been defined in this data collection.
[in] | dc | A reference to a source data collection |
[in] | varname | Name of variable to copy |
[in] | srclod | The level-of-detail used to open varname in dc . |
[in] | dstlod | The level-of-detail used to open varname in this data collection. |
Implemented in VAPoR::VDCNetCDF.
int VAPoR::VDC::DefineCoordVar | ( | string | varname, |
std::vector< string > | dimnames, | ||
string | time_dim_name, | ||
string | units, | ||
int | axis, | ||
XType | type, | ||
bool | compressed | ||
) |
Define a coordinate variable
This method provides the definition for a coordinate variable: a variable providing spatial or temporal coordinates for a subsequently defined data variable.
If the variable's name, varname
, matches a dimension defined with DefineDimension(), only the units and external data type may differ from the 1D coordinate variable impliclity defined by DefineDimension()
[in] | varname | The name of the coordinate variable. |
[in] | dimnames | An ordered vector specifying the variable's spatial dimension names. The dimension names must have previously been defined with the DefineDimension() method. |
[in] | time_dim_name | The name of the time varying dimension, if any. |
[in] | units | This parameter specifies a string describing the units of measure for the variable. The string is compatible with the Unidata udunits2 conversion package. If the quantity is unitless an empty string may be specified. |
[in] | axis | An integer indicating the spatial or temporal coordinate axis. Acceptable values are 0 (for X or longitude), 1 (for Y or latitude), 2 (for Z or vertical), and 3 (for time). |
[in] | type | The primitive data type storage format. Currently supported values are FLOAT. This is the type that will be used to store the variable on disk |
[in] | compressed | A boolean indicating whether the coordinate variable is to be wavelet transformed. |
It is an error to call this method if the VDC master is not currently in define mode.
status | A negative int is returned on error |
int VAPoR::VDC::DefineCoordVarUniform | ( | string | varname, |
std::vector< string > | dimname, | ||
string | time_dim_name, | ||
string | units, | ||
int | axis, | ||
XType | type, | ||
bool | compressed | ||
) |
Define a coordinate variable with uniform sampling
This method provides the definition for a uniform coordinate variable. A uniformly sampled coordinate variable is a variable for which the coordinates along the fastest varying axis may be given by i * dx , where i is an index starting from zero, and dx is a real number representing the spacing between points.
One-dimensional coordinate variables that have uniform sampling should be declared as such using this method rather than the more general DefineCoordVar().
[in] | varname | The name of the coordinate variable. |
[in] | dimnames | An ordered vector specifying the variable's spatial dimension names. The dimension names must have previously been defined with the DefineDimension() method. |
[in] | time_dim_name | The name of the time varying dimension, if any. |
[in] | units | This parameter specifies a string describing the units of measure for the variable. The string is compatible with the udunits2 conversion package. If the quantity is unitless an empty string may be specified. |
[in] | axis | An integer indicating the spatial or temporal coordinate axis. Acceptable values are 0 (for X or longitude), 1 (for Y or latitude), 2 (for Z or vertical), and 3 (for time). |
[in] | type | The primitive data type storage format. Currently supported values are FLOAT |
[in] | compressed | A boolean indicating whether the coordinate variable is to be wavelet transformed. |
It is an error to call this method if the VDC master is not currently in define mode.
status | A negative int is returned on error |
int VAPoR::VDC::DefineDataVar | ( | string | varname, |
std::vector< string > | dimnames, | ||
std::vector< string > | coordvars, | ||
string | units, | ||
XType | type, | ||
bool | compressed | ||
) |
Define a data variable
This method defines a data variable in the VDC master file
[in] | varname | The name of the data variable. |
[in] | dimnames | An ordered vector specifying the variables dimension names. The dimension names must have previously be defined with the DefineDimension() method. |
[in] | coordvars | An ordered vector specifying the coordinate variable names providing the coordinates for this variable. The coordinate variables must have previously been defined with the DefineCoordVar() method. Moreover, the dimension names of each coordinate variable must be a subset of those in dimnames . |
[in] | units | This parameter specifies a string describing the units of measure for the variable. The string is compatible with the udunits2 conversion package. If the quantity is unitless an empty string may be specified. |
[in] | type | The primitive data type storage format. Currently supported values are FLOAT |
[in] | compressed | A boolean indicating whether the coordinate variable is to be wavelet transformed. |
It is an error to call this method if the VDC master is not currently in define mode.
int VAPoR::VDC::DefineDataVar | ( | string | varname, |
std::vector< string > | dimnames, | ||
std::vector< string > | coordvars, | ||
string | units, | ||
XType | type, | ||
double | missing_value, | ||
string | maskvar | ||
) |
Define a compressed or non-compressed data variable with missing data
[in] | missing_value | Specifies a value that should be used for masked grid locations after a variable is reconstructed. |
[in] | maskvar | Specifies the name of a variable whose contents indicate the presense or absense of invalid entries in the data variable. The contents of the mask array are treated as booleans, true values indicating valid data. The rank of of the variable may be less than or equal to that of varname . The dimensions of maskvar must match the fastest varying dimensions of varname . The maskvar variable must have been previously defined with DefineDataVar(). If maskvar is empty, the variable will not be compressed. |
int VAPoR::VDC::DefineDimension | ( | string | dimname, |
size_t | length | ||
) |
Define a dimension in the VDC
This method specifies the name, and length of a dimension. A variable in the VDC may have one to four dimensions (one to three spatial, and zero or one temporal). Dimensions may be of any length greater than or equal to one.
This method must be called prior to defining any variables requring the defined dimensions.
There are no default dimensions defined.
It is an error to call this method if the VDC master is not currently in define mode.
[in] | dimname | A string specifying the name of the dimension. |
[in] | length | The dimension length, which must be greater than zero. |
status | A negative int is returned on error |
int VAPoR::VDC::DefineDimension | ( | string | dimname, |
size_t | length, | ||
int | axis | ||
) |
Define a dimension in the VDC and an associated coordinate variable
This method defines a dimension and a 1D, unitless coordinate variable with the same name.
It is an error to call this method if the VDC master is not currently in define mode.
[in] | name | A string specifying the name of the dimension, and the coordinate variable. |
[in] | length | The dimension length, which must be greater than zero. |
[in] | axis | An integer indicating the spatial or temporal coordinate axis. Acceptable values are 0 (for X or longitude), 1 (for Y or latitude), 2 (for Z or vertical), and 3 (for time). |
status | A negative int is returned on error |
int VAPoR::VDC::EndDefine | ( | ) |
When the open mode mode is A or W this method signals the class object that metadata defintions have been completed and it commits them to the master VDC file. This method also prepares the VDC for the reading or writing of variable or coordinate data.
Ignored if mode is R.
status | A negative it is returned if the master file is not successfully written for any reason |
|
protectedvirtual |
Implements VAPoR::DC.
|
protectedvirtual |
Implements VAPoR::DC.
|
protectedvirtual |
Implements VAPoR::DC.
|
protectedvirtual |
Return a list of available attribute's names
Returns a vector of all attribute names for the variable, varname
. If varname
is the empty string the names of all of the global attributes are returned. If varname
is not defined an empty vector is returned.
[in] | varname | The name of the variable to query, or the empty string if the names of global attributes are desired. |
attnames | A vector of returned attribute names |
Implements VAPoR::DC.
|
protectedvirtual |
Return the external data type for an attribute
Returns the external storage type of the named variable attribute.
[in] | varname | The name of the variable to query, or the empty string if the names of global attributes are desired. |
[in] | name | Name of the attribute. |
If | an attribute named by name does not exist, a negative value is returned. |
Implements VAPoR::DC.
|
inlineprotectedvirtual |
Return metadata about an auxiliary variable
If the variable varname
is defined as an auxiliary variable its metadata will be returned in var
.
bool | If the named variable cannot be found false is returned and the values of var are undefined. |
Implements VAPoR::DC.
|
inlineprotectedvirtual |
Return a list of names for all of the defined Auxiliary variables.
Returns a list of names for all Auxiliary variables defined
Implements VAPoR::DC.
|
protectedvirtual |
Return metadata about a data or coordinate variable
If the variable varname
is defined as either a data or coordinate variable its metadata will be returned in var
.
bool | If the named variable cannot be found false is returned and the values of var are undefined. |
Implements VAPoR::DC.
|
inlineprotectedvirtual |
void VAPoR::VDC::GetCompressionBlock | ( | std::vector< size_t > & | bs, |
string & | wname, | ||
std::vector< size_t > & | cratios | ||
) | const |
Retrieve current compression block settings.
[out] | bs | An ordered vector containing the current compression block dimensions. |
[out] | wname | The wavelet family name. |
[out] | cratios | A vector of compression of integer compression factors. |
|
protectedvirtual |
Return a coordinate variable's definition
Return a reference to a DC::CoordVar object describing the coordinate variable named by varname
[in] | varname | A string specifying the name of the coordinate variable. |
[out] | coordvar | A CoordVar object containing the definition of the named variable. |
bool | False is returned if the named coordinate variable does not exist, and the contents of cvar will be undefined. |
Implements VAPoR::DC.
|
protectedvirtual |
Return a list of names for all of the defined coordinate variables.
Returns a list of names for all coordinate variables defined
Implements VAPoR::DC.
|
protectedvirtual |
Return a data variable's definition
Return a reference to a DC::DataVar object describing the data variable named by varname
[in] | varname | A string specifying the name of the variable. |
[out] | datavar | A DataVar object containing the definition of the named Data variable. |
bool | If the named data variable cannot be found false is returned and the values of datavar are undefined. |
Implements VAPoR::DC.
|
protectedvirtual |
Return a list of names for all of the defined data variables.
Returns a list of names for all data variables defined
Implements VAPoR::DC.
|
protectedvirtual |
Implements VAPoR::DC.
|
protectedvirtual |
Implements VAPoR::DC.
|
protectedpure virtual |
Return a variable's array dimension lengths at a specified refinement level
Compressed variables may have a multi-resolution grid representation. This method returns the variable's ordered array dimension lengths, and block dimensions at the multiresolution refinement level specified by level
.
If the variable named by varname
is not compressed the variable's native dimensions are returned.
dims_at_level
will match that of bs_at_level
. If the data are not blocked the value of each element of bs_at_level
will be 1.[in] | varname | Data or coordinate variable name. |
[in] | level | Specifies a member of a multi-resolution variable's grid hierarchy as described above. |
[out] | dims_at_level | An ordered vector containing the variable's dimensions at the specified refinement level |
[out] | bs_at_level | An ordered vector containing the variable's block dimensions at the specified refinement level |
status | Zero is returned upon success, otherwise -1. |
Implements VAPoR::DC.
|
protectedvirtual |
Return default Proj4 map projection string.
For georeference data sets that have map projections this method returns the default properly formatted Proj4 projection string for mapping from geographic to cartographic coordinates. If no projection exists, an empty string is returned.
projstring | An empty string if a Proj4 map projection is not available for the named variable, otherwise a properly formatted Proj4 projection string is returned. |
Implements VAPoR::DC.
|
protectedvirtual |
|
inlineprotectedvirtual |
|
protectedvirtual |
Return a Mesh's definition
This method returns the definition of the mesh named by mesh_name
as a reference to a DC::Mesh object.
[in] | mesh_name | A string specifying the name of the Mesh. |
[out] | mesh | The returned Mesh object reference |
bool | If the named mesh can not be found false is returned. |
Implements VAPoR::DC.
|
protectedvirtual |
Implements VAPoR::DC.
|
protectedvirtual |
Implements VAPoR::DC.
|
pure virtual |
Return the path name and temporal offset for a variable
Data and coordinate variables in a VDC are in general distributed into multiple files. For example, for large variables only a single time step may be stored per file. This method returns the file path name, path
, of the file containing varname
at time step ts
. Also returned is the integer time offset of the variable within path
.
[in] | varname | Data or coordinate variable name. |
[in] | ts | Integer offset relative to a variable's temporal dimension |
[out] | path | Path to file containing variable varname at time step ts . |
[out] | file_ts | Temporal offset of variable varname in file path . |
[out] | max_ts | Maximum number of time steps stored in path |
status | A negative int is returned if varname or ts are invalid, or if the class object is in define mode. |
Implemented in VAPoR::VDCNetCDF.
|
inline |
Retrieve current boundary periodic settings
|
inlineprotectedvirtual |
Initialize the DC class
Prepare a DC for reading. This method prepares the master DC file indicated by path
for reading. The method should be called immediately after the constructor, before any other class methods. This method exists only because C++ constructors can not return error codes.
[in] | path | Path name of file that contains, or will contain, the DC master file for this data collection |
[in] | options | A vector of option pairs (name, value) that may be accepted by the derived class. |
status | A negative int is returned on failure |
Implements VAPoR::DC.
Definition at line 230 of file VDC.h.
References initialize().
Referenced by initialize().
|
protectedvirtual |
Initialize the VDC class
Prepare a VDC for reading or writing/appending. This method prepares the master VDC file indicated by path
for reading or writing. The method should be called immediately after the constructor, before any other class methods. This method exists only because C++ constructors can not return error codes.
[in] | path | A single element vector that specifies the name of file that contains, or will contain, the VDC master file for this data collection |
[in] | mode | One of R, W, or A, indicating whether path will be opened for reading, writing, or appending, respectively. When mode is A underlying NetCDF files will be opened opened with nc_open(path, NC_WRITE)). When mode is W NetCDF files will be created (opened with nc_create(path)). When mode is A additional time steps may be added to an existing file. |
bs
is a three-element array, with the first element specifying the length of the fastest varying spatial dimension (e.g. X) of the storage block, the second element specifies the length of the next fastest varying dimension, etc. If a variable definition defines a variable with n spatial , where n is less than three, only the first n elements of bs
will be used. For example, if the rank of bs is greater than two a 2D variable will be stored in blocks having dimensions bs[0] x bs[1]. Time dimensions are never blocked. This parameter is ignored unless mode
is W.
mode
controls the access to the master file indicated by path
and the variable data files in a somewhat unintuitive manner. If mode
is R or A the master file path
must already exist. If mode
is A or W the contents of the VDC master may be changed (written) and the VDC is put into define mode until EndDefine() is called. While in define mode metadata that will be contained in the VDC master file may be changed, but coordinate and data variables may not be accessed (read or written). Similarly, when not in define mode coordinate and data variables may be accessed (read or written), but metadata in the VDC master may not be changed. See OpenVariableRead() and OpenVariableWrite() for discussion on how mode
effects reading and writing of coordinate and data variables.status | A negative int is returned on failure |
|
protectedpure virtual |
Open the named variable for reading
This method prepares a data or coordinate variable, indicated by a variable name and time step pair, for subsequent read operations by methods of this class. The value of the refinement levels parameter, level
, indicates the resolution of the volume in the multiresolution hierarchy as described by GetDimLensAtLevel().
The level-of-detail parameter, lod
, selects the approximation level. Valid values for lod
are integers in the range 0..n-1, where n is returned by DC::BaseVar::GetCRatios().size(), or the value -1 may be used to select the best approximation available.
An error occurs, indicated by a negative return value, if the volume identified by the {varname, timestep, level, lod} tupple is not available. Note the availability of a volume can be tested with the VariableExists() method.
[in] | ts | Time step of the variable to read. This is the integer offset into the variable's temporal dimension. If the variable does not have a temporal dimension ts is ignored. |
[in] | varname | Name of the variable to read |
[in] | level | Refinement level of the variable. Ignored if the variable is not compressed. |
[in] | lod | Approximation level of the variable. A value of -1 indicates the maximum approximation level defined for the DC. Ignored if the variable is not compressed. |
status | Returns a non-negative file descriptor on success |
Implements VAPoR::DC.
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Open the named variable for writing
This method prepares a data or coordinate variable, indicated by a variable name and time step pair, for subsequent write operations by methods of this class.
The behavior of this method is impacted somewhat by the setting of the Initialize() mode parameter. Coordinate or data variable files may be written regardless of the mode
setting. However, if mode
is W the first time a coordinate or data file is written it will be created (opened with nc_create(path), for example) regareless of whether the file previously existed. If mode
is A or R existing coordinate or data files will be opened for appending (e.g. opened with nc_open(path, NC_WRITE)). New files will be created (opened with nc_create(path)).
An error occurs, indicated by a negative return value, if the varible identified by the {varname, timestep, lod} tupple is not defined.
[in] | ts | Time step of the variable to read. This is the integer offset into the variable's temporal dimension. If the variable does not have a temporal dimension ts is ignored. |
[in] | varname | Name of the variable to read |
[in] | lod | Approximation level of the variable. A value of -1 indicates the maximum approximation level defined for the VDC. Ignored if the variable is not compressed. |
status | Returns a non-negative value on success |
Implemented in VAPoR::VDCNetCDF.
int VAPoR::VDC::PutAtt | ( | string | varname, |
string | attname, | ||
XType | type, | ||
const string & | values | ||
) |
int VAPoR::VDC::PutAtt | ( | string | varname, |
string | attname, | ||
XType | type, | ||
const vector< double > & | values | ||
) |
Write an attribute
This method write an attribute to the VDC. The attribute can either be "global", if varname
is the empty string, or bound to a variable if varname
indentifies a variable in the VDC.
[in] | varname | The name of a variable already defined in the VDC, or the empty string if the attribute is to be global |
[in] | attname | The attributes name |
[in] | type | The primitive data type storage format. This is the type that will be used to store the attribute on disk |
[in] | values | A vector of floating point attribute values |
status | A negative int is returned on failure |
int VAPoR::VDC::PutAtt | ( | string | varname, |
string | attname, | ||
XType | type, | ||
const vector< long > & | values | ||
) |
|
pure virtual |
Write a variable at single time step
This method writes a variable hyperslab consisting of the variable's entire spatial dimensions at the time step indicated by ts
. Any variables currently opened with OpenVariableWrite() are first closed. Thus variables need not be opened with OpenVariableWrite() prior to calling PutVar();
It is an error to call this method in define mode
[in] | ts | Time step of the variable to write. This is the integer offset into the variable's temporal dimension. If the variable does not have a temporal dimension ts is ignored. |
[in] | varname | Name of the variable to write |
[in] | lod | Approximation level of the variable. A value of -1 indicates the maximum approximation level defined for the VDC. Ignored if the variable is not compressed. |
[in] | data | Pointer from where the data will be copied |
status | A negative int is returned on failure |
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Write an entire variable in one call
This method writes and entire variable (all time steps, all grid points) into a VDC. This is the simplest interface for writing data into a VDC. If the variable is split across multiple files PutVar() ensures that the data are correctly distributed. Any variables currently opened with OpenVariableWrite() are first closed. Thus variables need not be opened with OpenVariableWrite() prior to calling PutVar();
It is an error to call this method in define mode
[in] | varname | Name of the variable to write |
[in] | lod | Approximation level of the variable. A value of -1 indicates the maximum approximation level defined for the VDC. Ignored if the variable is not compressed. |
[in] | data | Pointer from where the data will be copied |
status | A negative int is returned on failure |
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Implemented in VAPoR::VDCNetCDF.
|
protectedpure virtual |
Implements VAPoR::DC.
|
protectedpure virtual |
Read in and return a subregion from the currently opened variable
This method reads and returns a subset of variable data. The min
and max
vectors, whose dimensions must match the spatial rank of the currently opened variable, identify the minimum and maximum extents, in grid coordinates, of the subregion of interest. The minimum and maximum valid values of an element of min or max are 0 and n-1, respectively, where n is the length of the associated dimension at the opened refinement level.
The region returned is stored in the memory region pointed to by region
. It is the caller's responsbility to ensure adequate space is available.
[in] | fd | A valid file descriptor returned by OpenVariableRead() |
[in] | min | Minimum region extents in grid coordinates |
[in] | max | Maximum region extents in grid coordinates |
[out] | region | The requested volume subregion |
status | Returns a non-negative value on success |
Implements VAPoR::DC.
int VAPoR::VDC::SetCompressionBlock | ( | string | wname, |
std::vector< size_t > | cratios | ||
) |
Sets various parameters for storage blocks for subsequent variable definitions
This method sets the storage parameters for subsequent variable definitions for compressed variables.
Variables whose spatial dimension lengths are less than the coresponding dimension of bs
will be padded to block boundaries.
wname
set the wavelet family name and boundary handling mode for subsequent compressed variable definitions. Wider wavelets (those requiring more filter coefficients) will typically yield higher compression rates, but are more computationally expensive and will limit the depth of of the grid resolution refinement hierarchy.
Recommended values for wname
are bior1.1, bior1.3, bior1.5 bior3.3, bior3.5, bior3.7, bior3.9, bior2.2, bior2.6, bior2.6, and bior2.8. For odd length filters (e.g. bior1.3)
Finally, cratios
specifies a vector of compression factors for subsequent compressed variable definitions.
[in] | wname | A wavelet family name. The default value is "bior4.4". |
[in] | cratios | A vector of compression of integer compression factors. The default compression ratio vector is: (1, 10, 100, 500) |
status | A negative int is returned if an invalid parameter or parameter combination is specified. |
|
virtual |
Set the default Proj4 map projection for georeferenced variables
This method sets the default Proj4 map projection string to be used for georeferenced variables. The string set by projstring
is returned by VDC::GetMapProjection()
|
virtual |
Set a map projection string for a data variable
This method sets a properly formatted Proj4 map projection string for the data variable indicated by varname
|
inline |
Set the boundary periodic for subsequent variable definitions
This method specifies an ordered, three-element boolean vector indicating the boundary periodicty for a variable's spatial dimensions. The ordering is from fastest to slowest varying dimension.
[in] | periodic | A three-element array of booleans. The default value of periodic is (false, false, false). |
status | A negative int is returned on error |
|
pure virtual |
Returns true if indicated data volume is available
Returns true if the variable identified by the timestep, variable name, refinement level, and level-of-detail is present in the data set. Returns false if the variable is not available.
[in] | ts | A valid time step between 0 and GetNumTimesteps()-1 |
[in] | varname | A valid variable name |
[in] | reflevel | Refinement level requested. |
[in] | lod | Compression level of detail requested. refinement level contained in the VDC. |
Implements VAPoR::DC.
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Write all spatial values to the currently opened variable
This method writes, and compresses as necessary, the contents of the array contained in data
to the currently opened variable. The number of values written from data
is given by the product of the spatial dimensions of the open variable.
[in] | data | An array of data to be written |
status | Returns a non-negative value on success |
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Write a single slice of data to the currently opened variable
Compress, and necessary, and write a single slice (2D array) of data to the variable indicated by the most recent call to OpenVariableWrite(). The dimensions of a slices are NX by NY, where NX is the dimension of the array along the fastest varying spatial dimension, specified in grid points, and NY is the length of the second fastest varying dimension at the currently opened refinement level. See OpenVariableWrite().
This method should be called exactly NZ times for each opened variable, where NZ is the dimension of third, and slowest varying dimension. In the case of a 2D variable, NZ is 1.
[in] | slice | A 2D slice of data |
status | Returns a non-negative value on success |
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Implemented in VAPoR::VDCNetCDF.
|
pure virtual |
Implemented in VAPoR::VDCNetCDF.
|
friend |
|
protected |
|
protected |