NetCDF-C++ 4.3.1
netCDF::NcFile Class Reference

Class represents a netCDF root group. More...

#include "ncFile.h"

Inheritance diagram for netCDF::NcFile:
netCDF::NcGroup

Public Types

enum  FileFormat { classic , classic64 , nc4 , nc4classic }
 
enum  FileMode { read , write , replace , newFile }
 
enum  GroupLocation {
  ChildrenGrps , ParentsGrps , ChildrenOfChildrenGrps , AllChildrenGrps ,
  ParentsAndCurrentGrps , AllGrps
}
 The enumeration list contains the options for selecting groups (used for returned set of NcGroup objects). More...
 
enum  Location {
  Current , Parents , Children , ParentsAndCurrent ,
  ChildrenAndCurrent , All
}
 The enumeration list contains the options for selecting groups. More...
 

Public Member Functions

 NcFile ()
 Constructor generates a null object. More...
 
 NcFile (const std::string &filePath, FileMode fMode)
 Opens a netCDF file. More...
 
 NcFile (const std::string &filePath, FileMode fMode, FileFormat fFormat)
 Creates a netCDF file of a specified format. More...
 
 NcFile (const std::string &filePath, int ncFileFlags)
 Opens a netCDF file. More...
 
virtual ~NcFile ()
 destructor More...
 
NcCompoundType addCompoundType (const std::string &name, size_t size) const
 Adds a new netCDF UserDefined type. More...
 
NcDim addDim (const std::string &name) const
 Adds a new unlimited netCDF dimension. More...
 
NcDim addDim (const std::string &name, size_t dimSize) const
 Adds a new netCDF dimension. More...
 
NcEnumType addEnumType (const std::string &name, NcEnumType::ncEnumType basetype) const
 Adds a new netCDF enum type. More...
 
NcGroup addGroup (const std::string &name) const
 Adds a new child netCDF group object. More...
 
NcOpaqueType addOpaqueType (const std::string &name, size_t size) const
 Adds a new netCDF Opaque type. More...
 
NcVar addVar (const std::string &name, const NcType &ncType) const
 Adds a new netCDF scalar variable. More...
 
NcVar addVar (const std::string &name, const NcType &ncType, const NcDim &ncDim) const
 Adds a new netCDF variable. More...
 
NcVar addVar (const std::string &name, const NcType &ncType, const std::vector< NcDim > &ncDimVector) const
 Adds a new multi-dimensional netCDF variable. More...
 
NcVar addVar (const std::string &name, const std::string &typeName, const std::string &dimName) const
 Adds a new netCDF variable. More...
 
NcVar addVar (const std::string &name, const std::string &typeName, const std::vector< std::string > &dimNames) const
 Adds a new netCDF multi-dimensional variable. More...
 
NcVlenType addVlenType (const std::string &name, NcType &basetype) const
 Adds a new netCDF Vlen type. More...
 
void close ()
 Close a file before destructor call. More...
 
void create (const std::string &filePath, int ncFileFlags)
 Create a netCDF file. More...
 
void enddef ()
 Leave define mode, used for classic model. More...
 
NcGroupAtt getAtt (const std::string &name, NcGroup::Location location=Current) const
 Gets the named NcGroupAtt object. More...
 
int getAttCount (NcGroup::Location location=Current) const
 Gets the number of group attributes. More...
 
std::set< NcGroupAttgetAtts (const std::string &name, NcGroup::Location location=Current) const
 Gets all NcGroupAtt objects with a given name. More...
 
std::multimap< std::string, NcGroupAttgetAtts (NcGroup::Location location=Current) const
 Gets the collection of NcGroupAtt objects. More...
 
void getCoordVar (std::string &coordVarName, NcDim &ncDim, NcVar &ncVar, NcGroup::Location location=Current) const
 Gets the NcDim and NcVar object pair for a named coordinate variable. More...
 
std::map< std::string, NcGroupgetCoordVars (NcGroup::Location location=Current) const
 Gets a collection of coordinate variables. More...
 
NcDim getDim (const std::string &name, NcGroup::Location location=Current) const
 Gets the named NcDim object. More...
 
int getDimCount (NcGroup::Location location=Current) const
 Gets the number of NcDim objects. More...
 
std::set< NcDimgetDims (const std::string &name, NcGroup::Location location=Current) const
 Gets NcDim objects with a given name. More...
 
std::multimap< std::string, NcDimgetDims (NcGroup::Location location=Current) const
 Gets the collection of NcDim objects. More...
 
NcGroup getGroup (const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
 Gets the named child NcGroup object. More...
 
int getGroupCount (NcGroup::GroupLocation location=ChildrenGrps) const
 Gets the number of NcGroup objects. More...
 
std::set< NcGroupgetGroups (const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
 Gets NcGroup objects with a given name. More...
 
std::multimap< std::string, NcGroupgetGroups (NcGroup::GroupLocation location=ChildrenGrps) const
 Gets the collection of NcGroup objects. More...
 
int getId () const
 Gets the group id. More...
 
std::string getName (bool fullName=false) const
 Gets the group name. More...
 
NcGroup getParentGroup () const
 Gets the parent group. More...
 
NcType getType (const std::string &name, NcGroup::Location location=Current) const
 Gets the NcType object with a given name. More...
 
int getTypeCount (NcGroup::Location location=Current) const
 Gets the number of type objects. More...
 
int getTypeCount (NcType::ncType enumType, NcGroup::Location location=Current) const
 Gets the number of type objects with a given enumeration type. More...
 
std::set< NcTypegetTypes (const std::string &name, NcGroup::Location location=Current) const
 Gets the collection of NcType objects with a given name. More...
 
std::set< NcTypegetTypes (const std::string &name, NcType::ncType enumType, NcGroup::Location location=Current) const
 Gets the collection of NcType objects with a given name and data type. More...
 
std::multimap< std::string, NcTypegetTypes (NcGroup::Location location=Current) const
 Gets the collection of NcType objects. More...
 
std::set< NcTypegetTypes (NcType::ncType enumType, NcGroup::Location location=Current) const
 Gets the collection of NcType objects with a given data type. More...
 
NcVar getVar (const std::string &name, NcGroup::Location location=Current) const
 Gets the named NcVar object. More...
 
int getVarCount (NcGroup::Location location=Current) const
 Gets the number of NcVar objects in this group. More...
 
std::set< NcVargetVars (const std::string &name, NcGroup::Location location=Current) const
 Gets all NcVar objects with a given name. More...
 
std::multimap< std::string, NcVargetVars (NcGroup::Location location=Current) const
 Get the collection of NcVar objects. More...
 
bool isNull () const
 Returns true if this object is null (i.e. More...
 
bool isRootGroup () const
 Returns true if this is the root group, otherwise returns false. More...
 
void open (const std::string &filePath, FileMode fMode)
 Opens a netCDF file. More...
 
void open (const std::string &filePath, FileMode fMode, FileFormat fFormat)
 Creates a netCDF file of a specified format. More...
 
void open (const std::string &filePath, int ncFileFlags)
 Opens a netCDF file. More...
 
bool operator!= (const NcGroup &rhs) const
 != operator More...
 
bool operator== (const NcGroup &rhs) const
 equivalence operator More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, double datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, float datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, int datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, long datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, long long datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, short datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const double *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const float *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const int *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const long *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const long long *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const short *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const signed char *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const unsigned char *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const unsigned int *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const unsigned long long *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const unsigned short *dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const void *dataValues) const
 Creates a new NetCDF group attribute or if already exisiting replaces it. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, unsigned int datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, unsigned long long datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, unsigned short datumValue) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, const std::string &dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
NcGroupAtt putAtt (const std::string &name, size_t len, const char **dataValues) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void redef ()
 Redefine variable. More...
 
void set_Fill (int fillmode, int *old_modep)
 Elect a fill parameter different that the one currently being used. More...
 
void sync ()
 Synchronize an open netcdf dataset to disk. More...
 

Protected Attributes

int myId
 
bool nullObject
 assignment operator
More...
 

Detailed Description

Class represents a netCDF root group.

The Ncfile class is the same as the NcGroup class with the additional functionality for opening and closing files.

Definition at line 18 of file ncFile.h.

Member Enumeration Documentation

◆ FileFormat

Enumerator
classic 

Classic format, classic data model.

classic64 

64-bit offset format, classic data model

nc4 

(default) netCDF-4/HDF5 format, enhanced data model

nc4classic 

netCDF-4/HDF5 format, classic data model

Definition at line 30 of file ncFile.h.

◆ FileMode

Enumerator
read 

File exists, open read-only.

write 

File exists, open for writing.

replace 

Create new file, even if already exists.

newFile 

Create new file, fail if already exists.

Definition at line 22 of file ncFile.h.

◆ GroupLocation

The enumeration list contains the options for selecting groups (used for returned set of NcGroup objects).

Enumerator
ChildrenGrps 

Select from the set of children in the current group.

ParentsGrps 

Select from set of parent groups (excludes the current group).

ChildrenOfChildrenGrps 

Select from set of all children of children in the current group.

AllChildrenGrps 

Select from set of all children of the current group and beneath.

ParentsAndCurrentGrps 

Select from set of parent groups(includes the current group).

AllGrps 

Select from set of parent groups, current groups and all the children beneath.

Definition at line 35 of file ncGroup.h.

◆ Location

enum netCDF::NcGroup::Location
inherited

The enumeration list contains the options for selecting groups.

Enumerator
Current 

Select from contents of current group.

Parents 

Select from contents of parents groups.

Children 

Select from contents of children groups.

ParentsAndCurrent 

Select from contents of current and parents groups.

ChildrenAndCurrent 

Select from contents of current and child groups.

All 

Select from contents of current, parents and child groups.

Definition at line 48 of file ncGroup.h.

Constructor & Destructor Documentation

◆ NcFile() [1/4]

NcFile::NcFile ( )

Constructor generates a null object.

Definition at line 41 of file ncFile.cpp.

◆ NcFile() [2/4]

netCDF::NcFile::NcFile ( const std::string &  filePath,
int  ncFileFlags 
)

Opens a netCDF file.

Parameters
filePathName of netCDF optional path. \aram ncFileFlags File flags from netcdf.h

◆ NcFile() [3/4]

netCDF::NcFile::NcFile ( const std::string &  filePath,
FileMode  fMode 
)

Opens a netCDF file.

Parameters
filePathName of netCDF optional path.
fModeThe file mode:
  • 'read' File exists, open for read-only.
  • 'write' File exists, open for writing.
  • 'replace' Create new file, even it already exists.
  • 'newFile' Create new file, fail it exists already.

◆ NcFile() [4/4]

netCDF::NcFile::NcFile ( const std::string &  filePath,
FileMode  fMode,
FileFormat  fFormat 
)

Creates a netCDF file of a specified format.

Parameters
filePathName of netCDF optional path.
fModeThe file mode:
  • 'replace' Create new file, even it already exists.
  • 'newFile' Create new file, fail it exists already.

◆ ~NcFile()

NcFile::~NcFile ( )
virtual

destructor

Definition at line 15 of file ncFile.cpp.

Member Function Documentation

◆ addCompoundType()

NcCompoundType NcGroup::addCompoundType ( const std::string &  name,
size_t  size 
) const
inherited

Adds a new netCDF UserDefined type.

Parameters
nameName of type.
sizeThe size of the new type in bytes.
Returns
The new NcCompoundType object for this new netCDF userDefined type.

Definition at line 1290 of file ncGroup.cpp.

◆ addDim() [1/2]

NcDim netCDF::NcGroup::addDim ( const std::string &  name) const
inherited

Adds a new unlimited netCDF dimension.

Parameters
Thename of new dimension.
Returns
The NcDim object for this new netCDF dimension.

◆ addDim() [2/2]

NcDim netCDF::NcGroup::addDim ( const std::string &  name,
size_t  dimSize 
) const
inherited

Adds a new netCDF dimension.

Parameters
Thename of new dimension.
Lengthof dimension; that is, number of values for this dimension as an index to variables that use it.
Returns
The NcDim object for this new netCDF dimension.

◆ addEnumType()

NcEnumType NcGroup::addEnumType ( const std::string &  name,
NcEnumType::ncEnumType  basetype 
) const
inherited

Adds a new netCDF enum type.

Parameters
nameName of type. For atomic types, the CDL name is expected. This is consistent with the string returned from NcType::getName().
enumTypeThe enumeration value of the object type.
Returns
The NcEnumType object for this new netCDF enum type.

Definition at line 1261 of file ncGroup.cpp.

◆ addGroup()

NcGroup NcGroup::addGroup ( const std::string &  name) const
inherited

Adds a new child netCDF group object.

Method will throw an netCDF::exceptions::NcNullgrp exception if the group is null (ie NcGroup::isNull()=true).

Parameters
nameVariable name.
Returns
NcGroup The NcGroup object for this new netCDF group.

Definition at line 265 of file ncGroup.cpp.

◆ addOpaqueType()

NcOpaqueType NcGroup::addOpaqueType ( const std::string &  name,
size_t  size 
) const
inherited

Adds a new netCDF Opaque type.

Parameters
nameName of type.
sizeThe size of the new type in bytes.
Returns
The NcOpaqueType object for this new netCDF opaque type..

Definition at line 1281 of file ncGroup.cpp.

◆ addVar() [1/5]

NcVar NcGroup::addVar ( const std::string &  name,
const NcType ncType 
) const
inherited

Adds a new netCDF scalar variable.

The NcType must be non-null, and be defined in either the current group or a parent group. An NcNullType exception is thrown if the NcType object is invalid.

Parameters
nameVariable name.
typeNameType name.
Returns
The NcVar object for this new netCDF variable.

Definition at line 400 of file ncGroup.cpp.

◆ addVar() [2/5]

NcVar netCDF::NcGroup::addVar ( const std::string &  name,
const NcType ncType,
const NcDim ncDim 
) const
inherited

Adds a new netCDF variable.

The NcType and NcDim objects must be non-null, and be defined in either the current group or a parent group. An NcNullType exception is thrown if the NcType object is invalid. An NcNullDim exception is thrown if the NcDim object is invalid.

Parameters
nameVariable name.
ncTypeNcType object.
ncDimNcDim object.
Returns
The NcVar object for this new netCDF variable.

◆ addVar() [3/5]

NcVar netCDF::NcGroup::addVar ( const std::string &  name,
const NcType ncType,
const std::vector< NcDim > &  ncDimVector 
) const
inherited

Adds a new multi-dimensional netCDF variable.

The NcType and NcDim objects must be non-null, and be defined in either the current group or a parent group. An NcNullType exception is thrown if the NcType object is invalid. An NcNullDim exception is thrown if any of the the NcDim objects are invalid.

Parameters
nameVariable name.
ncTypeNcType object.
ncDimvectorVector of NcDim objects.
Returns
The NcVar object for this new netCDF variable.

◆ addVar() [4/5]

NcVar netCDF::NcGroup::addVar ( const std::string &  name,
const std::string &  typeName,
const std::string &  dimName 
) const
inherited

Adds a new netCDF variable.

The NcType and NcDim objects must be non-null, and be defined in either the current group or a parent group. An NcNullType exception is thrown if the NcType object is invalid. An NcNullDim exception is thrown if the NcDim object is invalid.

Parameters
nameVariable name.
typeNameType name.
dimNameDimension name.
Returns
The NcVar object for this new netCDF variable.

◆ addVar() [5/5]

NcVar netCDF::NcGroup::addVar ( const std::string &  name,
const std::string &  typeName,
const std::vector< std::string > &  dimNames 
) const
inherited

Adds a new netCDF multi-dimensional variable.

The NcType and NcDim objects must be non-null, and be defined in either the current group or a parent group. An NcNullType exception is thrown if the NcType object is invalid. An NcNullDim exception is thrown if the NcDim object is invalid.

Parameters
nameVariable name.
typeNameType name.
dimNamesVector of dimension names.
Returns
The NcVar object for this new netCDF variable.

◆ addVlenType()

NcVlenType NcGroup::addVlenType ( const std::string &  name,
NcType basetype 
) const
inherited

Adds a new netCDF Vlen type.

Parameters
nameName of type.
basetypeA NcType object to be used for the basetype.
Returns
The NcVlenType object for this new netCDF vlen type.

Definition at line 1271 of file ncGroup.cpp.

◆ close()

void NcFile::close ( )

Close a file before destructor call.

Definition at line 30 of file ncFile.cpp.

◆ create()

void NcFile::create ( const std::string &  filePath,
int  ncFileFlags 
)

Create a netCDF file.

Allow for the explicit creation of a file using a path and NC_ file flags from netcdf.h.

Parameters
filePathName of netCDF optional path.
ncFileFlagsFile flags from netcdf.h
Author
wfisher

Definition at line 114 of file ncFile.cpp.

◆ enddef()

void NcFile::enddef ( )

Leave define mode, used for classic model.

Definition at line 182 of file ncFile.cpp.

◆ getAtt()

NcGroupAtt NcGroup::getAtt ( const std::string &  name,
NcGroup::Location  location = Current 
) const
inherited

Gets the named NcGroupAtt object.

Parameters
nameName of attribute
locationEnumeration type controlling the groups to search.
Returns
A NcGroupAtt object. If there are multiple objects indentied with the same name, the object closest to the current group is returned. If no valid object is found , a null node is returned.

Definition at line 593 of file ncGroup.cpp.

◆ getAttCount()

int NcGroup::getAttCount ( NcGroup::Location  location = Current) const
inherited

Gets the number of group attributes.

Parameters
locationEnumeration type controlling the groups to search.
Returns
Number of attributes.

Definition at line 507 of file ncGroup.cpp.

◆ getAtts() [1/2]

std::set< NcGroupAtt > netCDF::NcGroup::getAtts ( const std::string &  name,
NcGroup::Location  location = Current 
) const
inherited

Gets all NcGroupAtt objects with a given name.

Parameters
nameName of attribute
locationEnumeration type controlling the groups to search.
Returns
Set of NcGroupAtt objects.

◆ getAtts() [2/2]

multimap< std::string, NcGroupAtt > NcGroup::getAtts ( NcGroup::Location  location = Current) const
inherited

Gets the collection of NcGroupAtt objects.

Parameters
locationEnumeration type controlling the groups to search.
Returns
A STL multimap object, containing pairs of <attribute name, NcGroupAtt object> entities.

Definition at line 542 of file ncGroup.cpp.

◆ getCoordVar()

void NcGroup::getCoordVar ( std::string &  coordVarName,
NcDim ncDim,
NcVar ncVar,
NcGroup::Location  location = Current 
) const
inherited

Gets the NcDim and NcVar object pair for a named coordinate variable.

Coordinate variable have an NcDim and NcVar object with the same name defined in the same group.

The method returns two objects for the named coordinate variable. The method searches first in the current group and optionally in the parent and child group and returns the first instance found.
Parameters
locationEnumeration type controlling the groups to search.
Returns
The set of names of dimension variables.

Definition at line 1339 of file ncGroup.cpp.

◆ getCoordVars()

map< string, NcGroup > NcGroup::getCoordVars ( NcGroup::Location  location = Current) const
inherited

Gets a collection of coordinate variables.

Coordinate variable have an NcDim and NcVar object with the same name defined in the same group.

The method returns STL map object containing a coordinate variables in the current group and optionally in the parent and child groups. It is expected that within each group, the names of dimensions are unique and the the names of variables are unique. However, if this is not the case, this method will still work correctly.
Parameters
locationEnumeration type controlling the groups to search.
Returns
The NcVar dimension variable. If no valid object is found , a null node is returned.

Definition at line 1300 of file ncGroup.cpp.

◆ getDim()

NcDim NcGroup::getDim ( const std::string &  name,
NcGroup::Location  location = Current 
) const
inherited

Gets the named NcDim object.

Parameters
nameName of dimension.
locationEnumeration type controlling the groups to search.
Returns
An NcDim object. If there are multiple objects indentied with the same name, the object closest to the current group is returned. If no valid object is found , a null node is returned.

Definition at line 984 of file ncGroup.cpp.

◆ getDimCount()

int NcGroup::getDimCount ( NcGroup::Location  location = Current) const
inherited

Gets the number of NcDim objects.

Parameters
locationEnumeration type controlling the groups to search.
Returns
Number of dimensions.

Definition at line 904 of file ncGroup.cpp.

◆ getDims() [1/2]

std::set< NcDim > netCDF::NcGroup::getDims ( const std::string &  name,
NcGroup::Location  location = Current 
) const
inherited

Gets NcDim objects with a given name.

Parameters
nameName of dimension.
locationEnumeration type controlling the groups to search.
Returns
Set of NcDim objects with given name.

◆ getDims() [2/2]

multimap< string, NcDim > NcGroup::getDims ( NcGroup::Location  location = Current) const
inherited

Gets the collection of NcDim objects.

Parameters
locationEnumeration type controlling the groups to search.
Returns
A STL multimap object, containing pairs of <attribute name, NcDim object> entities.

Definition at line 939 of file ncGroup.cpp.

◆ getGroup()

NcGroup NcGroup::getGroup ( const std::string &  name,
NcGroup::GroupLocation  location = ChildrenGrps 
) const
inherited

Gets the named child NcGroup object.

Method will throw an netCDF::exceptions::NcNullgrp exception if the group is null (ie NcGroup::isNull()=true).

Parameters
nameGroup name.
locationEnumeration type controlling the groups to search.
Returns
An NcGroup object. If there are multiple objects indentied with the same name, the object closest to the current group is returned. If no valid object is found , a null node is returned.

Definition at line 236 of file ncGroup.cpp.

◆ getGroupCount()

int NcGroup::getGroupCount ( NcGroup::GroupLocation  location = ChildrenGrps) const
inherited

Gets the number of NcGroup objects.

Method will throw an netCDF::exceptions::NcNullgrp exception if the group is null (ie NcGroup::isNull()=true).

Parameters
locationEnumeration type controlling the groups to search.
Returns
Number of groups.

Definition at line 147 of file ncGroup.cpp.

◆ getGroups() [1/2]

set< NcGroup > NcGroup::getGroups ( const std::string &  name,
NcGroup::GroupLocation  location = ChildrenGrps 
) const
inherited

Gets NcGroup objects with a given name.

Method will throw an netCDF::exceptions::NcNullgrp exception if the group is null (ie NcGroup::isNull()=true).

Parameters
nameName of group.
locationEnumeration type controlling the groups to search.
Returns
Set of NcGroup objects with given name.

Definition at line 250 of file ncGroup.cpp.

◆ getGroups() [2/2]

multimap< std::string, NcGroup > NcGroup::getGroups ( NcGroup::GroupLocation  location = ChildrenGrps) const
inherited

Gets the collection of NcGroup objects.

Method will throw an netCDF::exceptions::NcNullgrp exception if the group is null (ie NcGroup::isNull()=true).

Parameters
locationEnumeration type controlling the groups to search.
Returns
A STL multimap object, containing pairs of <attribute name, NcGroup object> entities.

Definition at line 183 of file ncGroup.cpp.

◆ getId()

int NcGroup::getId ( ) const
inherited

Gets the group id.

Method will throw an netCDF::exceptions::NcNullgrp exception if the group is null (ie NcGroup::isNull()=true).

Definition at line 141 of file ncGroup.cpp.

◆ getName()

string NcGroup::getName ( bool  fullName = false) const
inherited

Gets the group name.

Method will throw an netCDF::exceptions::NcNullgrp exception if the group is null (ie NcGroup::isNull()=true).

Parameters
fullNameIf true then the full name is returned with subgroups separated by a forward slash "/" (default is false)
Returns
The group name.

Definition at line 97 of file ncGroup.cpp.

◆ getParentGroup()

NcGroup NcGroup::getParentGroup ( ) const
inherited

Gets the parent group.

Method will throw an netCDF::exceptions::NcNullgrp exception if the group is null (ie NcGroup::isNull()=true). If the current root is the parent group, then return a null group.

Definition at line 125 of file ncGroup.cpp.

◆ getType()

NcType NcGroup::getType ( const std::string &  name,
NcGroup::Location  location = Current 
) const
inherited

Gets the NcType object with a given name.

Parameters
nameName of type. For atomic types, the CDL name is expected. This is consistent with the string returned from NcType::getName().
locationEnumeration type controlling the groups to search.
Returns
NcType object. If there are multiple objects indentied with the same name, the object closest to the current group is returned. If no valid object is found , a null node is returned.

Definition at line 1227 of file ncGroup.cpp.

◆ getTypeCount() [1/2]

int NcGroup::getTypeCount ( NcGroup::Location  location = Current) const
inherited

Gets the number of type objects.

Parameters
locationEnumeration type controlling the groups to search.
Returns
Number of types.

Definition at line 1040 of file ncGroup.cpp.

◆ getTypeCount() [2/2]

int NcGroup::getTypeCount ( NcType::ncType  enumType,
NcGroup::Location  location = Current 
) const
inherited

Gets the number of type objects with a given enumeration type.

Parameters
enumTypeThe enumeration value of the object type.
locationEnumeration type controlling the groups to search.
Returns
Number of types of the given enumeration type.

Definition at line 1078 of file ncGroup.cpp.

◆ getTypes() [1/4]

std::set< NcType > netCDF::NcGroup::getTypes ( const std::string &  name,
NcGroup::Location  location = Current 
) const
inherited

Gets the collection of NcType objects with a given name.

Parameters
nameName of type. For atomic types, the CDL name is expected. This is consistent with the string returned from NcType::getName().
locationEnumeration type controlling the groups to search.
Returns
Set of NcType objects.

◆ getTypes() [2/4]

std::set< NcType > netCDF::NcGroup::getTypes ( const std::string &  name,
NcType::ncType  enumType,
NcGroup::Location  location = Current 
) const
inherited

Gets the collection of NcType objects with a given name and data type.

Parameters
nameName of type. For atomic types, the CDL name is expected. This is consistent with the string returned from NcType::getName().
enumTypeEnumeration type specifying the data type.
locationEnumeration type controlling the groups to search.
Returns
Set of Nctype objects.

◆ getTypes() [3/4]

multimap< string, NcType > NcGroup::getTypes ( NcGroup::Location  location = Current) const
inherited

Gets the collection of NcType objects.

Parameters
locationEnumeration type controlling the groups to search.
Returns
A STL multimap object, on return contains pairs of <Type name, NcType object> entities. For atomic types, the type returned is the CDL name.

Definition at line 1122 of file ncGroup.cpp.

◆ getTypes() [4/4]

set< NcType > NcGroup::getTypes ( NcType::ncType  enumType,
NcGroup::Location  location = Current 
) const
inherited

Gets the collection of NcType objects with a given data type.

Parameters
enumTypeEnumeration type specifying the data type.
locationEnumeration type controlling the groups to search.
Returns
Set of Nctype objects.

Definition at line 1186 of file ncGroup.cpp.

◆ getVar()

NcVar NcGroup::getVar ( const std::string &  name,
NcGroup::Location  location = Current 
) const
inherited

Gets the named NcVar object.

Parameters
nameVariable name.
locationEnumeration type controlling the groups to search.
Returns
A NcVar object. If there are multiple objects indentied with the same name, the object closest to the current group is returned. If no valid object is found , a null node is returned.

Definition at line 388 of file ncGroup.cpp.

◆ getVarCount()

int NcGroup::getVarCount ( NcGroup::Location  location = Current) const
inherited

Gets the number of NcVar objects in this group.

Parameters
locationEnumeration type controlling the groups to search.
Returns
Number of variables.

Definition at line 279 of file ncGroup.cpp.

◆ getVars() [1/2]

std::set< NcVar > netCDF::NcGroup::getVars ( const std::string &  name,
NcGroup::Location  location = Current 
) const
inherited

Gets all NcVar objects with a given name.

Parameters
nameName of attribute
locationEnumeration type controlling the groups to search.
Returns
Set of NcVar objects.

◆ getVars() [2/2]

multimap< std::string, NcVar > NcGroup::getVars ( NcGroup::Location  location = Current) const
inherited

Get the collection of NcVar objects.

Parameters
locationEnumeration type controlling the groups to search.
Returns
A STL multimap object, containing pairs of <attribute name, NcVar object> entities.

Definition at line 313 of file ncGroup.cpp.

◆ isNull()

bool netCDF::NcGroup::isNull ( ) const
inlineinherited

Returns true if this object is null (i.e.

it has no contents); otherwise returns false.

Definition at line 158 of file ncGroup.h.

◆ isRootGroup()

bool NcGroup::isRootGroup ( ) const
inherited

Returns true if this is the root group, otherwise returns false.

Definition at line 119 of file ncGroup.cpp.

◆ open() [1/3]

void netCDF::NcFile::open ( const std::string &  filePath,
FileMode  fMode 
)

Opens a netCDF file.

Parameters
filePathName of netCDF optional path.
fModeThe file mode:
  • 'read' File exists, open for read-only.
  • 'write' File exists, open for writing.
  • 'replace' Create new file, even it already exists.
  • 'newFile' Create new file, fail it exists already.

◆ open() [2/3]

void netCDF::NcFile::open ( const std::string &  filePath,
FileMode  fMode,
FileFormat  fFormat 
)

Creates a netCDF file of a specified format.

Parameters
filePathName of netCDF optional path.
fModeThe file mode:
  • 'replace' Create new file, even it already exists.
  • 'newFile' Create new file, fail it exists already.

◆ open() [3/3]

void netCDF::NcFile::open ( const std::string &  filePath,
int  ncFileFlags 
)

Opens a netCDF file.

Parameters
filePathName of netCDF optional path.
ncFileFlagsFile flags from netcdf.h

◆ operator!=()

bool NcGroup::operator!= ( const NcGroup rhs) const
inherited

!= operator

Definition at line 86 of file ncGroup.cpp.

◆ operator==()

bool NcGroup::operator== ( const NcGroup rhs) const
inherited

equivalence operator

Definition at line 77 of file ncGroup.cpp.

◆ putAtt() [1/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
double  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [2/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
float  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [3/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
int  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [4/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
long  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [5/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
long long  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [6/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
short  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [7/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const double *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [8/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const float *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [9/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const int *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [10/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const long *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [11/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const long long *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [12/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const short *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [13/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const signed char *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [14/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const unsigned char *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [15/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const unsigned int *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [16/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const unsigned long long *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [17/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const unsigned short *  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [18/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
size_t  len,
const void *  dataValues 
) const
inherited

Creates a new NetCDF group attribute or if already exisiting replaces it.

If you are writing a Fill_Value attribute, and will tell the HDF5 layer to use the specified fill value for that variable.

Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
Parameters
nameName of attribute.
typeThe attribute type.
lenThe length of the attribute (number of Nctype repeats).
dataValuesData Values to put into the new attribute. If the type of data values differs from the netCDF variable type, type conversion will occur. (However, no type conversion is carried out for variables using the user-defined data types: nc_Vlen, nc_Opaque, nc_Compound and nc_Enum.)
Returns
The NcGroupAtt object for this new netCDF attribute.

◆ putAtt() [19/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
unsigned int  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [20/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
unsigned long long  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [21/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const NcType type,
unsigned short  datumValue 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [22/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
const std::string &  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ putAtt() [23/23]

NcGroupAtt netCDF::NcGroup::putAtt ( const std::string &  name,
size_t  len,
const char **  dataValues 
) const
inherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ redef()

void NcFile::redef ( )

Redefine variable.

Definition at line 177 of file ncFile.cpp.

◆ set_Fill()

void NcFile::set_Fill ( int  fillmode,
int *  old_modep 
)

Elect a fill parameter different that the one currently being used.

Definition at line 171 of file ncFile.cpp.

◆ sync()

void NcFile::sync ( )

Synchronize an open netcdf dataset to disk.

Definition at line 167 of file ncFile.cpp.

Field Documentation

◆ myId

int netCDF::NcGroup::myId
protectedinherited

Definition at line 572 of file ncGroup.h.

◆ nullObject

bool netCDF::NcGroup::nullObject
protectedinherited

assignment operator

Definition at line 570 of file ncGroup.h.


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

Return to the Main Unidata NetCDF page.
Generated on Wed Nov 10 2021 15:25:08 for NetCDF-C++. NetCDF is a Unidata library.