VAPoR
3.0.0
|
Class for reading a WRF data set stored as a series of NetCDF files. More...
#include <DCWRF.h>
Public Member Functions | |
DCWRF () | |
virtual | ~DCWRF () |
virtual int | Initialize (const vector< string > &paths) |
virtual bool | GetDimension (string dimname, DC::Dimension &dimension) const |
virtual std::vector< string > | GetDimensionNames () const |
virtual bool | GetCoordVarInfo (string varname, DC::CoordVar &cvar) const |
virtual bool | GetDataVarInfo (string varname, DC::DataVar &datavar) const |
virtual bool | GetBaseVarInfo (string varname, DC::BaseVar &var) const |
virtual std::vector< string > | GetDataVarNames () const |
virtual std::vector< string > | GetCoordVarNames () const |
virtual int | GetNumRefLevels (string varname) const |
virtual int | GetMapProjection (string lonname, string latname, string &projstring) const |
virtual int | GetAtt (string varname, string attname, vector< double > &values) const |
virtual int | GetAtt (string varname, string attname, vector< long > &values) const |
virtual int | 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) const |
virtual int | OpenVariableRead (size_t ts, string varname, int, int) |
virtual int | OpenVariableRead (size_t ts, string varname) |
virtual int | CloseVariable () |
virtual int | Read (float *data) |
virtual int | ReadSlice (float *slice) |
virtual int | ReadRegion (const vector< size_t > &min, const vector< size_t > &max, float *region) |
virtual int | ReadRegionBlock (const vector< size_t > &min, const vector< size_t > &max, float *region) |
virtual int | GetVar (string varname, int, int, float *data) |
virtual int | GetVar (string varname, float *data) |
virtual int | GetVar (size_t ts, string varname, int, int, float *data) |
virtual int | GetVar (size_t ts, string varname, float *data) |
virtual bool | VariableExists (size_t ts, string varname, int reflevel=0, int lod=0) const |
Public Member Functions inherited from VAPoR::DC | |
DC () | |
virtual | ~DC () |
virtual bool | GetDimension (string dimname, size_t &length, int &axis) const |
virtual std::vector< string > | GetDataVarNames (int ndim, bool spatial) const |
virtual std::vector< string > | GetCoordVarNames (int ndim, bool spatial) const |
virtual bool | IsTimeVarying (string varname) const |
virtual bool | IsCompressed (string varname) const |
virtual int | GetNumTimeSteps (string varname) const |
virtual int | GetCRatios (string varname, vector< size_t > &cratios) const |
virtual bool | IsDataVar (string varname) const |
virtual bool | IsCoordVar (string varname) const |
virtual int | GetMapProjection (string varname, string &projstring) const |
Public Member Functions inherited from VetsUtil::MyBase | |
MyBase () | |
const string & | getClassName () const |
Additional Inherited Members | |
Public Types inherited from VAPoR::DC | |
enum | XType { INVALID = -1, FLOAT, DOUBLE, INT32, INT64, TEXT } |
External storage types for primitive data. More... | |
Public Types inherited from VetsUtil::MyBase | |
typedef void(* | ErrMsgCB_T) (const char *msg, int err_code) |
typedef void(* | DiagMsgCB_T) (const char *msg) |
Static Public Member Functions inherited from VAPoR::DC | |
static bool | ParseDimensions (const vector< DC::Dimension > &dimensions, vector< size_t > &sdims, size_t &numts) |
Static Public Member Functions inherited from VetsUtil::MyBase | |
static void | SetErrMsg (const char *format,...) |
Record a formatted error message. More... | |
static void | SetErrMsg (int errcode, const char *format,...) |
Record a formatted error message and an error code. More... | |
static const char * | GetErrMsg () |
static void | SetErrCode (int err_code) |
Record an error code. More... | |
static int | GetErrCode () |
Retrieve the current error code. More... | |
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. More... | |
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 Public Attributes inherited from VetsUtil::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 |
Protected Member Functions inherited from VetsUtil::MyBase | |
void | SetClassName (const string &name) |
Class for reading a WRF data set stored as a series of NetCDF files.
VAPoR::DCWRF::DCWRF | ( | ) |
Class constuctor
|
virtual |
|
virtual |
Close the currently opened variable
Close the handle for variable opened with OpenVariableRead()
Implements VAPoR::DC.
|
virtual |
Read an attribute
This method reads an attribute from the 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 DC.
[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 |
[out] | type | The primitive data type storage format. This is the type that will be used to store the attribute on disk |
[out] | values | A vector to contain the returned floating point attribute values |
status | A negative int is returned on failure |
Implements VAPoR::DC.
|
virtual |
Implements VAPoR::DC.
|
virtual |
Implements VAPoR::DC.
|
virtual |
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.
|
virtual |
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.
|
virtual |
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.
|
virtual |
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.
|
virtual |
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.
|
virtual |
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.
|
virtual |
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.
|
virtual |
Return a dimensions's definition
This method returns the definition of the dimension named by dimname
as a reference to a DC::Dimension object. If dimname
is not defined as a dimension then the name of dimension
will be the empty string()
[in] | dimname | A string specifying the name of the dimension. |
[out] | dimension | The returned Dimension object reference |
bool | If the named dimension can not be found false is returned. |
Implements VAPoR::DC.
|
virtual |
|
virtual |
Return a variable's dimension lengths at a specified refinement level
Compressed variables have a multi-resolution grid representation. This method returns the variable's ordered spatial and temporal 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.
[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.
|
virtual |
Return a Proj4 map projection string.
For georeference data sets that have map projections this method returns a properly formatted Proj4 projection string for mapping from geographic to cartographic coordinates. If no such projection exists an empty string is returned.
[in] | lonname | Name of longitude coordinate variable |
[in] | latname | Name of latitude coordinate variable |
[out] | projstring | An empty string if a Proj4 map projection is not available for the named coordinate pair, otherwise a properly formatted Proj4 projection string is returned. |
Implements VAPoR::DC.
|
inlinevirtual |
|
inlinevirtual |
Read an entire variable in one call
This method reads and entire variable (all time steps, all grid points) from a DC. This is the simplest interface for reading data from a DC. If the variable is split across multiple files GetVar() ensures that the data are correctly gathered and assembled into memory Any variables currently opened with OpenVariableRead() are first closed. Thus variables need not be opened with OpenVariableRead() prior to calling GetVar();
It is an error to call this method in define mode
[in] | varname | Name of the variable to write |
[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. |
[out] | data | Pointer to where data will be copied. It is the caller's responsbility to ensure data points to sufficient memory. |
status | A negative int is returned on failure |
Implements VAPoR::DC.
Definition at line 166 of file DCWRF.h.
Referenced by GetVar().
|
virtual |
|
inlinevirtual |
Read an entire variable in one call
This method reads and entire variable (all time steps, all grid points) from a DC. This is the simplest interface for reading data from a DC. If the variable is split across multiple files GetVar() ensures that the data are correctly gathered and assembled into memory Any variables currently opened with OpenVariableRead() are first closed. Thus variables need not be opened with OpenVariableRead() prior to calling GetVar();
It is an error to call this method in define mode
[in] | varname | Name of the variable to write |
[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. |
[out] | data | Pointer to where data will be copied. It is the caller's responsbility to ensure data points to sufficient memory. |
status | A negative int is returned on failure |
Implements VAPoR::DC.
Definition at line 173 of file DCWRF.h.
References GetVar().
|
virtual |
|
virtual |
Initialize the DCWRF class
Prepare a WRF data set for reading. This method prepares the DCWRF class for reading the files indicated by paths
. 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 list of WRF NetCDF files comprising the output of a single WRF model run. |
status | A negative int is returned on failure |
Implements VAPoR::DC.
|
inlinevirtual |
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 value on success |
Implements VAPoR::DC.
|
virtual |
|
virtual |
Read all spatial values of the currently opened variable
This method reads, and decompresses as necessary, the contents of the currently opened variable into the array data
. The number of values read into data
is given by the product of the spatial dimensions of the open variable at the refinement level specified.
It is the caller's responsibility to ensure data
points to adequate space.
[out] | data | An array of data to be written |
status | Returns a non-negative value on success |
Implements VAPoR::DC.
|
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] | 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.
|
virtual |
Read in and return a blocked subregion from the currently opened variable.
This method is identical to ReadRegion() with the exceptions that for compressed variables:
start
and count
must be aligned with the underlying storage block of the variable. See DC::SetCompressionBlock()region
will preserve its underlying storage blocking (the data will not be contiguous) Implements VAPoR::DC.
|
virtual |
Read a single slice of data from the currently opened variable
Decompress, as necessary, and read a single slice (2D array) of data from the variable indicated by the most recent call to OpenVariableRead(). 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 grid refinement level. See OpenVariableRead().
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.
It is the caller's responsibility to ensure slice
points to adequate space.
[out] | slice | A 2D slice of data |
status | Returns a non-negative value on success |
Implements VAPoR::DC.
|
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 DC. |
Implements VAPoR::DC.