bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
FONcAttributes Class Reference

A class that provides static methods to help write out attributes for a given variable. More...

#include <FONcAttributes.h>

Collaboration diagram for FONcAttributes:
Collaboration graph

Static Public Member Functions

static void add_attributes (int ncid, int varid, AttrTable &attrs, const string &var_name, const string &prepend_attr, bool is_netCDF_enhanced)
 helper function for add_attributes
 
static void add_dap4_attributes (int ncid, int varid, D4Attributes *d4_attrs, const string &var_name, const string &prepend_attr, bool is_netCDF_enhanced)
 add_dap4_attributes
 
static void add_original_name (int ncid, int varid, const string &var_name, const string &orig)
 Adds an attribute for the variable if the variable name had to be modified in any way.
 
static void add_variable_attributes (int ncid, int varid, BaseType *b, bool is_netCDF_enhanced, bool is_dap4)
 Add the attributes for an OPeNDAP variable to the netcdf file.
 
static void write_attrs_for_nc4_types (int ncid, int varid, const string &var_name, const string &global_attr_name, const string &var_attr_name, AttrTable attrs, AttrTable::Attr_iter &attr, bool is_nc_enhanced)
 writes out a single attribute that maps the datatype to netCDF-4
 
static void write_dap4_attrs_for_nc4_types (int ncid, int varid, const string &var_name, const string &global_attr_name, const string &var_attr_name, D4Attribute *attr, bool is_nc_enhanced)
 writes out a single attribute that maps the dap4 datatype to netCDF-4
 

Detailed Description

A class that provides static methods to help write out attributes for a given variable.

Given a BaseType from a DataDDS, these functions can write out attributes for that BaseType as well as all parent classes of that BaseType. Since netcdf is a flattened data structure, any variables within a structure or grid will write out attributes for the structure or grid along with its own attributes.

Definition at line 54 of file FONcAttributes.h.

Member Function Documentation

◆ add_attributes()

void FONcAttributes::add_attributes ( int ncid,
int varid,
AttrTable & attrs,
const string & var_name,
const string & prepend_attr,
bool is_netCDF_enhanced )
static

helper function for add_attributes

Parameters
ncidThe id of the netcdf file being written to
varidThe netcdf variable id
attrsThe OPeNDAP AttrTable containing the attributes
var_nameA string to prepend to the attribute name
prepend_attrAny name to prepend to the name of the attribute. As far as I know, this is no longer used; when standard attributes are prefixed client programs will (often) fail to recognize the standard attributes (since the names are no longer really standard).
is_nc_enhancedA flag to indicate if we want to map datatypes to netCDF-4
Exceptions
BESInternalErrorif there are any problems writing out the attributes for the data object.

Definition at line 147 of file FONcAttributes.cc.

◆ add_dap4_attributes()

void FONcAttributes::add_dap4_attributes ( int ncid,
int varid,
D4Attributes * d4_attrs,
const string & var_name,
const string & prepend_attr,
bool is_netCDF_enhanced )
static

add_dap4_attributes

Parameters
ncidThe id of the netcdf file being written to
varidThe netcdf variable id
attrsThe OPenDAP DAP4 attributes
var_nameany variable name to prepend to the attribute name
prepend_attrAny name to prepend to the name of the attribute. As far as I know, this is no longer used; when standard attributes are prefixed client programs will (often) fail to recognize the standard attributes (since the names are no longer really standard).
is_nc_enhancedThe flag to indicate if we want to map datatypes to netCDF-4
Exceptions
BESInternalErrorif there are any problems writing out the attributes for the data object.

Definition at line 177 of file FONcAttributes.cc.

◆ add_original_name()

void FONcAttributes::add_original_name ( int ncid,
int varid,
const string & var_name,
const string & orig )
static

Adds an attribute for the variable if the variable name had to be modified in any way.

When generating a new name for a variable, the original name might contain characters that are not allowed in netcdf files. For this reason, the characters are modified and we add an attribute to the netcdf file for that variable to signify the change.

Parameters
ncidThe id of the netcdf open file
varidThe id of the variable to add the attribute to
var_nameThe name of the variable as it appears in the new * file
origThe name of the variable before it was modified

Definition at line 796 of file FONcAttributes.cc.

◆ add_variable_attributes()

void FONcAttributes::add_variable_attributes ( int ncid,
int varid,
BaseType * b,
bool is_nc_enhanced,
bool is_dap4 )
static

Add the attributes for an OPeNDAP variable to the netcdf file.

This method writes out any attributes for the provided variable and for any parent BaseType objects of this variable. For example, if this variable is a part of a structure, which is a part of another structure, then we write out all of the attributes for the outermost structure, the inner structure, and the variable of the structure. For example, if there is a structure Alpha with attribute a1, that contains a structure Point with attribute s2, which contains two variables x, with attribute a3, and y, with attribute a4, then variable Alpha.Point.x will contain attributes Alpha.a1, Alpha.Point.s2, and a3 and Alpha.Point.y will contain attributes Alpha.a1, Alpha.Point.s2, and a4.

Attributes can also be attribute containers, and not just simple attributes. In this case, just as with structures, we flatten out the attribute containers. For example, if there is an attribute container called name, with attributes first and last contained in it, then two attributes are created called name.first and name.last.

OPeNDAP can have multiple string values for a given attribute. This can not be represented in netcdf3 (can in netcdf4). To accomplish this we take each of the string values for the given attribute and append them together using a newline as a separator (recommended by Unidata).

Parameters
ncidThe id of the netcdf file being written to
varidThe netcdf variable id to associate the attributes to
bThe OPeNDAP variable containing the attributes.
is_nc_enhancedThe flag to indicate if we want to map datatypes to netCDF-4
Exceptions
BESInternalErrorif there is a problem writing the attributes for the variable.

Definition at line 79 of file FONcAttributes.cc.

◆ write_attrs_for_nc4_types()

void FONcAttributes::write_attrs_for_nc4_types ( int ncid,
int varid,
const string & var_name,
const string & global_attr_name,
const string & var_attr_name,
AttrTable attrs,
AttrTable::Attr_iter & attr,
bool is_nc_enhanced )
static

writes out a single attribute that maps the datatype to netCDF-4

Parameters
ncidThe id of the netcdf file being written to
varidThe netcdf variable id
var_namethe name of the variable (flattened)
global_attr_namethe name of the global attribute name
var_attr_namethe name of the variable name
attrsthe AttrTable that contains the attribute to be written
attrthe iterator into the AttrTable for the attribute to be written
is_nc_enhancedThe flag to indicate if we want to map datatypes to netCDF-4
Exceptions
BESInternalErrorif there is a problem writing this attribute Note: This function only maps DAP2 attribute types to NC4.

Definition at line 825 of file FONcAttributes.cc.

◆ write_dap4_attrs_for_nc4_types()

void FONcAttributes::write_dap4_attrs_for_nc4_types ( int ncid,
int varid,
const string & var_name,
const string & global_attr_name,
const string & var_attr_name,
D4Attribute * attr,
bool is_nc_enhanced )
static

writes out a single attribute that maps the dap4 datatype to netCDF-4

Parameters
ncidThe id of the netcdf file being written to
varidThe netcdf variable id
var_namethe name of the variable (flattened)
global_attr_namethe name of the global attribute name
var_attr_namethe name of the variable name
attrthe DAP4 attribute to be written
is_nc_enhancedThe flag to indicate if we want to map datatypes to netCDF-4
Exceptions
BESInternalErrorif there is a problem writing this attribute Note: the DAP4 attributes are mapped to NC4. Now only 64-bit integer are added.

Definition at line 1085 of file FONcAttributes.cc.


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