Module netCDF4_classic :: Class Variable
[hide private]
[frames] | no frames]

Class Variable



object --+
         |
        Variable

A netCDF Variable is used to read and write netCDF data. They are analagous to numpy array objects.

Variable(dataset, name, datatype, dimensions=(), zlib=True, complevel=6, shuffle=True, fletcher32=False, chunking='seq', least_significant_digit=None, fill_value=None)

Variable instances should be created using the createVariable method of a Dataset instance, not using this class directly.

Parameters:

dataset - Dataset instance to associate with variable.

name - Name of the variable.

datatype - Variable data type, one of 'f4' (32-bit floating point), 'f8' (64-bit floating point), 'i4' (32-bit signed integer), 'i2' (16-bit signed integer), 'i4' (8-bit singed integer), 'i1' (8-bit signed integer) or 'S1' (single-character string). The old single character Numeric typecodes ('f','d','c','i','h','b') are also accepted

Keywords:

dimensions - a tuple containing the variable's dimension names (defined previously with createDimension). Default is an empty tuple which means the variable is a scalar (and therefore has no dimensions).

zlib - if True (default), data assigned to the Variable instance is compressed on disk.

complevel - the level of zlib compression to use (1 is the fastest, but poorest compression, 9 is the slowest but best compression). Default 6.

shuffle - if True (default), the HDF5 shuffle filter is applied to improve compression.

fletcher32 - if True (default False), the Fletcher32 checksum algorithm is used for error detection.

chunking - Chunking is required in any dataset with one or more unlimited dimension in HDF5. NetCDF-4 supports setting the chunking algorithm at variable creation. If chunking = 'seq' (default) chunk sizes are set to favor sequential access. Setting chunking = 'sub' will cause chunk sizes to be set to favor subsetting equally in any dimension.

least_significant_digit - If specified, variable data will be truncated (quantized). This produces 'lossy', but significantly more efficient compression. For example, if least_significant_digit=1, data will be quantized using around(scale*data)/scale, where scale = 2**bits, and bits is determined so that a precision of 0.1 is retained (in this case bits=4). Default is None, or no quantization.

fill_value - If specified, the default netCDF _FillValue (the value that the variable gets filled with before any data is written to it) is replaced with this value. If fill_value is set to False, then the variable is not pre-filled.

Returns:

a Variable instance. All further operations on the netCDF Variable are accomplised via Variable instance methods.

A list of attribute names corresponding to netCDF attributes defined for the variable can be obtained with the ncattrs() method. These attributes can be created by assigning to an attribute of the Variable instance. A dictionary containing all the netCDF attribute name/value pairs is provided by the __dict__ attribute of a Variable instance.

The instance variables dimensions, dtype, shape and least_significant_digits are read-only (and should not be modified by the user).

Instance Methods [hide private]
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __delitem__(x, y)
del x[y]
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __getitem__(x, y)
x[y]
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __new__(T, S, ...)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __setitem__(x, i, y)
x[i]=y
  _get(...)
Private method to retrieve data from a netCDF variable
  _getDimensions(...)
Private method to get variables's dimension names
  _put(...)
Private method to put data into a netCDF variable
  _shape(...)
Private method to find current sizes of all variable dimensions
  assignValue(...)
assign a value to a scalar variable.
  getValue(...)
get the value of a scalar variable.
  ncattrs(...)
return names of netCDF attribute for this Variable in a list
  typecode(...)
return dtype attribute, provided for compatibility with Scientific.IO.NetCDF

Inherited from object: __hash__, __reduce__, __reduce_ex__, __repr__, __str__


Class Variables [hide private]
  _dsetid = <member '_dsetid' of 'netCDF4_classic.Variable' obje...
  _varid = <member '_varid' of 'netCDF4_classic.Variable' objects>

Instance Variables [hide private]
  dimensions
A tuple containing the names of the dimensions associated with this variable.
  dtype = <member 'dtype' of 'netCDF4_classic.Variable' objects>
A description of the variable's data type ('i4','f8','S1', etc).
  least_significant_digit
Describes the power of ten of the smallest decimal place in the data the contains a reliable value.
  shape
a tuple describing the current size of all the variable's dimensions.

Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__delattr__(...)

 
x.__delattr__('name') <==> del x.name
Overrides: object.__delattr__

__delitem__(x, y)
(Index deletion operator)

 
del x[y]

__getattribute__(...)

 
x.__getattribute__('name') <==> x.name
Overrides: object.__getattribute__

__getitem__(x, y)
(Indexing operator)

 
x[y]

__init__(...)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__

__new__(T, S, ...)

 
Returns:
a new object with type S, a subtype of T

Overrides: object.__new__

__setattr__(...)

 
x.__setattr__('name', value) <==> x.name = value
Overrides: object.__setattr__

__setitem__(x, i, y)
(Index assignment operator)

 
x[i]=y

_get(...)

 
Private method to retrieve data from a netCDF variable

_getDimensions(...)

 
Private method to get variables's dimension names

_put(...)

 
Private method to put data into a netCDF variable

_shape(...)

 
Private method to find current sizes of all variable dimensions

assignValue(...)

 

assign a value to a scalar variable. Provided for compatibility with Scientific.IO.NetCDF, can also be done by assigning to a slice ([:]).

assignValue(val)

getValue(...)

 

get the value of a scalar variable. Provided for compatibility with Scientific.IO.NetCDF, can also be done by slicing ([:]).

getValue()

ncattrs(...)

 

return names of netCDF attribute for this Variable in a list

ncattrs()

typecode(...)

 
return dtype attribute, provided for compatibility with Scientific.IO.NetCDF

Class Variable Details [hide private]

_dsetid

None
Value:
<member '_dsetid' of 'netCDF4_classic.Variable' objects>               
      

_varid

None
Value:
<member '_varid' of 'netCDF4_classic.Variable' objects>                
      

Instance Variable Details [hide private]

dimensions

A tuple containing the names of the dimensions associated with this variable.

dtype

A description of the variable's data type ('i4','f8','S1', etc).
Value:
<member 'dtype' of 'netCDF4_classic.Variable' objects>                 
      

least_significant_digit

Describes the power of ten of the smallest decimal place in the data the contains a reliable value. Data is truncated to this decimal place when it is assigned to the Variable instance. If None, the data is not truncated.

shape

a tuple describing the current size of all the variable's dimensions.