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) – Anpnetcdf.Fileinstance to associate with dimension.name (str) – Name of the new dimension.
size (int) – Length of the dimension.
-1means to create the expandable dimension. (Default-1).
- Returns:
The created dimension instance.
- Return type:
Note
Dimensioninstances should be created using theFile.def_dim()method of aFileinstance, not usingDimension.__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.Fileinstance that thisDimensionbelongs to.- Return type:
- isunlimited(self)
- Returns:
Trueif thisDimensioninstance is unlimited,Falseotherwise.- 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