gwcs.selector

The classes in this module create discontinuous transforms.

The main class is RegionsSelector. It maps inputs to transforms and evaluates the transforms on the corresponding inputs. Regions are well defined spaces in the same frame as the inputs. Regions are assigned unique labels (int or str). The region labels are used as a proxy between inputs and transforms. An example is the location of IFU slices in the detector frame.

RegionsSelector uses two structures:
  • A mapping of inputs to labels - “label_mapper”

  • A mapping of labels to transforms - “transform_selector”

A “label_mapper” is also a transform, a subclass of astropy.modeling.Model, which returns the labels corresponding to the inputs.

An instance of a LabelMapper class is passed to RegionsSelector. The labels are used by RegionsSelector to match inputs to transforms. Finally, RegionsSelector evaluates the transforms on the corresponding inputs. Label mappers and transforms take the same inputs as RegionsSelector. The inputs should be filtered appropriately using the inputs_mapping argument which is ian instance of Mapping. The transforms in “transform_selector” should have the same number of inputs and outputs.

This is illustrated below using two regions, labeled 1 and 2

digraph regions { node [shape=box, style=filled, fillcolor=lightyellow, fontname="Helvetica", margin="0.3,0.3"]; subgraph cluster_detector { label="Detector"; style=filled; color=lightgray; fontname="Helvetica"; region1 [label="1", shape=box, height=2, width=1]; region2 [label="2", shape=box, height=1, width=1]; {rank=same; region1 region2} } }

+-----------+
| +-+       |
| | |  +-+  |
| |1|  |2|  |
| | |  +-+  |
| +-+       |
+-----------+

Label mapper workflow:

digraph selector_workflow { splines="ortho" node [shape=box, style=filled, fillcolor=lightblue, fontname="Arial", margin="0.3,0.3"]; // Nodes in [shape=point, width=0, height=0]; inputs [label="inputs", fillcolor=lightgreen]; label_mapper [label="label mapper"]; label [label="label"]; transform_selector [label="transform_selector"]; transform [label="transform"]; outputs [label="outputs", fillcolor=lightgreen]; // Invisible nodes for alignment invisible1 [style=invis, shape=point]; invisible2 [style=invis, shape=point]; // Main flow in ->inputs -> transform -> outputs; inputs -> invisible1 [style=invis]; inputs -> label_mapper [constraint=false]; label_mapper -> label; label -> transform_selector; transform_selector -> transform; invisible2 -> transform [style=invis]; // Layout adjustments {rank=same; label_mapper; invisible1;} {rank=same; transform_selector; invisible2;} }

                   +--------------+
                   | label mapper |
                   +--------------+
                     ^       |
                     |       V
           ----------|   +-------+
           |             | label |
         +--------+      +-------+
--->     | inputs |          |
         +--------+          V
              |          +--------------------+
              |          | transform_selector |
              |          +--------------------+
              V                  |
         +-----------+           |
         | transform |<-----------
         +------------+
              |
              V
         +---------+
         | outputs |
         +---------+

The base class _LabelMapper can be subclassed to create other label mappers.

Classes

LabelMapper(inputs, mapper[, no_label, ...])

Maps inputs to regions.

LabelMapperArray(mapper[, inputs_mapping, ...])

Maps array locations to labels.

LabelMapperDict(inputs, mapper[, ...])

Maps a number to a transform, which when evaluated returns a label.

LabelMapperRange(inputs, mapper[, ...])

The structure this class uses maps a range of values to a transform.

RegionsSelector(inputs, outputs, selector, ...)

This model defines discontinuous transforms.

Inheritance diagram of gwcs.selector.LabelMapper, gwcs.selector.LabelMapperArray, gwcs.selector.LabelMapperDict, gwcs.selector.LabelMapperRange, gwcs.selector.RegionsSelector