Bases: cf.space.Variable
A CF cell measures object.
Refer to Variable for all details.
Parameters: | **kwargs – Optional. refer to Variable |
---|
Overloaded operators
Refer to Variable.
Methods
Refer to Variable.
Create a numpy array deep copy of the data.
If the data was stored as a file pointer then it will be changed in-place to be stored as a numpy array.
Returns: | A numpy array. |
---|
Examples
>>> a = x.array
>>> type(a)
<type 'numpy.ndarray'>
>>> a = x.array[[0,1]]
>>> type(a)
<type 'numpy.ndarray'>
>>> a.shape
(2,)
Create a deep copy of the variable, but with shallow copies of selected attributes.
If a deep copy of a variable’s attribute raises an exception then a shallow copy is attempted. If the shallow copy also raises an exception then the variable’s attribute is assigned to the returned copy.
In particular, netCDF4.Variable instances are copied by assignment.
Parameters: |
|
---|---|
Returns: | A deep copy of the variable with the exceptions of those attributes given by the shallow argument. |
Data-type of the data’s elements.
Returns: | A numpy dtype object. |
---|
Return a string containing a full description of the variable.
Parameters: |
|
---|---|
Returns: | A string containing the description of the variable. |
See also
Return True if the variable is congruent to another variable in that they have identical data, property names (as returned by the properties() method) and corresponding property values.
Equality of numbers is to within a tolerance. Refer to cf for details.
Parameters: |
|
---|---|
Returns: | True if the two objects are congruent, False otherwise. |
Examples
>>> y = x
>>> x.equals(y)
True
>>> y =x()
>>> y[...] = y.varray + 1
>>> x.equals(y)
False
>>> y[...] = y.varray - 1
>>> x.equals(y)
True
>>> y.standard_name += '_different'
>>> x.equals(y)
False
Determine whether or not the variable matches conditions on its phenomena.
The variable’s phenomena are its attributes and, if it has any, its size 1 coordinates.
The phenomenon and its conditions are specified with **kwargs parameters.
The variable matches the conditions if and only if it contains all of the specified phenomena and they pass all of their given criteria. A variable always matches no criteria.
Parameters: |
|
---|---|
Returns: | True if the variable matches the criteria, False otherwise. |
Examples
>>> S
<CF Space: air_temperature(19, 30, 24)>
>>> s.standard_name
'air_temperature'
>>> s.extract(standard_name = 'air_temperature')
True
>>> s.extract(standard = '^air.*')
True
>>> s.extract(standard_name = lt('b'))
True
>>> s.extract(standard_name = outside('b', 'p'))
True
>>> s.extract(standard = ['.*temp.*', 'pressure'])
True
>>> s.extract(exact=True, standard_name = 'air_temperature')
True
>>> s.extract(exact=True, standard_ = 'air_temperature')
False
>>> s.extract(standard = ['temp', 'pressure'])
False
>>> s.extract(standard_name = inside('o', 'p'))
False
Return the first element of the data without replacing a file pointer with a numpy array.
Returns: | The scalar value of the first element of the data. |
---|
Return the last element of the data without replacing a file pointer with a numpy array.
Returns: | The scalar value of the last element of the data. |
---|
Return the standard_name attribute of the variable.
If there is no standard_name attribute then return one of the long_name attribute, the ncvar attribute or the value of the default parameter, depending on the values of the parameters.
Parameters: |
|
---|---|
Returns: | The name of the variable. |
Return a set of attributes which are netCDF attributes suitable for writing to a netCDF file.
All writable attributes are considered netCDF attributes except those starting with an underscore, (with the exception of ‘_FillValue’) and those starting with “nc”.
To create an attribute which will not be in the set of netCDF attributes, assign directly to the __dict__ dictionary as opposed to using setattr.
Returns: | A set of attributes which are netCDF attributes. |
---|
Number of data dimensions.
Equivalent to the number of elements in shape tuple.
Returns: | A non-negative integer |
---|
Return a set of writable, public attribute names, excluding methods.
An attribute created by assigning directly to the __dict__ dictionary (as opposed to using setattr()) will not appear in this set.
Parameters: | nc (bool) – If False then exclude attributes whose names begin “nc”. |
---|---|
Returns: | A set of attribute names. |
Reset the data to a file pointer if one is available, regardless of of whether the data is currently stored as a numpy array or not.
This may free memory, but any changes to data stored as a numpy array will be lost.
Parameters: | test (bool) – Optional. If True then do not reinstate a file pointer if it exists. |
---|---|
Returns: | True if a file pointer exists, False otherwise. |
Tuple of the data’s dimension sizes.
Returns: | A tuple |
---|
Number of elements in the data.
Equivalent to the product of the data’s dimension sizes.
Returns: | A non-negative integer |
---|
The type of the data object.
Returns: | A type object, or None if the variable has no data. |
---|
Create a numpy view of the data.
If the data was stored as a file pointer then it will be changed in-place to be stored as a numpy array.
Note that making changes to elements of the returned view changes the underlying data. Refer to numpy.ndarray.view().
Returns: | A numpy view. |
---|
Examples
>>> a = x.varray
>>> print a
array([0, 1, 2, 3, 4])
>>> a[0] = 999
>>> print x.varray[0]
999
>>> a = 'a_different_object'
>>> print x.varray
array([999, 1, 2, 3, 4])