VAPoR
0.1
|
Wrapper for a collection of netCDF files. More...
#include <NetCDFCFCollection.h>
Public Member Functions | |
NetCDFCFCollection () | |
virtual | ~NetCDFCFCollection () |
virtual int | Initialize (const std::vector< string > &files) |
virtual bool | IsCoordVarCF (string var) const |
virtual bool | IsAuxCoordVarCF (string var) const |
virtual bool | IsLatCoordVar (string var) const |
virtual bool | IsLonCoordVar (string var) const |
virtual bool | IsTimeCoordVar (string var) const |
virtual bool | IsVertCoordVar (string var) const |
virtual bool | IsVertCoordVarUp (string var) const |
virtual std::vector< string > | GetLatCoordVars () const |
virtual std::vector< string > | GetLonCoordVars () const |
virtual std::vector< string > | GetTimeCoordVars () const |
virtual std::vector< string > | GetVertCoordVars () const |
virtual std::vector< string > | GetDataVariableNames (int ndim, bool spatial) const |
virtual int | GetVarCoordVarNames (string var, std::vector< string > &cvars) const |
virtual int | GetVarUnits (string var, string &units) const |
const UDUnits * | GetUDUnits () const |
virtual int | Convert (const string from, const string to, const double *src, double *dst, size_t n) const |
virtual bool | GetMissingValue (string varname, double &mv) const |
virtual int | OpenRead (size_t ts, string varname) |
virtual bool | IsVertDimensionless (string cvar) const |
virtual int | InstallStandardVerticalConverter (string cvar, string newvar, string units="meters") |
virtual void | UninstallStandardVerticalConverter (string cvar) |
bool | GetMapProjectionProj4 (string varname, string &proj4string) const |
void | FormatTimeStr (double time, string &str) const |
Public Member Functions inherited from VAPoR::NetCDFCollection | |
NetCDFCollection () | |
virtual | ~NetCDFCollection () |
virtual int | Initialize (const std::vector< string > &files, const std::vector< string > &time_dimnames, const std::vector< string > &time_coordvar) |
virtual bool | VariableExists (string varname) const |
virtual bool | VariableExists (size_t ts, string varname) const |
virtual bool | IsDerivedVar (string varname) const |
virtual bool | IsStaggeredVar (string varname) const |
virtual bool | IsStaggeredDim (string dimname) const |
virtual std::vector< string > | GetVariableNames (int ndim, bool spatial) const |
virtual std::vector< size_t > | GetSpatialDims (string varname) const |
virtual std::vector< string > | GetSpatialDimNames (string varname) const |
virtual size_t | GetTimeDim (string varname) const |
virtual string | GetTimeDimName (string varname) const |
virtual std::vector< size_t > | GetDims (string varname) const |
virtual std::vector< string > | GetDimNames (string varname) const |
virtual bool | IsTimeVarying (string varname) const |
std::vector< string > | GetAttNames (string varname) const |
int | GetAttType (string varname, string attname) const |
void | GetAtt (string varname, string attname, std::vector< double > &values) const |
void | GetAtt (string varname, string attname, std::vector< long > &values) const |
void | GetAtt (string varname, string attname, string &values) const |
virtual std::vector< string > | GetDimNames () const |
virtual std::vector< size_t > | GetDims () const |
virtual size_t | GetNumTimeSteps () const |
virtual size_t | GetNumTimeSteps (string varname) const |
virtual int | GetTime (size_t ts, double &time) const |
virtual int | GetTimes (string varname, std::vector< double > ×) const |
virtual std::vector< double > | GetTimes () const |
virtual int | GetFile (size_t ts, string varname, string &file, size_t &local_ts) const |
virtual int | GetVariableInfo (string varname, NetCDFSimple::Variable &varinfo) const |
virtual int | Read (size_t start[], size_t count[], float *data, int fd=0) |
virtual int | Read (size_t start[], size_t count[], int *data, int fd=0) |
virtual int | Read (float *data, int fd=0) |
virtual int | Read (char *data, int fd=0) |
virtual int | ReadNative (size_t start[], size_t count[], float *data, int fd=0) |
virtual int | ReadNative (size_t start[], size_t count[], int *data, int fd=0) |
virtual int | ReadNative (size_t start[], size_t count[], char *data, int fd=0) |
virtual int | ReadNative (float *data, int fd=0) |
virtual int | ReadNative (int *data, int fd=0) |
virtual int | ReadSlice (float *data, int fd=0) |
virtual int | ReadSliceNative (float *data, int fd=0) |
virtual int | SeekSlice (int offset, int whence, int fd=0) |
virtual int | Close (int fd=0) |
virtual void | SetStaggeredDims (const std::vector< string > dimnames) |
virtual void | SetMissingValueAttName (string attname) |
virtual std::vector< string > | GetFailedVars () const |
void | InstallDerivedVar (string varname, DerivedVar *derivedVar) |
void | RemoveDerivedVar (string varname) |
Public Member Functions inherited from VetsUtil::MyBase | |
MyBase () | |
const string & | getClassName () const |
Friends | |
std::ostream & | operator<< (std::ostream &o, const NetCDFCFCollection &ncdfc) |
Additional Inherited Members | |
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 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 VAPoR::NetCDFCollection | |
bool | _GetVariableInfo (string varname, NetCDFSimple::Variable &variable) const |
Protected Member Functions inherited from VetsUtil::MyBase | |
void | SetClassName (const string &name) |
Wrapper for a collection of netCDF files.
This class provides access to CF-1 compliant collection of netCDF files. This work is based on the "NetCDF Climate and Forecast (CF) Metadata Conventions", version 1.6, 5, December 2011.
Definition at line 35 of file NetCDFCFCollection.h.
VAPoR::NetCDFCFCollection::NetCDFCFCollection | ( | ) |
|
virtual |
|
virtual |
Convert an array of floating point values from one unit to another
This method uses the UDUnits class to convert an array of floating point values from one unit measure to another as supported by Unidata's udunits2 library. See from A string containing the unit to convert from (e.g. "meters") to A string containing the unit to convert to (e.g. "feet") src An array of input values to be converted dst An output buffer large enough to contained the converted data n The number of elements in src
status a non-negative int is returned on success
void VAPoR::NetCDFCFCollection::FormatTimeStr | ( | double | time, |
string & | str | ||
) | const |
|
virtual |
Return a list of data variables with a given rank
Returns a list of data variables having a dimension rank of ndim
. If spatial
is true only the data variable's spatial dimension rank is examined. Thus if spatial
is true, and the named variable is explicitly time varying, the time-varying dimension is not counted. For example, if a variable named 'v' is defined with 4 dimensions in the netCDF file, and the slowest varying dimension name matches a named dimension specified in Initialize() by time_dimnames
, then the variable 'v' would be returned by a query with ndim==3 and spatial==true.
Names of variables that are coordinate or auxiliary coordinate variables are not returned, nor are variables that are missing coordinate variables.
[in] | ndim | Rank of spatial dimensions |
[in] | spatial | Only compare spatial dimensions against ndim |
|
inlinevirtual |
Return a vector of all latitude coordinate variables
Definition at line 161 of file NetCDFCFCollection.h.
|
inlinevirtual |
Return a vector of all longitude coordinate variables
Definition at line 165 of file NetCDFCFCollection.h.
bool VAPoR::NetCDFCFCollection::GetMapProjectionProj4 | ( | string | varname, |
string & | proj4string | ||
) | const |
Get a map projection as a proj4 string
If a variable has a map projection generate a proj4 transformation string for converting from geographic to Cartographic coordinates. Returns false if no proj4 string could be generated: either no map projection exists, or one exists but is not supported.
|
virtual |
Return the missing value, if any, for a variable
This method returns the value of the missing data value marker, if defined, for the variable named by varname
.
Missing data values are indicated using the _FillValue
, or missing_value
attributes as defined in section 2.5.1 of the CF 1.6 spec.
[in] | varname | The variable name |
[out] | mv | The missing value for the variabled name by varname |
bool | The boolean true is returned if a missing value is defined. If no missing variable is defined the return value is false and the value of mv is not defined. |
Reimplemented from VAPoR::NetCDFCollection.
|
inlinevirtual |
Return a vector of all time coordinate variables
Definition at line 169 of file NetCDFCFCollection.h.
|
inline |
Return a pointer to the internal UDUnits object used to perform unit conversion.
Definition at line 254 of file NetCDFCFCollection.h.
|
virtual |
Return ordered list of coordinate or auxliary coordinate variables for the named variable.
This method returns in cvars
an ordered list of all of the spatio-temporal coordinate or auxliary coordinate variables associated with the variable named by var
. See Chapter 5 of the CF 1.X spec. for more detail, summarized here:
CF1.X Chap. 5 excerpt :
"The use of coordinate variables is required whenever they are applicable. That is, auxiliary coordinate variables may not be used as the only way to identify latitude and longitude coordinates that could be identified using coordinate variables. This is both to enhance conformance to COARDS and to facilitate the use of generic applications that recognize the NUG convention for coordinate variables. An application that is trying to find the latitude coordinate of a variable should always look first to see if any of the variable's dimensions correspond to a latitude coordinate variable. If the latitude coordinate is not found this way, then the auxiliary coordinate variables listed by the coordinates attribute should be checked. Note that it is permissible, but optional, to list coordinate variables as well as auxiliary coordinate variables in the coordinates attribute."
[in] | varname | A variable name |
[out] | cvars | A unodered vector of coordinate variable names |
status | a negative int is returned if the number of elements in cvars does not match the number of spatio-temporal dimensions of the variable named by var |
|
virtual |
Return the value of the 'units' attribute for the named variable
This method fetches the value of the 'units' attribute, if present, for the variable named by var
. If a units attribute is not present then units
will contain an empty string.
[in] | varname | A variable name |
[out] | units | The value of the variable's 'units' attribute. If the 'units' attribute is not present the parameter will contain the empty string. |
status | a non-negative int is returned on success |
|
inlinevirtual |
Return a vector of all vertical coordinate variables
Definition at line 173 of file NetCDFCFCollection.h.
|
virtual |
|
virtual |
This method defines a converter from dimensionless vertical coordinates to dimensioned vertical coordinates
This method can be used to create a derived variable containing dimensioned vertical coordinates from a native variable containing dimensionless vertical coordinates. Once defined, the derived variable can be operated on like any other native variable contained in the data collection using methods such as OpenRead(), and ReadSlice(). The dimensionless vertical coordinate variable must contain a standard_name
attribute containing a supported dimensionless coordinate. Currently supported standard names are:
[in] | cvar | A dimensionless variable with a standard_name attribute |
[in] | newvar | The name of the new derived variable |
[in] | units | The length units of the new variable |
status | a non-negative int is returned on success |
|
inlinevirtual |
Return boolean indicating whether the named variable is a CF auxiliary coordinate variable
This method returns true if the variable named by var
is a "auxiliary coordinate variable"
CF1.X Definition of auxiliary coordinate variable :
Any netCDF variable that contains coordinate data, but is not a coordinate variable (in the sense of that term defined by the NUG and used by this standard - see below). Unlike coordinate variables, there is no relationship between the name of an auxiliary coordinate variable and the name(s) of its dimension(s).
true | if var is an auxliary coordinate variable, false otherwise |
Definition at line 81 of file NetCDFCFCollection.h.
|
inlinevirtual |
Return boolean indicating whether variable is a CF coordinate variable
This method returns true if the variable named by var
is a "coordinate variable"
CF1.X Definition of coordinate variable :
"We use this term precisely as it is defined in section 2.3.1 of the NUG. It is a one- dimensional variable with the same name as its dimension [e.g., time(time)], and it is defined as a numeric data type with values that are ordered monotonically. Missing values are not allowed in coordinate variables."
true | if var is a coordinate variable, false otherwise |
Definition at line 61 of file NetCDFCFCollection.h.
|
inlinevirtual |
Return boolean indicating whether the named variable represents latitude.
This method returns true if the variable named by var
is a latitude coordinate variable. See section 4.1 of the CF spec.
true | if var is latitude coordinate variable, false otherwise |
Definition at line 95 of file NetCDFCFCollection.h.
|
inlinevirtual |
Return boolean indicating whether the named variable represents longitude.
This method returns true if the variable named by var
is a longitude coordinate variable. See section 4.2 of the CF spec.
true | if var is longitude coordinate variable, false otherwise |
Definition at line 108 of file NetCDFCFCollection.h.
|
inlinevirtual |
Return boolean indicating whether the named variable represents time.
This method returns true if the variable named by var
is a time coordinate variable. See section 4.4 of the CF spec.
true | if var is a time coordinate variable, false otherwise |
Definition at line 121 of file NetCDFCFCollection.h.
|
inlinevirtual |
Return boolean indicating whether the named variable represents a vertical coordinate.
This method returns true if the variable named by var
is a dimesional or dimensionless vertical coordinate variable. See section 4.3 of the CF spec.
true | if var is a time coordinate variable, false otherwise |
Definition at line 135 of file NetCDFCFCollection.h.
|
virtual |
Return true if the increasing direction of the named vertical coordinate variable is up
CF 1.x description of vertical coordinate direction:
The direction of positive (i.e., the direction in which the coordinate values are increasing), whether up or down, cannot in all cases be inferred from the units. The direction of positive is useful for applications displaying the data. For this reason the attribute positive as defined in the COARDS standard is required if the vertical axis units are not a valid unit of pressure (a determination which can be made using the udunits routine, utScan) – otherwise its inclusion is optional. The positive attribute may have the value up or down (case insensitive).
|
virtual |
Return true if the named variable is a dimensionless vertical coordinate variable.
This method returns true if the variable named by cvar
is both a vertical coordinate variable and it is dimensionless. See section 4.3.2 of the CF 1.6 spec.
|
virtual |
Open the named variable for reading
This method prepares a netCDF variable, indicated by a variable name and time step pair, for subsequent read operations by methods of this class. A small, non-negative integer for use in subsequent read operations is returned. The file descriptor returned by a successful call will be the lowest-numbered file descriptor not currently open for the process, starting with zero.
[in] | ts | Time step of the variable to read |
[in] | varname | Name of the variable to read |
status | Returns a non-negative file descriptor on success |
Reimplemented from VAPoR::NetCDFCollection.
|
virtual |
Remove the converter for a previously defined dimensionless vertical coordinate converter
[in] | cvar | The name of a derived variable previousl defined with InstallStandardVerticalConverter() |
|
friend |