gwcs.wcs.Pipeline

class gwcs.wcs.Pipeline(forward_transform, *, input_frame=None, output_frame=None)

Bases: _BasePipeline

Class to handle a sequence of WCS transformations.

This is intended to act like a list of steps, but with built in protections for things like duplicate frames. In addition, this handles all the logic for handling steps and their frames/transforms.

This class is intended to be an organizational class for the WCS which handles the sequence of steps and their transforms. It is not intended to be used directly by outside users, but rather through the WCS class, which subclasses this class and adds the additional evaluation functionality and user interface for the WCS.

Warning

This class supports passing any _BasePipeline subclass as the forward_transform argument. In this case, no validation checks or copies of the steps are made. This means that when the forward_transform is a type of _BasePipeline, the user is responsible for ensuring that the pipeline is valid. Moreover, since no copies of the steps are made, any changes made to the steps contained within the resulting instance will back-propagate to the original _BasePipeline subclass instance. This behavior is intended to allow for the efficient creation of pipelines (or WCSs) from existing pipelines (or WCSs) without the expensive overhead of validation and copies.

Parameters:

Attributes

available_frames

List of all the frame names in this WCS in their order in the pipeline

backward_transform

Return the total backward transform if available - from output to input coordinate system.

bounding_box

Return the bounding box of the pipeline.

forward_transform

Return the forward transform of the pipeline.

input_frame

Return the input frame name of the pipeline.

output_frame

Return the output frame name of the pipeline.

pipeline

Allow direct access to the raw pipeline steps.

unit

The unit of the coordinates in the output coordinate system.

property Pipeline.available_frames: list[str]

List of all the frame names in this WCS in their order in the pipeline

property Pipeline.backward_transform: Model

Return the total backward transform if available - from output to input coordinate system.

Raises:

NotImplementedError – An analytical inverse does not exist.

property Pipeline.bounding_box: ModelBoundingBox | CompoundBoundingBox | None

Return the bounding box of the pipeline.

property Pipeline.forward_transform: Model

Return the forward transform of the pipeline.

property Pipeline.input_frame: CoordinateFrameProtocol

Return the input frame name of the pipeline.

property Pipeline.output_frame: CoordinateFrameProtocol

Return the output frame name of the pipeline.

property Pipeline.pipeline: list[Step]

Allow direct access to the raw pipeline steps.

property Pipeline.unit: tuple[Unit | None, ...] | None

The unit of the coordinates in the output coordinate system.

Methods

attach_compound_bounding_box(cbbox, ...)

Attach a compound bounding box dictionary to the pipeline.

get_frame(frame)

Return the frame object corresponding to the given frame name.

get_transform(from_frame, to_frame)

Return a transform between two coordinate frames.

insert_frame(input_frame, transform, ...)

Insert a new frame into an existing pipeline.

insert_transform(frame, transform[, after])

Insert a transform before (default) or after a coordinate frame.

pipeline_between(from_frame, to_frame)

Return a pipeline between the two given frames.

set_transform(from_frame, to_frame, transform)

Set/replace the transform between two coordinate frames.

Pipeline.attach_compound_bounding_box(cbbox, selector_args)

Attach a compound bounding box dictionary to the pipeline.

Parameters:
  • cbbox (dict[tuple[str, ...], tuple]) –

    Dictionary of the bounding box tuples (F order) for each input set

    keys: selector argument values: bounding box tuple in F order

  • selector_args (tuple[str, ...]) – Argument names to the model that are used to select the bounding box

Return type:

None

Pipeline.get_frame(frame)

Return the frame object corresponding to the given frame name.

Parameters:

frame (str | CoordinateFrameProtocol) – Name of the frame or the frame object.

Returns:

The frame object corresponding to the given name.

Return type:

CoordinateFrameProtocol

Pipeline.get_transform(from_frame, to_frame)

Return a transform between two coordinate frames.

Parameters:
Returns:

Transform between two frames.

Return type:

Mdl

Pipeline.insert_frame(input_frame, transform, output_frame)

Insert a new frame into an existing pipeline. This frame must be anchored to a frame already in the pipeline by a transform. This existing frame is identified solely by its name, although an entire CoordinateFrameProtocol can be passed (e.g., the input_frame or output_frame attribute). This frame is never modified.

Parameters:
Return type:

None

Pipeline.insert_transform(frame, transform, after=False)

Insert a transform before (default) or after a coordinate frame.

Append (or prepend) a transform to the transform connected to frame.

Parameters:
  • frame (str | CoordinateFrameProtocol) – Coordinate frame which sets the point of insertion.

  • transform (Model) – New transform to be inserted in the pipeline

  • after (bool, default: False) – If True, the new transform is inserted in the pipeline immediately after frame.

Return type:

None

Pipeline.pipeline_between(from_frame, to_frame)

Return a pipeline between the two given frames.

Parameters:
Returns:

A DirectionalWCS (wcs, forward) where wcs is of the type of the calling object. The forward attribute indicates if the wcs/pipeline between the two frames is forward (True, from_frame -> to_frame) or backward (False, to_frame -> from_frame). Note that if from_frame and to_frame are the same, then None is returned.

Return type:

Optional[DirectionalWCS[Self]]

Pipeline.set_transform(from_frame, to_frame, transform)

Set/replace the transform between two coordinate frames.

Parameters:
Return type:

None