NetCDF
4.6.3
|
Attributes hold metadata about data and files. More...
Functions | |
int | nc_get_att_string (int ncid, int varid, const char *name, char **value) |
Get a variable-length string attribute. More... | |
Deleting and Renaming Attributes | |
int | nc_rename_att (int ncid, int varid, const char *name, const char *newname) |
Rename an attribute. More... | |
int | nc_del_att (int ncid, int varid, const char *name) |
Delete an attribute. More... | |
Getting Attributes | |
int | nc_get_att (int ncid, int varid, const char *name, void *value) |
Get an attribute of any type. More... | |
int | nc_get_att_text (int ncid, int varid, const char *name, char *value) |
Get an attribute. More... | |
int | nc_get_att_schar (int ncid, int varid, const char *name, signed char *value) |
Get an attribute. More... | |
int | nc_get_att_uchar (int ncid, int varid, const char *name, unsigned char *value) |
Get an attribute. More... | |
int | nc_get_att_short (int ncid, int varid, const char *name, short *value) |
Get an attribute. More... | |
int | nc_get_att_int (int ncid, int varid, const char *name, int *value) |
Get an attribute. More... | |
int | nc_get_att_long (int ncid, int varid, const char *name, long *value) |
Get an attribute. More... | |
int | nc_get_att_float (int ncid, int varid, const char *name, float *value) |
Get an attribute. More... | |
int | nc_get_att_double (int ncid, int varid, const char *name, double *value) |
Get an attribute. More... | |
int | nc_get_att_ubyte (int ncid, int varid, const char *name, unsigned char *value) |
Get an attribute. More... | |
int | nc_get_att_ushort (int ncid, int varid, const char *name, unsigned short *value) |
Get an attribute. More... | |
int | nc_get_att_uint (int ncid, int varid, const char *name, unsigned int *value) |
Get an attribute. More... | |
int | nc_get_att_longlong (int ncid, int varid, const char *name, long long *value) |
Get an attribute. More... | |
int | nc_get_att_ulonglong (int ncid, int varid, const char *name, unsigned long long *value) |
Get an attribute. More... | |
Learning about Attributes | |
int | nc_inq_att (int ncid, int varid, const char *name, nc_type *xtypep, size_t *lenp) |
Return information about a netCDF attribute. More... | |
int | nc_inq_attid (int ncid, int varid, const char *name, int *idp) |
Find an attribute ID. More... | |
int | nc_inq_attname (int ncid, int varid, int attnum, char *name) |
Find the name of an attribute. More... | |
int | nc_inq_natts (int ncid, int *nattsp) |
Find number of global or group attributes. More... | |
int | nc_inq_atttype (int ncid, int varid, const char *name, nc_type *xtypep) |
Find the type of an attribute. More... | |
int | nc_inq_attlen (int ncid, int varid, const char *name, size_t *lenp) |
Find the length of an attribute. More... | |
Writing Attributes | |
int | nc_put_att_string (int ncid, int varid, const char *name, size_t len, const char **value) |
Write a string attribute. More... | |
int | nc_put_att_text (int ncid, int varid, const char *name, size_t len, const char *value) |
Write a text attribute. More... | |
int | nc_put_att (int ncid, int varid, const char *name, nc_type xtype, size_t len, const void *value) |
Write an attribute. More... | |
int | nc_put_att_schar (int ncid, int varid, const char *name, nc_type xtype, size_t len, const signed char *value) |
Write an attribute. More... | |
int | nc_put_att_uchar (int ncid, int varid, const char *name, nc_type xtype, size_t len, const unsigned char *value) |
Write an attribute. More... | |
int | nc_put_att_short (int ncid, int varid, const char *name, nc_type xtype, size_t len, const short *value) |
Write an attribute. More... | |
int | nc_put_att_int (int ncid, int varid, const char *name, nc_type xtype, size_t len, const int *value) |
Write an attribute. More... | |
int | nc_put_att_long (int ncid, int varid, const char *name, nc_type xtype, size_t len, const long *value) |
Write an attribute. More... | |
int | nc_put_att_float (int ncid, int varid, const char *name, nc_type xtype, size_t len, const float *value) |
Write an attribute. More... | |
int | nc_put_att_double (int ncid, int varid, const char *name, nc_type xtype, size_t len, const double *value) |
Write an attribute. More... | |
int | nc_put_att_ubyte (int ncid, int varid, const char *name, nc_type xtype, size_t len, const unsigned char *value) |
Write an attribute. More... | |
int | nc_put_att_ushort (int ncid, int varid, const char *name, nc_type xtype, size_t len, const unsigned short *value) |
Write an attribute. More... | |
int | nc_put_att_uint (int ncid, int varid, const char *name, nc_type xtype, size_t len, const unsigned int *value) |
Write an attribute. More... | |
int | nc_put_att_longlong (int ncid, int varid, const char *name, nc_type xtype, size_t len, const long long *value) |
Write an attribute. More... | |
int | nc_put_att_ulonglong (int ncid, int varid, const char *name, nc_type xtype, size_t len, const unsigned long long *value) |
Write an attribute. More... | |
Attributes hold metadata about data and files.
Attributes may be associated with a netCDF variable to specify such properties as units, special values, maximum and minimum valid values, scaling factors, and offsets.
Attributes for a netCDF dataset are defined when the dataset is first created, while the netCDF dataset is in define mode. Additional attributes may be added later by reentering define mode.
A netCDF attribute has a netCDF variable to which it is assigned, a name, a type, a length, and a sequence of one or more values.
An attribute is designated by its variable ID and name. When an attribute name is not known, it may be designated by its variable ID and number in order to determine its name, using the function nc_inq_attname().
The attributes associated with a variable are typically defined immediately after the variable is created, while still in define mode. The data type, length, and value of an attribute may be changed even when in data mode, as long as the changed attribute requires no more space than the attribute as originally defined.
It is also possible to have attributes that are not associated with any variable. These are called global attributes and are identified by using NC_GLOBAL as a variable pseudo-ID. Global attributes are usually related to the netCDF dataset as a whole and may be used for purposes such as providing a title or processing history for a netCDF dataset.
Operations supported on attributes are:
int nc_del_att | ( | int | ncid, |
int | varid, | ||
const char * | name | ||
) |
Delete an attribute.
The function nc_del_att() deletes a netCDF attribute from an open netCDF dataset. The netCDF dataset must be in define mode.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
Here is an example using nc_del_att() to delete the variable attribute Units for a variable rh in an existing netCDF dataset named foo.nc:
int nc_get_att | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
void * | value | ||
) |
Get an attribute of any type.
The nc_get_att() functions works for any type of attribute, and must be used to get attributes of user-defined type. We recommend that they type safe versions of this function be used for atomic data types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. Before using the value as a C string, make sure it is null-terminated. Call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att() from nc_test4/tst_vl.c creates a VLEN attribute, then uses nc_get_att() to read it.
int nc_get_att_double | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
double * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_float | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
float * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_int | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
int * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_long | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
long * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_longlong | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
long long * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_schar | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
signed char * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_short | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
short * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_string | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
char ** | value | ||
) |
Get a variable-length string attribute.
This function gets an attribute from netCDF file. The nc_get_att() function works with any type of data including user defined types, but this function will retrieve attributes which are of type variable-length string.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
int nc_get_att_text | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
char * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_ubyte | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
unsigned char * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_uchar | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
unsigned char * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_uint | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
unsigned int * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_ulonglong | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
unsigned long long * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_get_att_ushort | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
unsigned short * | value | ||
) |
Get an attribute.
This function gets an attribute from the netCDF file. The nc_get_att() function works with any type of data, including user defined types.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute name. |
value | Pointer to location for returned attribute value(s). All elements of the vector of attribute values are returned, so you must allocate enough space to hold them. If you don't know how much space to reserve, call nc_inq_attlen() first to find out the length of the attribute. |
Here is an example using nc_get_att_double() to determine the values of a variable attribute named valid_range for a netCDF variable named rh and using nc_get_att_text() to read a global attribute named title in an existing netCDF dataset named foo.nc.
In this example, it is assumed that we don't know how many values will be returned, but that we do know the types of the attributes. Hence, to allocate enough space to store them, we must first inquire about the length of the attributes.
int nc_inq_att | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type * | xtypep, | ||
size_t * | lenp | ||
) |
Return information about a netCDF attribute.
The function nc_inq_att returns the attribute's type and length.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Pointer to the location for the returned attribute NetCDF Names. Ignored if NULL. |
xtypep | Pointer to location for returned attribute Data Types. Ignored if NULL. |
lenp | Pointer to location for returned number of values currently stored in the attribute. For attributes of type NC_CHAR, you should not assume that this includes a trailing zero byte; it doesn't if the attribute was stored without a trailing zero byte, for example from a FORTRAN program. Before using the value as a C string, make sure it is null-terminated. Ignored if NULL. |
Here is an example using nc_inq_att() to find out the type and length of a variable attribute named valid_range for a netCDF variable named rh and a global attribute named title in an existing netCDF dataset named foo.nc:
int nc_inq_attid | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
int * | idp | ||
) |
Find an attribute ID.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute NetCDF Names. |
idp | Pointer to location for returned attribute number that specifies which attribute this is for this variable (or which global attribute). If you already know the attribute name, knowing its number is not very useful, because accessing information about an attribute requires its name. |
Here is an example using nc_inq_attid() from nc_test4/tst_vars2.c. In this example three attributes are created in a file. Then it is re-opened, and their IDs are checked. They will be 0, 1, and 2, in the order that the attributes were written to the file.
int nc_inq_attlen | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
size_t * | lenp | ||
) |
Find the length of an attribute.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. |
lenp | Pointer to location for returned number of values currently stored in the attribute. Before using the value as a C string, make sure it is null-terminated. Ignored if NULL. |
Here is an example from nc_test4/tst_h_scalar.c which checks the attributes of an already-open netCDF file. In this code, the length of two attributes are checked, and found to be 1.
int nc_inq_attname | ( | int | ncid, |
int | varid, | ||
int | attnum, | ||
char * | name | ||
) |
Find the name of an attribute.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
attnum | Attribute number. The attributes for each variable are numbered from 0 (the first attribute) to natts-1, where natts is the number of attributes for the variable, as returned from a call to nc_inq_varnatts(). |
name | Pointer to the location for the returned attribute NetCDF Names. |
Here is an example from nc_test4/tst_atts3.c a variable of every type is added to a file, with names from the 'names' array. Then the file is re-opened, and the names of the attributes are checked in a for loop.
int nc_inq_atttype | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type * | xtypep | ||
) |
Find the type of an attribute.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. |
xtypep | Pointer to location for returned attribute Data Types. |
Here is an example from nc_test4/tst_h_refs.c. In this example, a file with an integer attribute is open. It's type is confirmed to be NC_INT.
int nc_inq_natts | ( | int | ncid, |
int * | nattsp | ||
) |
Find number of global or group attributes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
nattsp | Pointer where number of global or group attributes will be written. Ignored if NULL. |
Here is an example from
int nc_put_att | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const void * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_double | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const double * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_float | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const float * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_int | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const int * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_long | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const long * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_longlong | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const long long * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_schar | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const signed char * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_short | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const short * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_string | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
size_t | len, | ||
const char ** | value | ||
) |
Write a string attribute.
The function nc_put_att_string adds or changes a variable attribute or global attribute of an open netCDF dataset. The string type is only available in netCDF-4/HDF5 files, when NC_CLASSIC_MODEL has not been used in nc_create().
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
int nc_put_att_text | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
size_t | len, | ||
const char * | value | ||
) |
Write a text attribute.
Add or change a text attribute. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
Use the nc_put_att function to create attributes of any type, including user-defined types. We recommend using the type safe versions of this function whenever possible.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_ubyte | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const unsigned char * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_uchar | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const unsigned char * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_uint | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const unsigned int * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_ulonglong | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const unsigned long long * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_put_att_ushort | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
nc_type | xtype, | ||
size_t | len, | ||
const unsigned short * | value | ||
) |
Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or global attribute of an open netCDF dataset. If this attribute is new, or if the space required to store the attribute is greater than before, the netCDF dataset must be in define mode for classic formats (or netCDF-4/HDF5 with NC_CLASSIC_MODEL).
With netCDF-4 files, nc_put_att will notice if you are writing a _FillValue attribute, and will tell the HDF5 layer to use the specified fill value for that variable. With either classic or netCDF-4 files, a _FillValue attribute will be checked for validity, to make sure it has only one value and that its type matches the type of the associated variable.
Although it's possible to create attributes of all types, text and double attributes are adequate for most purposes.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the variable to which the attribute will be assigned or NC_GLOBAL for a global or group attribute. |
name | Attribute NetCDF Names. Appendix A: Attribute Conventions may apply. |
xtype | Data Types of the attribute. |
len | Number of values provided for the attribute. |
value | Pointer to one or more values. |
Here is an example using nc_put_att_double() to add a variable attribute named valid_range for a netCDF variable named rh and nc_put_att_text() to add a global attribute named title to an existing netCDF dataset named foo.nc:
int nc_rename_att | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
const char * | newname | ||
) |
Rename an attribute.
The function nc_rename_att() changes the name of an attribute. If the new name is longer than the original name, the netCDF dataset must be in define mode. You cannot rename an attribute to have the same name as another attribute of the same variable.
ncid | NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). |
varid | Variable ID of the attribute's variable, or NC_GLOBAL for a global attribute. |
name | Attribute NetCDF Names. |
newname | The new attribute NetCDF Names. |
Here is an example using nc_rename_att() to rename the variable attribute units to Units for a variable rh in an existing netCDF dataset named foo.nc: