Variables

Variable is a core component of a netCDF file representing an array of data values organized along one or more dimensions, with associated metadata in the form of attributes. An instance of class pnetcdf.Variable represents a NetCDF variable stored in the file. The class methods provide I/O operations to read and write the data and metadata of a NetCDF variable.

Reading and writing a subarray of a variable can be done through either explicit function-call style methods or Python indexer-style (numpy-like) syntax.

Read-only python fields of class pnetcdf.Variable

The following class fields are read-only and should not be modified directly by the user.

name

The string name of Variable instance

Type: str

dtype

A numpy data type of the variable.

Type: numpy.dtype

datatype

Same as Variable.dtype().

Type: numpy.dtype

shape

The shape of the variable, which is the current sizes of all variable dimensions

Type: tuple of ints

ndim

The number of variable dimensions.

Type: int

size

Return the number of stored elements

Type: int

dimensions

Return the variable’s dimension names

Type: list of str

chartostring

If True, data is automatically converted to/from character arrays to string arrays when the _Encoding variable attribute is set. Default is True, can be reset using Variable.set_auto_chartostring() method.

Type: bool