Dimensions

Class Dimension is used to define the shape of NetCDF variables. In NetCDF, a variable, an instance of pnetcdf.Variable, is a multi-dimensional array. Methods in pnetcdf.Dimension provide an interface to access dimensions objects stored in the file.

class pnetcdf.Dimension

Bases: object

__init__(self, File file, name, size=-1, **kwargs)

The constructor for pnetcdf.Dimension.

Parameters:
  • file (pnetcdf.File) – An pnetcdf.File instance to associate with dimension.

  • name (str) – Name of the new dimension.

  • size (int) – Length of the dimension. -1 means to create the expandable dimension. (Default -1).

Returns:

The created dimension instance.

Return type:

pnetcdf.Dimension

Note

Dimension instances should be created using the File.def_dim() method of a File instance, not using Dimension.__init__() directly.

Example:

A example is available in examples/put_var.py

# Define dimensions
dim_t = f.def_dim('time', size = -1)
dim_y = f.def_dim("Y",    size = 100)
dim_x = f.def_dim("X",    size = 200)
getfile(self)
Returns:

the pnetcdf.File instance that this Dimension belongs to.

Return type:

pnetcdf.File

isunlimited(self)
Returns:

True if this Dimension instance is unlimited, False otherwise.

Return type:

bool

Read-only python fields of class pnetcdf.Dimension

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

name

String name of Dimension instance. This class field is read-only and should not be modified by the user. To rename a dimension, use File.rename_dim() method.

Type: str

size

The current size of Dimension (its value can be obtained by calling python function len() on the Dimension instance).

Type: int