smif.metadata.coordinates module¶
Each dimension of a multi-dimensional dataset can be indexed by a set of coordinates.
Dimensions might be represented as Euclidean coordinates over a grid:
>>> x = Coordinates('x', range(0, 100))
>>> y = Coordinates('y', range(0, 100))
A subset of Local Authority Districts in England would be a region-based spatial dimension:
>>> local_authority_districts = Coordinates('LADs', ['E07000128', 'E07000180'])
The hours of an average annual day would be a temporal dimension:
>>> hours = Coordinates('daily_hours', [
... {'name': 0, 'interval': [['PT0H', 'PT1H']]}
... {'name': 1, 'interval': [['PT1H', 'PT2H']]}
... {'name': 2, 'interval': [['PT2H', 'PT3H']]}
... ])
The economic sectors from the International Standard Industrial Classification of All Economic Activities (ISIC), revision 4 would be a categorical dimension:
>>> economic_sector = Coordinates('ISICrev4', [
... {'name': 'A', 'desc': 'Agriculture, forestry and fishing'},
... {'name': 'B', 'desc': 'Mining and quarrying'},
... {'name': 'C', 'desc': 'Manufacturing'},
... {'name': 'D', 'desc': 'Electricity, gas, steam and air conditioning supply'}
... ])
Summary¶
Data:
Coordinates |
Coordinates provide the labels to index a dimension, along with metadata that may be useful to describe, visualise or convert between dimensions. |
Reference¶
-
class
smif.metadata.coordinates.
Coordinates
(name, elements)[source]¶ Bases:
object
Coordinates provide the labels to index a dimension, along with metadata that may be useful to describe, visualise or convert between dimensions.
Coordinate element names are used to label each position along a finite dimension.
A dict mapping dimension name to list of coordinate elements can be passed to a
Spec
(orxarray.DataArray
) as coords.Parameters: Raises: ValueError
– If the list of elements is empty, or infiniteKeyError
– If the elements are not a list of simple data types or a list of dicts with a ‘name’ key
-
elements
Elements are a list of dicts with at least a ‘name’ key
Coordinate elements should not be changed.
-
ids
Element ids is a list of coordinate identifiers
-
names
¶ Names is an alias for Coordinates.ids
-
dim
Dim (dimension) is an alias for Coordinates.name