smif.metadata module

Encapsulates the input or output parameters of a sector model, for example:

- name: petrol_price
  spatial_resolution: GB
  temporal_resolution: annual
  units: £/l
- name: diesel_price
  spatial_resolution: GB
  temporal_resolution: annual
  units: £/l
- name: LPG_price
  spatial_resolution: GB
  temporal_resolution: annual
  units: £/l

Summary

Classes:

Metadata All metadata about a single dataset, typically model input or output
MetadataSet A container for metadata about model inputs or outputs

Reference

class smif.metadata.Metadata(name, spatial_resolution, temporal_resolution, units)[source]

Bases: object

All metadata about a single dataset, typically model input or output

Parameters:
  • name (str) – The dataset name
  • spatial_resolution (smif.convert.region.RegionSet) – The region set that defines the spatial resolution
  • temporal_resolution (smif.convert.interval.IntervalSet) – The interval set that defines the temporal resolution
  • units (str) – Name of the units for the dataset values
as_dict()[source]
normalise_unit(unit_string, param_name)[source]

Parse unit and return standard string representation

get_region_names()[source]

The list of region names for this spatial resolution

get_interval_names()[source]

The list of interval names for this temporal resolution

class smif.metadata.MetadataSet(metadata_list=None)[source]

Bases: collections.abc.Mapping

A container for metadata about model inputs or outputs

Parameters:metadata (list) –

A list of dicts like

{
    'name': 'heat_demand'
    'spatial_resolution': smif.convert.ResolutionSet
    'temporal_resolution': smif.convert.ResolutionSet
    'units': 'kW'
}

Or, a list of smif.metadata.Metadata

Metadata(‘heat_demand’,
smif.convert.area.RegionSet, smif.convert.interval.IntervalSet, ‘kW’)
metadata

A list of the model parameters

Returns:parameters – A list of smif.Metadata, sorted by name
Return type:list
add_metadata(item)[source]

Add an item to the set

Parameters:item (Metadata or dict) – Metadata object or dictionary with keys ‘name’, ‘spatial_resolution’, ‘temporal_resolution’ and ‘units’
get_spatial_res(name)[source]

The spatial resolution for parameter name

Parameters:name (str) – The name of a model parameter
get_temporal_res(name)[source]

The temporal resolution for parameter name

Parameters:name (str) – The name of a model parameter
get_units(name)[source]

The units used for parameter ‘name’

Parameters:name (str) – The name of a model parameter
spatial_resolutions

A list of the spatial resolutions

Returns:A list of the spatial resolutions associated with the model parameters
Return type:list
temporal_resolutions

A list of the temporal resolutions

Returns:A list of the temporal resolutions associated with the model parameters
Return type:list
names

A list of the parameter names

units

A list of the units

Returns:A list of the units associated with the model parameters
Return type:list