Bases: cf.field.Variable
A CF coordinate object.
Refer to the Variable and Field classes and the cf package for details.
Reserved public attributes:
In addition to the reserved public attributes inherited from the Variable class, the following are also reserved public attributes:
Attribute | Description |
---|---|
axis | As in the CF convention. |
positive | As in the CF convention. |
Reserved attributes:
In addition to the reserved attributes inherited from the Variable class, the following attributes have special definitions and it is recommended to set them accordingly.
Attribute | Description |
---|---|
bounds | The coordinate’s CoordinateBounds object. |
climatology | An indicator to specify if the coordinate’s bounds are intervals of climatological time. |
transform | A pointer to the coordinate’s Transform object. |
The coordinate’s Units object.
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,)
The coordinate’s CF axis public attribute.
The coordinate’s bounds object.
The variable’s CF calendar public attribute.
x.calendar=value <==> x.setpub(‘calendar’, value) x.calendar <==> x.getpub(‘calendar’) del x.calendar <==> x.delpub(‘calendar’) x.calendar=value <==> x.Units.calendar=value x.calendar <==> x.Units.calendar del x.calendar <==> del x.Units.calendar
Indicator of whether the coordinate’s bounds represent climatologocal time intervals.
Return a deep copy.
Parameters: | data (bool) – Optional. If False then assign the output variable’s data elements to None, with the expectation that they will be replaced subsequently. The data object’s metadata are deep copied in any case. |
---|---|
Returns: | A deep copy. |
Delete a private attribute.
Parameters: | attr (str) – The name of the private attribute to be deleted. |
---|---|
Returns: | None |
Delete a public attribute.
Parameters: | attr (str) – The name of the public attribute to be deleted. |
---|---|
Returns: | None |
Data-type of the data’s elements.
Returns: | A numpy dtype object. |
---|
Return a string containing a full description of the coordinate.
Parameters: |
|
---|---|
Returns: | A string containing the description of the coordinate. |
See also
Return the variable if and only if it matches conditions on its phenomena, i.e. its public attributes and, if it has any, its scalar or 1-d, size 1 coordinates. As extract, but with the restriction that only exact public attribute or coordinate names are allowed.
names, either a public attribute names or 1-d, size 1 coorinate standard names.
The keyword values are as for match.
Returns: | The variable if the it matches the criteria, otherwise a ValueError is raised. |
---|
Determine whether or not a variable matches conditions on its phenomena, i.e. its public attributes and, if it has any, its scalar or 1-d, size 1 coordinates. As match, but with the restriction that only exact public attribute or coordinate names are allowed.
Parameters: | **kwargs – The keyword arguments identify exact phenomenon names, either a public attribute names or 1-d, size 1 coorinate standard names. The keyword values are as for match. |
---|---|
Returns: | True if the variable matches the criteria, False otherwise. |
Examples:
>>> s
<CF Field: air_temperature(19, 30, 24)>
>>> s.standard_name
'air_temperature'
>>> s.extract(standard_name = 'air_temperature')
True
>>> s.extract(standard_n = '^air.*')
False
Return True if the variable is congruent to another variable in that
- They have identical data. Pointers to data on disk may be converted to numpy arrays in memory if required.
- They have identical reserved public attributes.
- They have identical public attributes.
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 + 1
>>> x.equals(y)
False
>>> y -= 1
>>> x.equals(y)
True
>>> x.setpub('name', 'name0')
>>> y.setpub('name', 'name1')
>>> x.equals(y)
False
Return the variable if and only if it matches conditions on its phenomena, i.e. its public attributes and, if it has any, its scalar or 1-d, size 1 coordinates. Unambiguous abbreviations of public attribute or coordinate names are allowed.
Refer to match for further details.
name or a coordinate’s standard name. Any unambiguous abbreviation of the phenomenon’s name is acceptable.
The keyword values are as for match.
Returns: | The variable if the it matches the criteria, otherwise a ValueError is raised. |
---|
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 a private attribute.
Parameters: |
|
---|---|
Returns: | The value of a private attribute. |
Return a public attribute.
Parameters: |
|
---|---|
Returns: | The value of a public attribute. |
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. |
---|
The variable’s CF long_name public attribute.
The variable’s CF long_name public attribute.
mask coordinate data
Determine whether or not a variable matches conditions on its phenomena, i.e. its public attributes and, if it has any, its scalar or 1-d, size 1 coordinates. Unambiguous abbreviations of public attribute or coordinate names are allowed.
The phenomena and their conditions are specified with **kwargs parameters.
The variable matches the conditions if and only if it contains all of the specified phenomena and they satisfy all of their given criteria. A variable always matches no criteria.
Parameters: | **kwargs – The keyword arguments identify a public attribute’s name or a coordinate’s standard name. Any unambiguous abbreviation of the phenomenon’s name is acceptable. A keyword’s value may be one of the following:
|
---|---|
Returns: | True if the variable matches the criteria, False otherwise. |
Examples:
>>> s
<CF Field: air_temperature(19, 30, 24)>
>>> s.pub('standard_name'), s.pub('units')
('air_temperature', 'K')
>>> 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(height = 2.0, units = 'K')
True
The variable’s CF missing_value public attribute.
Assigning a value to this attribute also assigns the same value to the _FillValue public attribute, if the latter has previously been defined.
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. |
Number of data dimensions.
Equivalent to the number of elements in shape tuple.
Returns: | A non-negative integer |
---|
Change the variable’s units in place without changing the variable’s data.
Parameters: | units (Units) – The new units as a Units object. |
---|---|
Returns: | None |
Examples:
>>> v.Units
<CF Units: metre>
>>> v.varray
array([ 0., 1., 2., 3., 4.])
>>> v.override_Units(cf.Units('km'))
>>> v.Units
<CF Units: km>
>>> v.varray
array([ 0., 1., 2., 3., 4.])
The coordinate’s CF positive public attribute.
A method which may be used in place of getpriv or setpriv.
If called with positional parameters, then they are interpreted as for getpriv and a public attribute (or default) value is returned.
If called with a keyword parameter, then the keyword and its value act as the two positional parameters of setpriv and a public attribute is set.
Return a dictionary of the instance’s private attributes.
A method which may be used in place of getpub or setpub.
If called with positional parameters, then they are interpreted as for getpub and a public attribute (or default) value is returned.
If called with a keyword parameter, then the keyword and its value act as the two positional parameters of setpub and a public attribute is set.
Examples:
>>> v.pub(units='K')
>>> v.pub('units')
'K'
>>> v.pub('UNITS', 'default_value')
'default_value'
Return a dictionary of the instance’s public attributes.
Set a private attribute.
Parameters: |
|
---|---|
Returns: | None |
Set a public attribute.
Parameters: |
|
---|---|
Returns: | None |
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 |
---|
Slice the coordinate’s data, returning a new coordinate. The coordinate’ bounds are also sliced.
Examples:
>>> c
<CF Coordinate: longitude(96)>
>>> c.bounds
<CF CoordinateBounds: longitude(96,2)>
>>> d=c.slice[1:]
>>> d
<CF Coordinate: longitude(95)>
>>> d.bounds
<CF CoordinateBounds: longitude(95,2)>
The variable’s CF standard_name public attribute.
Pointer to coordinate’s transfrom.
The types of the data stored in the variable’s Data object.
Returns: | A list of type objects for each of the data elements. Examples: |
---|
>>> v.type()
[<type 'netCDF4.Variable'>]
>>> v.slice[...]
>>> v.type()
[<type 'numpy.ndarray'>]
The coordinate’s units public attribute.
x.units=value <==> x.setpub(‘units’, value) x.units <==> x.getpub(‘units’) del x.units <==> x.delpub(‘units’) x.units=value <==> x.Units.units=value x.units <==> x.Units.units del x.units <==> del x.Units.units
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])