BaseLowLevelWCS#
- class astropy.wcs.wcsapi.BaseLowLevelWCS[source]#
Bases:
object
Abstract base class for the low-level WCS interface.
This is described in APE 14: A shared Python interface for World Coordinate Systems.
Attributes Summary
The shape of the data that the WCS applies to as a tuple of length
pixel_n_dim
in(row, column)
order (the convention for arrays in Python).Returns an (
world_n_dim
,pixel_n_dim
) matrix that indicates using booleans whether a given world coordinate depends on a given pixel coordinate.An iterable of strings describing the name for each pixel axis.
The bounds (in pixel coordinates) inside which the WCS is defined, as a list with
pixel_n_dim
(min, max)
tuples.The number of axes in the pixel coordinate system.
The shape of the data that the WCS applies to as a tuple of length
pixel_n_dim
in(x, y)
order (where for an image,x
is the horizontal coordinate andy
is the vertical coordinate).Indicates whether Python objects are given in serialized form or as actual Python objects.
An iterable of strings describing the name for each world axis.
A dictionary giving information on constructing high-level objects for the world coordinates.
A list with
world_n_dim
elements giving information on constructing high-level objects for the world coordinates.An iterable of strings describing the physical type for each world axis.
An iterable of strings given the units of the world coordinates for each axis.
The number of axes in the world coordinate system.
Methods Summary
array_index_to_world_values
(*index_arrays)Convert array indices to world coordinates.
pixel_to_world_values
(*pixel_arrays)Convert pixel coordinates to world coordinates.
world_to_array_index_values
(*world_arrays)Convert world coordinates to array indices.
world_to_pixel_values
(*world_arrays)Convert world coordinates to pixel coordinates.
Attributes Documentation
- array_shape#
The shape of the data that the WCS applies to as a tuple of length
pixel_n_dim
in(row, column)
order (the convention for arrays in Python).If the WCS is valid in the context of a dataset with a particular shape, then this property can be used to store the shape of the data. This can be used for example if implementing slicing of WCS objects. This is an optional property, and it should return
None
if a shape is not known or relevant.
- axis_correlation_matrix#
Returns an (
world_n_dim
,pixel_n_dim
) matrix that indicates using booleans whether a given world coordinate depends on a given pixel coordinate.This defaults to a matrix where all elements are
True
in the absence of any further information. For completely independent axes, the diagonal would beTrue
and all other entriesFalse
.
- pixel_axis_names#
An iterable of strings describing the name for each pixel axis.
If an axis does not have a name, an empty string should be returned (this is the default behavior for all axes if a subclass does not override this property). Note that these names are just for display purposes and are not standardized.
- pixel_bounds#
The bounds (in pixel coordinates) inside which the WCS is defined, as a list with
pixel_n_dim
(min, max)
tuples.The bounds should be given in
[(xmin, xmax), (ymin, ymax)]
order. WCS solutions are sometimes only guaranteed to be accurate within a certain range of pixel values, for example when defining a WCS that includes fitted distortions. This is an optional property, and it should returnNone
if a shape is not known or relevant.
- pixel_n_dim#
The number of axes in the pixel coordinate system.
- pixel_shape#
The shape of the data that the WCS applies to as a tuple of length
pixel_n_dim
in(x, y)
order (where for an image,x
is the horizontal coordinate andy
is the vertical coordinate).If the WCS is valid in the context of a dataset with a particular shape, then this property can be used to store the shape of the data. This can be used for example if implementing slicing of WCS objects. This is an optional property, and it should return
None
if a shape is not known or relevant.If you are interested in getting a shape that is comparable to that of a Numpy array, you should use
array_shape
instead.
- serialized_classes#
Indicates whether Python objects are given in serialized form or as actual Python objects.
- world_axis_names#
An iterable of strings describing the name for each world axis.
If an axis does not have a name, an empty string should be returned (this is the default behavior for all axes if a subclass does not override this property). Note that these names are just for display purposes and are not standardized. For standardized axis types, see
world_axis_physical_types
.
- world_axis_object_classes#
A dictionary giving information on constructing high-level objects for the world coordinates.
Each key of the dictionary is a string key from
world_axis_object_components
, and each value is a tuple with three elements or four elements:The first element of the tuple must be a class or a string specifying the fully-qualified name of a class, which will specify the actual Python object to be created.
The second element, should be a tuple specifying the positional arguments required to initialize the class. If
world_axis_object_components
specifies that the world coordinates should be passed as a positional argument, this this tuple should includeNone
placeholders for the world coordinates.The third tuple element must be a dictionary with the keyword arguments required to initialize the class.
Optionally, for advanced use cases, the fourth element (if present) should be a callable Python object that gets called instead of the class and gets passed the positional and keyword arguments. It should return an object of the type of the first element in the tuple.
Note that we don’t require the classes to be Astropy classes since there is no guarantee that Astropy will have all the classes to represent all kinds of world coordinates. Furthermore, we recommend that the output be kept as human-readable as possible.
The classes used here should have the ability to do conversions by passing an instance as the first argument to the same class with different arguments (e.g.
Time(Time(...), scale='tai')
). This is a requirement for the implementation of the high-level interface.The second and third tuple elements for each value of this dictionary can in turn contain either instances of classes, or if necessary can contain serialized versions that should take the same form as the main classes described above (a tuple with three elements with the fully qualified name of the class, then the positional arguments and the keyword arguments). For low-level API objects implemented in Python, we recommend simply returning the actual objects (not the serialized form) for optimal performance. Implementations should either always or never use serialized classes to represent Python objects, and should indicate which of these they follow using the
serialized_classes
attribute.See the document APE 14: A shared Python interface for World Coordinate Systems for examples .
- world_axis_object_components#
A list with
world_n_dim
elements giving information on constructing high-level objects for the world coordinates.Each element of the list is a tuple with three items:
The first is a name for the world object this world array corresponds to, which must match the string names used in
world_axis_object_classes
. Note that names might appear twice because two world arrays might correspond to a single world object (e.g. a celestial coordinate might have both “ra” and “dec” arrays, which correspond to a single sky coordinate object).The second element is either a string keyword argument name or a positional index for the corresponding class from
world_axis_object_classes
.The third argument is a string giving the name of the property to access on the corresponding class from
world_axis_object_classes
in order to get numerical values. Alternatively, this argument can be a callable Python object that takes a high-level coordinate object and returns the numerical values suitable for passing to the low-level WCS transformation methods.
See the document APE 14: A shared Python interface for World Coordinate Systems for examples.
- world_axis_physical_types#
An iterable of strings describing the physical type for each world axis.
These should be names from the VO UCD1+ controlled Vocabulary (http://www.ivoa.net/documents/latest/UCDlist.html). If no matching UCD type exists, this can instead be
"custom:xxx"
, wherexxx
is an arbitrary string. Alternatively, if the physical type is unknown/undefined, an element can beNone
.
- world_axis_units#
An iterable of strings given the units of the world coordinates for each axis.
The strings should follow the IVOA VOUnit standard (though as noted in the VOUnit specification document, units that do not follow this standard are still allowed, but just not recommended).
- world_n_dim#
The number of axes in the world coordinate system.
Methods Documentation
- array_index_to_world_values(*index_arrays)[source]#
Convert array indices to world coordinates.
This is the same as
pixel_to_world_values
except that the indices should be given in(i, j)
order, where for an imagei
is the row andj
is the column (i.e. the opposite order topixel_to_world_values
).If
world_n_dim
is1
, this method returns a single scalar or array, otherwise a tuple of scalars or arrays is returned.
- abstract pixel_to_world_values(*pixel_arrays)[source]#
Convert pixel coordinates to world coordinates.
This method takes
pixel_n_dim
scalars or arrays as input, and pixel coordinates should be zero-based. Returnsworld_n_dim
scalars or arrays in units given byworld_axis_units
. Note that pixel coordinates are assumed to be 0 at the center of the first pixel in each dimension. If a pixel is in a region where the WCS is not defined, NaN can be returned. The coordinates should be specified in the(x, y)
order, where for an image,x
is the horizontal coordinate andy
is the vertical coordinate.If
world_n_dim
is1
, this method returns a single scalar or array, otherwise a tuple of scalars or arrays is returned.
- world_to_array_index_values(*world_arrays)[source]#
Convert world coordinates to array indices.
This is the same as
world_to_pixel_values
except that the indices should be returned in(i, j)
order, where for an imagei
is the row andj
is the column (i.e. the opposite order topixel_to_world_values
). The indices should be returned as rounded integers.If
pixel_n_dim
is1
, this method returns a single scalar or array, otherwise a tuple of scalars or arrays is returned.
- abstract world_to_pixel_values(*world_arrays)[source]#
Convert world coordinates to pixel coordinates.
This method takes
world_n_dim
scalars or arrays as input in units given byworld_axis_units
. Returnspixel_n_dim
scalars or arrays. Note that pixel coordinates are assumed to be 0 at the center of the first pixel in each dimension. If a world coordinate does not have a matching pixel coordinate, NaN can be returned. The coordinates should be returned in the(x, y)
order, where for an image,x
is the horizontal coordinate andy
is the vertical coordinate.If
pixel_n_dim
is1
, this method returns a single scalar or array, otherwise a tuple of scalars or arrays is returned.