gwcs.api.NativeAPIMixin

class gwcs.api.NativeAPIMixin

Bases: ABC

A mix-in class that is intended to be inherited by the WCS class and provides the native GWCS API.

Attributes

bounding_box

The input_frame's bounding box

forward_transform

The forward transformation model from the input_frame to the output_frame.

input_frame

The input coordinate frame.

output_frame

The output coordinate frame.

abstract property NativeAPIMixin.bounding_box: ModelBoundingBox | CompoundBoundingBox | None

The input_frame’s bounding box

abstract property NativeAPIMixin.forward_transform: Model

The forward transformation model from the input_frame to the output_frame.

abstract property NativeAPIMixin.input_frame: CoordinateFrameProtocol

The input coordinate frame.

abstract property NativeAPIMixin.output_frame: CoordinateFrameProtocol

The output coordinate frame.

Methods

evaluate(*args[, with_bounding_box, fill_value])

Executes the forward transform.

invert(*args[, with_bounding_box, fill_value])

Invert coordinates from output frame to input frame using analytical or user-supplied inverse.

abstractmethod NativeAPIMixin.evaluate(*args, with_bounding_box=True, fill_value=nan, **kwargs)

Executes the forward transform.

Parameters:
  • args (ndarray[tuple[int, ...], dtype[TypeVar(Dtype, bound= generic)]] | Quantity) – Inputs in the input coordinate system, separate inputs for each dimension.

  • with_bounding_box (bool, default: True) – If True(default) values in the result which correspond to any of the inputs being outside the bounding_box are set to fill_value.

  • fill_value (float | number, default: nan) – Output value for inputs outside the bounding_box (default is np.nan).

  • kwargs (dict) – Keyword arguments to be passed to the forward_transform model.

Return type:

tuple[ndarray[tuple[int, ...], dtype[TypeVar(Dtype, bound= generic)]] | Quantity, ...] | ndarray[tuple[int, ...], dtype[TypeVar(Dtype, bound= generic)]] | Quantity

abstractmethod NativeAPIMixin.invert(*args, with_bounding_box=True, fill_value=nan, **kwargs)

Invert coordinates from output frame to input frame using analytical or user-supplied inverse. When neither analytical nor user-supplied inverses are defined, a numerical solution will be attempted using a numerical inverse algorithm.

Note

Currently numerical inverse is implemented only for 2D imaging WCS.

Parameters:
  • args (ndarray[tuple[int, ...], dtype[TypeVar(Dtype, bound= generic)]] | Quantity) – Coordinates to be inverted. The number of arguments must be equal to the number of world coordinates given by world_n_dim.

  • with_bounding_box (bool, default: True) – If True (default) values in the result which correspond to any of the inputs being outside the bounding_box are set to fill_value.

  • fill_value (float | number, default: nan) – Output value for inputs outside the bounding_box (default is np.nan).

  • kwargs (dict) – Keyword arguments to be passed to the backward_transform model (when defined) or to the iterative invert method.

Returns:

result – Returns a tuple of scalar or array values for each axis. Unless input_frame.naxes == 1 when it shall return the value. The return type will be Quantity objects if the transform returns Quantity objects, else values.

Return type:

tuple[ndarray[tuple[int, ...], dtype[TypeVar(Dtype, bound= generic)]] | Quantity, ...] | ndarray[tuple[int, ...], dtype[TypeVar(Dtype, bound= generic)]] | Quantity