VAPoR  3.0.0
Classes | Public Member Functions | List of all members
VAPoR::DCWRF Class Reference

Class for reading a WRF data set stored as a series of NetCDF files. More...

#include <DCWRF.h>

Inheritance diagram for VAPoR::DCWRF:
VAPoR::DC VetsUtil::MyBase

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)
 

Detailed Description

Class for reading a WRF data set stored as a series of NetCDF files.

Author
John Clyne
Date
January, 2015

Definition at line 27 of file DCWRF.h.

Constructor & Destructor Documentation

VAPoR::DCWRF::DCWRF ( )

Class constuctor

virtual VAPoR::DCWRF::~DCWRF ( )
virtual

Member Function Documentation

virtual int VAPoR::DCWRF::CloseVariable ( )
virtual

Close the currently opened variable

Close the handle for variable opened with OpenVariableRead()

See also
OpenVariableRead()

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::GetAtt ( string  varname,
string  attname,
vector< double > &  values 
) const
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.

Parameters
[in]varnameThe name of the variable the attribute is bound to, or the empty string if the attribute is global
[in]attnameThe attributes name
[out]typeThe primitive data type storage format. This is the type that will be used to store the attribute on disk
[out]valuesA vector to contain the returned floating point attribute values
Return values
statusA negative int is returned on failure

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::GetAtt ( string  varname,
string  attname,
vector< long > &  values 
) const
virtual

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::GetAtt ( string  varname,
string  attname,
string &  values 
) const
virtual

Implements VAPoR::DC.

virtual std::vector<string> VAPoR::DCWRF::GetAttNames ( string  varname) const
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.

Parameters
[in]varnameThe name of the variable to query, or the empty string if the names of global attributes are desired.
Return values
attnamesA vector of returned attribute names
See also
GetAtt()

Implements VAPoR::DC.

virtual XType VAPoR::DCWRF::GetAttType ( string  varname,
string  attname 
) const
virtual

Return the external data type for an attribute

Returns the external storage type of the named variable attribute.

Parameters
[in]varnameThe name of the variable to query, or the empty string if the names of global attributes are desired.
[in]nameName of the attribute.
Return values
Ifan attribute named by name does not exist, a negative value is returned.

Implements VAPoR::DC.

virtual bool VAPoR::DCWRF::GetBaseVarInfo ( string  varname,
DC::BaseVar var 
) const
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.

Return values
boolIf the named variable cannot be found false is returned and the values of var are undefined.
See also
GetDataVarInfo(), GetCoordVarInfo()

Implements VAPoR::DC.

virtual bool VAPoR::DCWRF::GetCoordVarInfo ( string  varname,
DC::CoordVar cvar 
) const
virtual

Return a coordinate variable's definition

Return a reference to a DC::CoordVar object describing the coordinate variable named by varname

Parameters
[in]varnameA string specifying the name of the coordinate variable.
[out]coordvarA CoordVar object containing the definition of the named variable.
Return values
boolFalse is returned if the named coordinate variable does not exist, and the contents of cvar will be undefined.

Implements VAPoR::DC.

virtual std::vector<string> VAPoR::DCWRF::GetCoordVarNames ( ) const
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 bool VAPoR::DCWRF::GetDataVarInfo ( string  varname,
DC::DataVar datavar 
) const
virtual

Return a data variable's definition

Return a reference to a DC::DataVar object describing the data variable named by varname

Parameters
[in]varnameA string specifying the name of the variable.
[out]datavarA DataVar object containing the definition of the named Data variable.
Return values
boolIf the named data variable cannot be found false is returned and the values of datavar are undefined.

Implements VAPoR::DC.

virtual std::vector<string> VAPoR::DCWRF::GetDataVarNames ( ) const
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 bool VAPoR::DCWRF::GetDimension ( string  dimname,
DC::Dimension dimension 
) const
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()

Parameters
[in]dimnameA string specifying the name of the dimension.
[out]dimensionThe returned Dimension object reference
Return values
boolIf the named dimension can not be found false is returned.

Implements VAPoR::DC.

virtual std::vector<string> VAPoR::DCWRF::GetDimensionNames ( ) const
virtual

Return names of all defined dimensions

This method returns the list of names of all of the dimensions defined in the DC.

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::GetDimLensAtLevel ( string  varname,
int  level,
std::vector< size_t > &  dims_at_level,
std::vector< size_t > &  bs_at_level 
) const
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.

Parameters
[in]varnameData or coordinate variable name.
[in]levelSpecifies a member of a multi-resolution variable's grid hierarchy as described above.
[out]dims_at_levelAn ordered vector containing the variable's dimensions at the specified refinement level
[out]bs_at_levelAn ordered vector containing the variable's block dimensions at the specified refinement level
Return values
statusZero is returned upon success, otherwise -1.
See also
VAPoR::DC, DC::BaseVar::GetBS(), DC::BaseVar::GetDimensions()

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::GetMapProjection ( string  lonname,
string  latname,
string &  projstring 
) const
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.

Parameters
[in]lonnameName of longitude coordinate variable
[in]latnameName of latitude coordinate variable
[out]projstringAn 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.

virtual int VAPoR::DCWRF::GetNumRefLevels ( string  varname) const
inlinevirtual

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.

Definition at line 90 of file DCWRF.h.

virtual int VAPoR::DCWRF::GetVar ( string  varname,
int  ,
int  ,
float *  data 
)
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

Parameters
[in]varnameName of the variable to write
[in]levelRefinement level of the variable. Ignored if the variable is not compressed.
[in]lodApproximation 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]dataPointer to where data will be copied. It is the caller's responsbility to ensure data points to sufficient memory.
Return values
statusA negative int is returned on failure

Implements VAPoR::DC.

Definition at line 166 of file DCWRF.h.

Referenced by GetVar().

virtual int VAPoR::DCWRF::GetVar ( string  varname,
float *  data 
)
virtual
virtual int VAPoR::DCWRF::GetVar ( size_t  ts,
string  varname,
int  ,
int  ,
float *  data 
)
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

Parameters
[in]varnameName of the variable to write
[in]levelRefinement level of the variable. Ignored if the variable is not compressed.
[in]lodApproximation 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]dataPointer to where data will be copied. It is the caller's responsbility to ensure data points to sufficient memory.
Return values
statusA negative int is returned on failure

Implements VAPoR::DC.

Definition at line 173 of file DCWRF.h.

References GetVar().

virtual int VAPoR::DCWRF::GetVar ( size_t  ts,
string  varname,
float *  data 
)
virtual
virtual int VAPoR::DCWRF::Initialize ( const vector< string > &  paths)
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.

Parameters
[in]pathA list of WRF NetCDF files comprising the output of a single WRF model run.
Return values
statusA negative int is returned on failure
See also
EndDefine();

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::OpenVariableRead ( size_t  ts,
string  varname,
int  ,
int   
)
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.

Parameters
[in]tsTime 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]varnameName of the variable to read
[in]levelRefinement level of the variable. Ignored if the variable is not compressed.
[in]lodApproximation level of the variable. A value of -1 indicates the maximum approximation level defined for the DC. Ignored if the variable is not compressed.
Return values
statusReturns a non-negative value on success
See also
GetNumRefLevels(), DC::BaseVar::GetCRatios(), OpenVariableRead()

Implements VAPoR::DC.

Definition at line 129 of file DCWRF.h.

virtual int VAPoR::DCWRF::OpenVariableRead ( size_t  ts,
string  varname 
)
virtual
virtual int VAPoR::DCWRF::Read ( float *  data)
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.

Parameters
[out]dataAn array of data to be written
Return values
statusReturns a non-negative value on success
See also
OpenVariableRead()

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::ReadRegion ( const vector< size_t > &  min,
const vector< size_t > &  max,
float *  region 
)
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.

Parameters
[in]minMinimum region extents in grid coordinates
[in]maxMaximum region extents in grid coordinates
[out]regionThe requested volume subregion
Return values
statusReturns a non-negative value on success
See also
OpenVariableRead(), GetDimension(), GetDimensionNames()

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::ReadRegionBlock ( const vector< size_t > &  min,
const vector< size_t > &  max,
float *  region 
)
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:

  • The vectors start and count must be aligned with the underlying storage block of the variable. See DC::SetCompressionBlock()
  • The hyperslab copied to region will preserve its underlying storage blocking (the data will not be contiguous)

Implements VAPoR::DC.

virtual int VAPoR::DCWRF::ReadSlice ( float *  slice)
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.

Parameters
[out]sliceA 2D slice of data
Return values
statusReturns a non-negative value on success
See also
OpenVariableRead()

Implements VAPoR::DC.

virtual bool VAPoR::DCWRF::VariableExists ( size_t  ts,
string  varname,
int  reflevel = 0,
int  lod = 0 
) const
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.

Parameters
[in]tsA valid time step between 0 and GetNumTimesteps()-1
[in]varnameA valid variable name
[in]reflevelRefinement level requested.
[in]lodCompression level of detail requested. refinement level contained in the DC.

Implements VAPoR::DC.


The documentation for this class was generated from the following file: