smif.convert.register module

Register, NDimensionalRegister and ResolutionSet abstract classes to contain area, interval and unit metadata.

Implemented by smif.convert.interval.TimeIntervalRegister, smif.convert.area.RegionRegister and smif.convert.unit.UnitRegister.

Summary

Classes:

LogMixin
NDimensionalRegister Abstract class which holds N-Dimensional ResolutionSets
Register Abstract class which holds the ResolutionSets
ResolutionSet Abstract class which holds the Resolution definitions

Reference

class smif.convert.register.LogMixin[source]

Bases: object

logger
class smif.convert.register.Register(axis=None)[source]

Bases: smif.convert.register.LogMixin

Abstract class which holds the ResolutionSets

Parameters:axis (int, default=None) – The axis over which operations on the data array are performed
data_interface = None
names
register(resolution_set)[source]
get_coefficients(source, destination)[source]
convert(data, from_set_name, to_set_name)[source]

Convert a list of data points for a given set to another set

Parameters:
Returns:

Return type:

numpy.ndarray

class smif.convert.register.NDimensionalRegister(axis=None)[source]

Bases: smif.convert.register.Register

Abstract class which holds N-Dimensional ResolutionSets

Parameters:axis (int, default=None) – The axis over which operations on the data array are performed
register(resolution_set)[source]

Add a ResolutionSet to the register

Parameters:resolution_set (smif.convert.ResolutionSet) –
Raises:ValueError – If a ResolutionSet of the same name already exists in the register
names

Names of registered region sets

Returns:sets
Return type:list of str
get_entry(name)[source]

Returns the ResolutionSet of name

Parameters:name (str) – The unique identifier of a ResolutionSet in the register
Returns:
Return type:smif.convert.ResolutionSet
get_coefficients(source, destination)[source]

Get coefficients representing intersection of sets

Parameters:
  • source (string) – The name of the source set
  • destination (string) – The name of the destination set
Returns:

Return type:

numpy.ndarray

class smif.convert.register.ResolutionSet[source]

Bases: object

Abstract class which holds the Resolution definitions

as_dict()[source]

Get a serialisable representation of the object

get_entry_names()[source]

Get the names of the entries in the ResolutionSet

Returns:The set of names which identify each entry in the ResolutionSet
Return type:set
intersection(bounds)[source]

Return the subset of entries intersecting with the bounds

get_proportion(entry_a, entry_b)[source]

Calculate the proportion of entry_a and entry_b

Parameters:
  • entry_a (string) – Name of an entry in ResolutionSet
  • entry_b (string) – Name of an entry in ResolutionSet
Returns:

The proportion of entry_a and entry_b

Return type:

float

coverage
static get_bounds()[source]

Implement this helper method to return bounds from an entry in the register

Parameters:entry – An entry from a ResolutionSet
Returns:The bounds of the entry
Return type:bounds