Bases: cf.utils.CfDict
Completely describe a field’s coordinate system (space).
It contains the dimension constructs, auxiliary coordinate constructs, cell measure constructs and transform constructs defined by the CF data model.
The space is a dictionary-like object whose key/value pairs identify and store the coordinate and cell measure constructs which describe it.
The dimensionality of the space’s components and its transforms are stored as attributes.
Initialization
The attributes dimension_sizes, dimensions and transforms are automatically initialized.
Parameters : |
|
---|
Return a dictionary whose values are the auxiliary coordinates which span the given dimension and keys of the space’s auxiliary coordinate identifiers.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> s.dimensions
{'data': ['dim0', 'dim1', 'dim2'],
'dim0': ['dim0'],
'dim1': ['dim1'],
'dim2': ['dim2'],
'aux0': ['dim1', 'dim2'],
'aux1': ['dim0'],
'aux2': ['dim2', 'dim1']}
>>> s.aux_coords()
{'aux0': <CF Coordinate: ...>,
'aux1': <CF Coordinate: ...>,
'aux2': <CF Coordinate: ...>}
>>> s.aux_coords('dim2')
{'aux0': <CF Coordinate: ...>,
'aux2': <CF Coordinate: ...>}
Return a dictionary whose values are the cell measures which span the given dimension and keys of the space’s cell measure identifiers.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> s.dimensions
{'data': ['dim0', 'dim1', 'dim2'],
'dim0': ['dim0'],
'dim1': ['dim1'],
'dim2': ['dim2'],
'cm0' : ['dim1', 'dim2'],
'cm1' : ['dim1', 'dim2', 'dim3']}
>>> s.cell_measures()
{'cm0': <CF CellMeasures: ...>,
'cm1': <CF CellMeasures: ...>}
>>> s.cell_measures('dim3')
{'cm1': <CF CellMeasures: ...>}
Find a coordinate of the space by name. Refer to cf.Field.coord for details.
Return a deep copy.
Equivalent to copy.deepcopy(d).
Returns : |
|
---|
Examples
>>> d.copy()
Return True if a dimension is increasing, otherwise return False.
A dimension is considered to be increasing if its dimension coordinate values are increasing in index space or if it has no dimension coordinate.
The direction is taken directly from the appropriate coordinate’s Data object, if available. (This is because we can assume that the space has been finalized.)
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> s.dimension_sizes
{'dim0': 3, 'dim1': 1, 'dim2': 2, 'dim3': 2, 'dim4': 99}
>>> s.dimensions
{'dim0': ['dim0'],
'dim1': ['dim1'],
'aux0': ['dim0'],
'aux1': ['dim2'],
'aux2': ['dim3'],
}
>>> s['dim0'].array
array([ 0 30 60])
>>> s.direction('dim0')
True
>>> s['dim1'].array
array([15])
>>> s['dim1'].bounds.array
array([ 30 0])
>>> s.direction('dim1')
False
>>> s['aux1'].array
array([0, -1])
>>> s.direction('dim2')
True
>>> s['aux2'].array
array(['z' 'a'])
>>> s.direction('dim3')
True
>>> s.direction('dim4')
True
Return a string containing a full description of the space.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> x = s.dump()
>>> print s.dump()
>>> print s.dump(id='space1')
True if two spaces are logically equal, False otherwise.
Equality is defined as follows:
- There is one-to-one correspondence between dimensions and dimension sizes between the two spaces.
- For each space component type (dimension coordinate, auxiliary coordinate and cell measures), the set of constructs in one space equals that of the other space. The component identifiers need not be the same.
- The set of transforms in one space equals that of the other space. The transform identifiers need not be the same.
Equality of numbers is to within a tolerance.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> s.equals(t)
True
Expand the space with a new dimension in place.
The new dimension may by of any size greater then 0.
Parameters : |
|
---|---|
Returns : | None |
Examples
>>> s.expand_dims()
>>> s.expand_dims(size=12)
>>> c
<CF Coordinate: >
>>> s.expand_dims(coord=c)
Return a list of the key names which match a regular expression.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> d.keys()
['dim2', 'dim0', 'dim1', 'aux0', 'cm0']
>>> d.get_keys()
['dim2', 'dim0', 'dim1', 'aux0', 'cm0']
>>> d.get_keys('dim')
['dim2', 'dim0', 'dim1']
>>> d.get_keys('^aux|^dim')
['dim2', 'dim0', 'dim1', 'aux0']
>>> d.get_keys('dim[1-9]')
['dim2', 'dim1']
Insert a new dimension or auxiliary coordinate to the space in place.
Parameters : |
dim_name_map : dict, optional
|
---|---|
Returns : | None |
Examples
>>>
Return a new
Return a new
Return a new
Remove a coordinate from the space in place.
Parameters : |
|
---|---|
Returns : | None |
Examples
>>> s.remove_coordinate('dim0')
>>> s.remove_coordinate('aux1')
Remove a size 1 dimension from the space in place.
If the dimension has a dimension coordinate then it is removed, as are 1-d auxiliary coordinates and cell measures which span the dimension. The dimension is squeezed from multidimensional auxiliary coordinates and cell measures if they span it.
The dimension is not squeezed from the field’s data array if it spans it, therefore the field’s data array may need to be squeezed concurrently.
Parameters : |
|
---|---|
Returns : | None |
Examples
>>> s.dimension_sizes
{'dim0': 12, 'dim1': 73, 'dim2': 1}
>>> s.dimensions
{'data': ['dim0', 'dim1', 'dim2'],
'aux0': ['dim1', 'dim2'],
'aux1': ['dim2', 'dim1'],
'dim0': ['dim0'],
'dim1': ['dim1'],
'dim2': ['dim2'],
'cm0' : ['dim1', 'dim2']}
>>> s.squeeze('dim2')
>>> s.dimension_sizes
{'dim0': 12, 'dim1': 73}
>>> s.dimensions
{'data': ['dim0', 'dim1', 'dim2'],
'aux0': ['dim1'],
'aux1': ['dim1'],
'dim0': ['dim0'],
'dim1': ['dim1'],
'cm0' : ['dim1']}
The sizes of the space’s dimensions.
Examples
>>> s.dimension_sizes
{'dim2': 96,
'dim1': 73,
'dim0': 1}
The dimensions of each of the space’s components and of the its field’s data array.
>>> s.dimensions
{'data': ['dim0', 'dim1', 'dim2'],
'aux0': ['dim1', 'dim2'],
'aux1': ['dim2', 'dim1'],
'dim0': ['dim0'],
'dim1': ['dim1'],
'dim2': ['dim2'],
'cm0' : ['dim1', 'dim2']}
The space’s transform constructs.
>>> s.transforms
{'trans0': <CF Transform: ocean_sigma_z_coordinate>
>>> type(s.transforms)
'cf.utils.CfDict'