VAPOR3 3.9.4
Public Member Functions | Friends | List of all members
VAPoR::NetCDFCFCollection Class Reference

Wrapper for a collection of netCDF files. More...

#include <NetCDFCFCollection.h>

Inheritance diagram for VAPoR::NetCDFCFCollection:
VAPoR::NetCDFCollection Wasp::MyBase

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 IsCoordinateVar (string varName) 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 IsVertCoordVarPressure (string var) const
 
virtual bool IsVertCoordVarLength (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 UDUnitsGetUDUnits () const
 
virtual int Convert (const string from, const string to, const double *src, double *dst, size_t n) const
 
virtual int Convert (const string from, const string to, const float *src, float *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
 
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 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
 
int GetXType (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 std::vector< bool > GetDimsAreTimeVarying () const
 
long GetDimLengthAtTime (string name, long ts)
 
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 > &times) 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 bool GetMissingValue (string varname, double &mv) const
 
virtual int OpenRead (size_t ts, string varname)
 
virtual int Read (size_t start[], size_t count[], double *data, int fd=0)
 
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 (size_t start[], size_t count[], char *data, int fd=0)
 
virtual int Read (std::vector< size_t > start, std::vector< size_t > count, double *data, int fd=0)
 
virtual int Read (std::vector< size_t > start, std::vector< size_t > count, float *data, int fd=0)
 
virtual int Read (std::vector< size_t > start, std::vector< size_t > count, int *data, int fd=0)
 
virtual int Read (double *data, int fd=0)
 
virtual int Read (float *data, int fd=0)
 
virtual int Read (char *data, int fd=0)
 
virtual int Read (int *data, int fd=0)
 
virtual int ReadSlice (float *data, int fd=0)
 
virtual int SeekSlice (int offset, int whence, int fd=0)
 
virtual int Close (int fd=0)
 
virtual void SetMissingValueAttName (string attname)
 
virtual std::vector< string > GetFailedVars () const
 
- Public Member Functions inherited from Wasp::MyBase
 MyBase ()
 
const string & getClassName () const
 

Friends

std::ostream & operator<< (std::ostream &o, const NetCDFCFCollection &ncdfc)
 

Additional Inherited Members

- Public Types inherited from Wasp::MyBase
typedef void(* ErrMsgCB_T) (const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T) (const char *msg)
 
- 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
 
- Protected Member Functions inherited from VAPoR::NetCDFCollection
bool _GetVariableInfo (string varname, NetCDFSimple::Variable &variable) const
 
- Protected Member Functions inherited from Wasp::MyBase
void SetClassName (const string &name)
 

Detailed Description

Wrapper for a collection of netCDF files.

Author
John Clyne
Version
$Revision$
Date
$Date$

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 34 of file NetCDFCFCollection.h.

Constructor & Destructor Documentation

◆ NetCDFCFCollection()

VAPoR::NetCDFCFCollection::NetCDFCFCollection ( )

◆ ~NetCDFCFCollection()

virtual VAPoR::NetCDFCFCollection::~NetCDFCFCollection ( )
virtual

Member Function Documentation

◆ Convert() [1/2]

virtual int VAPoR::NetCDFCFCollection::Convert ( const string  from,
const string  to,
const double *  src,
double *  dst,
size_t  n 
) const
virtual

◆ Convert() [2/2]

virtual int VAPoR::NetCDFCFCollection::Convert ( const string  from,
const string  to,
const float *  src,
float *  dst,
size_t  n 
) const
virtual

◆ FormatTimeStr()

void VAPoR::NetCDFCFCollection::FormatTimeStr ( double  time,
string &  str 
) const

◆ GetDataVariableNames()

virtual std::vector< string > VAPoR::NetCDFCFCollection::GetDataVariableNames ( int  ndim,
bool  spatial 
) 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.

Parameters
[in]ndimRank of spatial dimensions
[in]spatialOnly compare spatial dimensions against ndim
See also
NetCDFCollection::GetVariableNames()

◆ GetLatCoordVars()

virtual std::vector< string > VAPoR::NetCDFCFCollection::GetLatCoordVars ( ) const
inlinevirtual

Return a vector of all latitude coordinate variables

Definition at line 170 of file NetCDFCFCollection.h.

◆ GetLonCoordVars()

virtual std::vector< string > VAPoR::NetCDFCFCollection::GetLonCoordVars ( ) const
inlinevirtual

Return a vector of all longitude coordinate variables

Definition at line 174 of file NetCDFCFCollection.h.

◆ GetMapProjectionProj4()

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.

◆ GetMissingValue()

virtual bool VAPoR::NetCDFCFCollection::GetMissingValue ( string  varname,
double &  mv 
) const
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.

Parameters
[in]varnameThe variable name
[out]mvThe missing value for the variabled name by varname
Return values
boolThe 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.

◆ GetTimeCoordVars()

virtual std::vector< string > VAPoR::NetCDFCFCollection::GetTimeCoordVars ( ) const
inlinevirtual

Return a vector of all time coordinate variables

Definition at line 178 of file NetCDFCFCollection.h.

◆ GetUDUnits()

const UDUnits * VAPoR::NetCDFCFCollection::GetUDUnits ( ) const
inline

Return a pointer to the internal UDUnits object used to perform unit conversion.

Definition at line 262 of file NetCDFCFCollection.h.

◆ GetVarCoordVarNames()

virtual int VAPoR::NetCDFCFCollection::GetVarCoordVarNames ( string  var,
std::vector< string > &  cvars 
) const
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."

Parameters
[in]varnameA variable name
[out]cvarsA ordered vector of coordinate variable names
Return values
statusa 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

◆ GetVarUnits()

virtual int VAPoR::NetCDFCFCollection::GetVarUnits ( string  var,
string &  units 
) const
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.

Parameters
[in]varnameA variable name
[out]unitsThe value of the variable's 'units' attribute. If the 'units' attribute is not present the parameter will contain the empty string.
Return values
statusa non-negative int is returned on success

◆ GetVertCoordVars()

virtual std::vector< string > VAPoR::NetCDFCFCollection::GetVertCoordVars ( ) const
inlinevirtual

Return a vector of all vertical coordinate variables

Definition at line 182 of file NetCDFCFCollection.h.

◆ Initialize()

virtual int VAPoR::NetCDFCFCollection::Initialize ( const std::vector< string > &  files)
virtual

◆ IsAuxCoordVarCF()

virtual bool VAPoR::NetCDFCFCollection::IsAuxCoordVarCF ( string  var) const
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).

Return values
trueif var is an auxliary coordinate variable, false otherwise

Definition at line 73 of file NetCDFCFCollection.h.

◆ IsCoordinateVar()

virtual bool VAPoR::NetCDFCFCollection::IsCoordinateVar ( string  varName) const
inlinevirtual

Return boolean indicating whether the named variable is a NetCDF CF "coordinate" variable or a "auxilliary" coordinate variable.

See also
IsAuxCoordVarCF(), IsCoordVarCF()

Definition at line 82 of file NetCDFCFCollection.h.

◆ IsCoordVarCF()

virtual bool VAPoR::NetCDFCFCollection::IsCoordVarCF ( string  var) const
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 as defined by the CF specification. I.e. the variable has a single spatial dimension whose name matches var name; the variable can be identified as a vertical, lat, lon, or time coordinate variable; or the variable is listed by some other variable's "coordinate" metadata attribute.

Return values
trueif var is a coordinate variable, false otherwise
See also
IsAuxCoordVarCF()

Definition at line 55 of file NetCDFCFCollection.h.

◆ IsLatCoordVar()

virtual bool VAPoR::NetCDFCFCollection::IsLatCoordVar ( string  var) const
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.

Return values
trueif var is latitude coordinate variable, false otherwise

Definition at line 94 of file NetCDFCFCollection.h.

◆ IsLonCoordVar()

virtual bool VAPoR::NetCDFCFCollection::IsLonCoordVar ( string  var) const
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.

Return values
trueif var is longitude coordinate variable, false otherwise

Definition at line 104 of file NetCDFCFCollection.h.

◆ IsTimeCoordVar()

virtual bool VAPoR::NetCDFCFCollection::IsTimeCoordVar ( string  var) const
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.

Return values
trueif var is a time coordinate variable, false otherwise

Definition at line 114 of file NetCDFCFCollection.h.

◆ IsVertCoordVar()

virtual bool VAPoR::NetCDFCFCollection::IsVertCoordVar ( string  var) const
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.

Return values
trueif var is a time coordinate variable, false otherwise

Definition at line 125 of file NetCDFCFCollection.h.

◆ IsVertCoordVarLength()

virtual bool VAPoR::NetCDFCFCollection::IsVertCoordVarLength ( string  var) const
virtual

Return boolean indicating whether the named variable represents a vertical length coordinate.

This method returns true if the variable named by var is a vertical coordinate variable with units of length (e.g. meters) See section 4.3 of the CF spec.

Return values
trueif var is a vertical length coordinate variable, false otherwise

◆ IsVertCoordVarPressure()

virtual bool VAPoR::NetCDFCFCollection::IsVertCoordVarPressure ( string  var) const
virtual

Return boolean indicating whether the named variable represents a vertical pressure coordinate.

This method returns true if the variable named by var is a vertical coordinate variable with units of pressure. See section 4.3 of the CF spec.

Return values
trueif var is a vertical pressure coordinate variable, false otherwise

◆ IsVertCoordVarUp()

virtual bool VAPoR::NetCDFCFCollection::IsVertCoordVarUp ( string  var) const
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).

◆ IsVertDimensionless()

virtual bool VAPoR::NetCDFCFCollection::IsVertDimensionless ( string  cvar) const
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.

◆ OpenRead()

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

Parameters
[in]tsTime step of the variable to read
[in]varnameName of the variable to read
Return values
statusReturns a non-negative file descriptor on success
See also
Read(), ReadSlice()

Reimplemented from VAPoR::NetCDFCollection.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  o,
const NetCDFCFCollection ncdfc 
)
friend

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