WCS¶
-
class
gwcs.wcs.WCS(forward_transform=None, input_frame='detector', output_frame=None, name='')[source]¶ Bases:
gwcs.api.GWCSAPIMixinBasic WCS class.
- Parameters
forward_transform :
Modelor a listThe transform between
input_frameandoutput_frame. A list of (frame, transform) tuples whereframeis the starting frame andtransformis the transform from this frame to the next one oroutput_frame. The last tuple is (transform, None), where None indicates the end of the pipeline.input_frame : str,
CoordinateFrameA coordinates object or a string name.
output_frame : str,
CoordinateFrameA coordinates object or a string name.
name : str
a name for this WCS
Attributes Summary
List all frames in this WCS object.
Return the total backward transform if available - from output to input coordinate system.
Return the range of acceptable values for each input axis.
Return the total forward transform - from input to output coordinate frame.
Return the input coordinate frame.
Return the name for this WCS.
Return the output coordinate frame.
Return the pipeline structure.
The unit of the coordinates in the output coordinate system.
Methods Summary
__call__(*args, **kwargs)Executes the forward transform.
fix_inputs(fixed)Return a new unique WCS by fixing inputs to constant values.
footprint([bounding_box, center, axis_type])Return the footprint in world coordinates.
get_transform(from_frame, to_frame)Return a transform between two coordinate frames.
insert_transform(frame, transform[, after])Insert a transform before (default) or after a coordinate frame.
invert(*args, **kwargs)Invert coordinates.
set_transform(from_frame, to_frame, transform)Set/replace the transform between two coordinate frames.
to_fits_sip([bounding_box, max_pix_error, …])Construct a SIP-based approximation to the WCS in the form of a FITS header
transform(from_frame, to_frame, *args, **kwargs)Transform positions between two frames.
Attributes Documentation
-
available_frames¶ List all frames in this WCS object.
- Returns
available_frames : dict
{frame_name: frame_object or None}
-
backward_transform¶ Return the total backward transform if available - from output to input coordinate system.
- Raises
NotImplementedError :
An analytical inverse does not exist.
-
bounding_box¶ Return the range of acceptable values for each input axis. The order of the axes is
axes_order.
-
forward_transform¶ Return the total forward transform - from input to output coordinate frame.
-
input_frame¶ Return the input coordinate frame.
-
name¶ Return the name for this WCS.
-
output_frame¶ Return the output coordinate frame.
-
pipeline¶ Return the pipeline structure.
-
unit¶ The unit of the coordinates in the output coordinate system.
Methods Documentation
-
__call__(*args, **kwargs)[source]¶ Executes the forward transform.
- argsfloat or array-like
Inputs in the input coordinate system, separate inputs for each dimension.
- with_unitsbool
If
Truereturns aSkyCoordorQuantityobject, by using the units of the output cooridnate frame. Optional, default=False.- with_bounding_boxbool, optional
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_valuefloat, optional
Output value for inputs outside the bounding_box (default is np.nan).
-
fix_inputs(fixed)[source]¶ Return a new unique WCS by fixing inputs to constant values.
- Parameters
fixed : dict
Keyword arguments with fixed values corresponding to
self.selector.- Returns
new_wcs :
WCSA new unique WCS corresponding to the values in
fixed.
Examples
>>> w = WCS(pipeline, selector={"spectral_order": [1, 2]}) >>> new_wcs = w.set_inputs(spectral_order=2) >>> new_wcs.inputs ("x", "y")
-
footprint(bounding_box=None, center=False, axis_type='all')[source]¶ Return the footprint in world coordinates.
- Parameters
bounding_box : tuple of floats: (start, stop)
prop: bounding_boxcenter : bool
If
Trueuse the center of the pixel, otherwise use the corner.axis_type : str
A supported
output_frame.axes_typeor “all” (default). One of [‘spatial’, ‘spectral’, ‘temporal’] or a custom type.- Returns
coord : ndarray
Array of coordinates in the output_frame mapping corners to the output frame. For spatial coordinates the order is clockwise, starting from the bottom left corner.
-
get_transform(from_frame, to_frame)[source]¶ Return a transform between two coordinate frames.
- Parameters
from_frame : str or
CoordinateFrameInitial coordinate frame name of object.
to_frame : str, or instance of
CoordinateFrameEnd coordinate frame name or object.
- Returns
transform :
ModelTransform between two frames.
-
insert_transform(frame, transform, after=False)[source]¶ Insert a transform before (default) or after a coordinate frame.
Append (or prepend) a transform to the transform connected to frame.
- Parameters
frame : str or
CoordinateFrameCoordinate frame which sets the point of insertion.
transform :
ModelNew transform to be inserted in the pipeline
after : bool
If True, the new transform is inserted in the pipeline immediately after
frame.
-
invert(*args, **kwargs)[source]¶ Invert coordinates.
The analytical inverse of the forward transform is used, if available. If not an iterative method is used.
- Parameters
args : float, array like,
SkyCoordorUnitcoordinates to be inverted
kwargs : dict
keyword arguments to be passed to the iterative invert method.
with_bounding_box : bool, optional
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, optional
Output value for inputs outside the bounding_box (default is np.nan).
-
set_transform(from_frame, to_frame, transform)[source]¶ Set/replace the transform between two coordinate frames.
- Parameters
from_frame : str or
CoordinateFrameInitial coordinate frame.
to_frame : str, or instance of
CoordinateFrameEnd coordinate frame.
transform :
ModelTransform between
from_frameandto_frame.
-
to_fits_sip(bounding_box=None, max_pix_error=0.25, degree=None, max_inv_pix_error=0.25, inv_degree=None, npoints=32, verbose=False)[source]¶ Construct a SIP-based approximation to the WCS in the form of a FITS header
This assumes a tangent projection.
The default mode in using this attempts to achieve roughly 0.25 pixel accuracy over the whole image.
- Parameters
bounding_box : tuple, optional
A pair of tuples, each consisting of two numbers Represents the range of pixel values in both dimensions ((xmin, xmax), (ymin, ymax))
max_pix_error : float, optional
Maximum allowed error over the domain of the pixel array. This error is the equivalent pixel error that corresponds to the maximum error in the output coordinate resulting from the fit based on a nominal plate scale.
degree : int, optional
Degree of the SIP polynomial. If supplied, max_pixel_error is ignored.
max_inv_error : float, optional
Maximum allowed inverse error over the domain of the pixel array in pixel units. If None, no inverse is generated.
inv_degree : int, optional
Degree of the inverse SIP polynomial. If supplied max_inv_pixel_error is ignored.
npoints : int, optional
The number of points in each dimension to sample the bounding box for use in the SIP fit.
verbose : bool, optional
print progress of fits
- Returns
FITS header with all SIP WCS keywords
- Raises
ValueError
If the WCS is not 2D, an exception will be raised. If the specified accuracy (both forward and inverse, both rms and maximum) is not achieved an exception will be raised.
Notes
Use of this requires a judicious choice of required accuracies. Attempts to use higher degrees (~7 or higher) will typically fail due floating point problems that arise with high powers.
-
transform(from_frame, to_frame, *args, **kwargs)[source]¶ Transform positions between two frames.
- Parameters
from_frame : str or
CoordinateFrameInitial coordinate frame.
to_frame : str, or instance of
CoordinateFrameCoordinate frame into which to transform.
args : float or array-like
Inputs in
from_frame, separate inputs for each dimension.output_with_units : bool
If
True- returns aSkyCoordorQuantityobject.with_bounding_box : bool, optional
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, optional
Output value for inputs outside the bounding_box (default is np.nan).