NCDF_PUT

The NCDF_PUT routine writes variables and attributes to a NetCDF file.

This routine is written in the IDL language. Its source code can be found in the file NCDF_PUT.pro in the lib subdirectory of the IDL distribution.

Examples

In this example, we create a NetCDF file and then list the contents:

gatt = {lon:'27.2 W', lat:'13.1 N', hgt:'3.8 km'}

var = {azi:'283.4 deg',alt:'-8.9 deg',fl:'300 mm', $

img:BYTARR(640,480),time:SYSTIME()}

NCDF_PUT, 'image.nc', /NEW, VARIABLES=var, GATT=gatt

NCDF_LIST, 'image.nc', /VARIABLES, /GATT, /VATT

IDL prints:

image.nc

# dimensions: 6

# Variables: 5

# Global attributes: 3

There are no unlimited dimensions.

 

Global Attributes

0 lat: 13.1 N

1 hgt: 3.8 km

2 lon: 27.2 W

 

Variables and attributes

0 azi: CHAR(9) = CHAR(azi_dim1)

1 alt: CHAR(8) = CHAR(alt_dim1)

2 fl: CHAR(6) = CHAR(fl_dim1)

3 time: CHAR(24) = CHAR(time_dim1)

4 img: BYTE(640,480) = BYTE(img_dim1,img_dim2)

 

Syntax

NCDF_PUT, filename, /DETAILS, ERROR=variable, ERR_TXT=variable, GATT=value, /NEW, VARIABLES=value, /VERBOSE

Arguments

FILENAME

An input string giving the name of the NetCDF file.

Keywords

DETAILS

Set this keyword to print out documentation for this routine.

ERROR

Set this keyword to a named variable in which the NetCDF error code will be returned if an error occurs. ERROR=0 indicates no errors.

ERR_TXT

Set this keyword to a named variable in which the NetCDF error message will be returned if an error occurs. An empty string indicates no errors.

GATT

Set this keyword to an IDL hash or structure containing the NetCDF global attributes. The GATT value should have the form:

HASH(attr1, value1, attr2, value2, ...)

or

{attr1:value1, attr2:value2, ...}

Note: If GATT is supplied as an IDL structure, then the attributes are all added with lowercase names. For control over the case, use a hash instead.

NEW

Set this keyword to start a new NetCDF file if the file already exists. If the file does not exist then this keyword is ignored.

VARIABLES

Set this keyword to an IDL hash or structure containing the NetCDF variables. The VARIABLES value should have the form:

HASH(name1, value1, name2, value2, ...)

or

{name1:value1, name2:value2, ...}

The value may be just the simple value itself if dimensions or attributes are not needed. If you do need dimensions or attributes, then you should supply the value as a hash or structure with the following keys/fields:

Note: "dim_names", "dim_sizes", and "attributes" are optional. If dimension names are not given the names will default to "name1_dim1", "name1_dim2", etc. If dimensions are not given the dimensions will be set from the array size. If the value is a scalar the dimension info is not needed and is ignored.

Note: If VARIABLES is supplied as an IDL structure, then the variables are all added with lowercase names. For control over the case use a hash instead.

VERBOSE

Set this keyword to print out informational messages.

Version History

8.4.1

Introduced

See Also

NCDF_GET, NCDF_LIST