smif.convert.register module

Register, ResolutionSet abstract classes to contain metadata and generate conversion coefficients.

NDimensionalRegister is used in smif.convert.interval.IntervalAdaptor and smif.convert.region.RegionAdaptor.

Summary

Data:

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.ResolutionSet[source]

Bases: object

Abstract class which holds the Resolution definitions

as_dict()[source]

Get a serialisable representation of the object

data

Resolution set data

Returns:
Return type:list
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(entry)[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
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
store = None
names
register(resolution_set: smif.convert.register.ResolutionSet)[source]
get_coefficients(source: str, destination: str)[source]
convert(data: <MagicMock id='139764765201024'>, from_set_name: str, to_set_name: str) → <MagicMock id='139764765241696'>[source]

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

Parameters:
Returns:

Return type:

numpy.ndarray

static convert_with_coefficients(data, coefficients: <MagicMock id='139764765257680'>, axis=None) → <MagicMock id='139764765302400'>[source]

Convert an array of data using given coefficients, along a given axis

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: smif.convert.register.ResolutionSet)[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[str]
get_entry(name: str) → smif.convert.register.ResolutionSet[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: str, destination: str) → <MagicMock id='139764765346928'>[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

generate_coefficients(from_set: smif.convert.register.ResolutionSet, to_set: smif.convert.register.ResolutionSet) → <MagicMock id='139764765358880'>[source]

Generate coefficients for converting between two :class:`ResolutionSet`s

Coefficients for converting a single dimension will always be 2D, of shape (len(from_set), len(to_set)).

Parameters:
Returns:

Return type:

numpy.ndarray