LabelMapperArray¶
- class gwcs.selector.LabelMapperArray(mapper, inputs_mapping=None, name=None, **kwargs)[source]¶
Bases:
_LabelMapper
Maps array locations to labels.
- Parameters:
- mapperndarray
An array of integers or strings where the values correspond to a label in
RegionsSelector
model. For pixels for which the transform is not defined the value should be set to 0 or “ “.- inputs_mapping
Mapping
An optional Mapping model to be prepended to the LabelMapper with the purpose to filter the inputs or change their order so that the output of it is (x, y) values to index the array.
- namestr
The name of this transform.
- Use case:
- For an IFU observation, the array represents the detector and its
- values correspond to the IFU slice label.
Attributes Summary
Methods Summary
__call__
(*inputs[, model_set_axis, ...])Evaluate this model using the given input(s) and the parameter values that were specified when the model was instantiated.
evaluate
(*args)Evaluate the model on some input variables.
from_vertices
(shape, regions)Create a
LabelMapperArray
from polygon vertices stores in a dict.Attributes Documentation
- fittable = False¶
- linear = False¶
- n_inputs = 2¶
- n_outputs = 1¶
Methods Documentation
- __call__(*inputs, model_set_axis=None, with_bounding_box=False, fill_value=nan, equivalencies=None, inputs_map=None, **new_inputs)¶
Evaluate this model using the given input(s) and the parameter values that were specified when the model was instantiated.
- classmethod from_vertices(shape, regions)[source]¶
Create a
LabelMapperArray
from polygon vertices stores in a dict.- Parameters:
- shapetuple
shape of mapper array
- regions: dict
{region_label : list_of_polygon_vertices} The keys in this dictionary should match the region labels in
RegionsSelector
. The list of vertices is ordered in such a way that when traversed in a counterclockwise direction, the enclosed area is the polygon. The last vertex must coincide with the first vertex, minimum 4 vertices are needed to define a triangle.
- Returns:
- mapper
LabelMapperArray
This models is used with
RegionsSelector
. A model which takes the same inputs asRegionsSelector
and returns a label.
- mapper
Examples
>>> regions = {1: [[795, 970], [2047, 970], [2047, 999], [795, 999], [795, 970]], ... 2: [[844, 1067], [2047, 1067], [2047, 1113], [844, 1113], [844, 1067]], ... 3: [[654, 1029], [2047, 1029], [2047, 1078], [654, 1078], [654, 1029]], ... 4: [[772, 990], [2047, 990], [2047, 1042], [772, 1042], [772, 990]] ... } >>> mapper = LabelMapperArray.from_vertices((2400, 2400), regions)