Module netCDF4 :: 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(group, 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 or Group instance, not using this class directly.

Parameters:

group - Group or Dataset instance to associate with variable.

name - Name of the variable.

datatype - Variable data type. If the Variable has one of the primitive data types, datatype is one of 'f4' (32-bit floating point), 'f8' (64-bit floating point), 'i4' (32-bit signed integer), 'i2' (16-bit signed integer), 'i8' (64-bit singed integer), 'i4' (8-bit singed integer), 'i1' (8-bit signed integer), 'u1' (8-bit unsigned integer), 'u2' (16-bit unsigned integer), 'u4' (32-bit unsigned integer), 'u8' (64-bit unsigned integer), 'S1' (single-character string), or 'S' (variable-length string). If the Variable has a user-defined data type (such as 'vlen' or 'compound'), datatype is an instance of the class UserType.

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, usertype, usertype_name, dtype_base, 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
  _get_compound(...)
Private method to retrieve data from a netCDF variable with usertype='compound'
  _get_string(...)
Private method to retrieve data from a netCDF variable with dtype='S'
  _get_vlen(...)
Private method to retrieve data from a netCDF variable with usertype='vlen'
  _put(...)
Private method to put data into a netCDF variable
  _put_string(...)
Private method to put data into a netCDF variable with dtype='S'
  _put_vlen(...)
Private method to put data into a netCDF variable with usertype='vlen'
  _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.
  group(...)
return the group that this Variable is a member of.
  ncattrs(...)
return netCDF attribute names for this Variable in a list

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


Class Variables [hide private]
  _grpid = <member '_grpid' of 'netCDF4.Variable' objects>
  _nunlimdim = <member '_nunlimdim' of 'netCDF4.Variable' objects>
  _varid = <member '_varid' of 'netCDF4.Variable' objects>

Instance Variables [hide private]
  dimensions
A tuple containing the names of the dimensions associated with this variable.
  dtype = <member 'dtype' of 'netCDF4.Variable' objects>
A description of the variable's data type.
  dtype_base = <member 'dtype_base' of 'netCDF4.Variable' objects>
Describes the primitive data type of which the user-defined data type is composed.
  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.
  usertype = <member 'usertype' of 'netCDF4.Variable' objects>
Describes the type of user-defined data type the Variable belongs to (False for a primitive data type, 'vlen' for a variable-length array, 'compound' for compound data type).
  usertype_name = <member 'usertype_name' of 'netCDF4.Variable' objects>
Python string describing the user-defined data type (None is usertype is False).

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

_get_compound(...)

 
Private method to retrieve data from a netCDF variable with usertype='compound'

_get_string(...)

 
Private method to retrieve data from a netCDF variable with dtype='S'

_get_vlen(...)

 
Private method to retrieve data from a netCDF variable with usertype='vlen'

_put(...)

 
Private method to put data into a netCDF variable

_put_string(...)

 
Private method to put data into a netCDF variable with dtype='S'

_put_vlen(...)

 
Private method to put data into a netCDF variable with usertype='vlen'

_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()

group(...)

 

return the group that this Variable is a member of.

group()

ncattrs(...)

 

return netCDF attribute names for this Variable in a list

ncattrs()

Class Variable Details [hide private]

_grpid

None
Value:
<member '_grpid' of 'netCDF4.Variable' objects>                        
      

_nunlimdim

None
Value:
<member '_nunlimdim' of 'netCDF4.Variable' objects>                    
      

_varid

None
Value:
<member '_varid' of 'netCDF4.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. It can either be a string describing one of the primitive data types ('i4','f8','S1', etc), or an instance of the class UserType.
Value:
<member 'dtype' of 'netCDF4.Variable' objects>                         
      

dtype_base

Describes the primitive data type of which the user-defined data type is composed. Only relevant for user-defined data types. For vlens, it is a string describing one of the primitive data types ('i4','f8','S1', etc). For compounds, it is a list of 3-element tuples as is used to describe the dtype of a numpy record array (see the documentation for UserType for details).
Value:
<member 'dtype_base' of 'netCDF4.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.

usertype

Describes the type of user-defined data type the Variable belongs to (False for a primitive data type, 'vlen' for a variable-length array, 'compound' for compound data type).
Value:
<member 'usertype' of 'netCDF4.Variable' objects>                      
      

usertype_name

Python string describing the user-defined data type (None is usertype is False).
Value:
<member 'usertype_name' of 'netCDF4.Variable' objects>