ResampledLowLevelWCS#
- class ndcube.wcs.wrappers.ResampledLowLevelWCS(wcs, factor, offset=0)[source]#
Bases:
BaseWCSWrapperA wrapper for a low-level WCS object that has down- or up-sampled pixel axes.
- Parameters:
wcs (
BaseLowLevelWCS) – The original WCS for which to reorder axesfactor (
intorfloator iterable of the same) – The factor by which to increase the pixel size for each pixel axis. If a scalar, the same factor is used for all axes.offset (
intorfloator iterable of the same) – The shift of the lower edge of the 0th pixel (i.e. the pixel coordinate -0.5) of the resampled grid relative to the lower edge of the 0th pixel in the original underlying pixel grid, in units of original pixel widths. (See the schematic in the Notes section for a graphical example.) If a scalar, the grid will be shifted by the same amount in all dimensions.
Notes
Below is a schematic of how ResampledLowLevelWCS works. The asterisks show the corners of pixels in a grid before resampling, while the dashes and pipes show the edges of the resampled pixels. The resampling along the x-axis has been performed using a factor of 2 and offset of 1, respectively, while the resampling of the y-axis uses a factor of 3 and offset of 2. The right column and upper row of numbers along the side and bottom of the grids denote the edges and centres of the original pixel grid in the original pixel coordinates. The left column and lower row gives the same locations in the pixel coordinates of the resampled grid. Note that the resampled pixels have an (x, y) shape of (2, 3) relative to the original pixel grid. Also note, the left/lower edge of the 0th pixel in the resampled grid (i.e. pixel coord -0.5) is shifted relative to the left/lower edge of the original 0th pixel, and that shift is given by the offset (+1 in the x-axis and +2 along the y-axis), which is in units of original pixel widths.
resampled original factor=3 offset=2 0.5 4.5 *-----------*-----------*-----------*-----------* | | 2/6 4 | | | | 1/6 3.5 * * * * * | | 0 3 | | | | -1/3 2.5 * * * * * | | -2/6 2 | | | | -0.5 1.5 *-----------*-----------*-----------*-----------* | | -4/6 1 | | | | -5/6 0.5 * * * * * | | -1 0 | | | | -1-1/6 -0.5 * * * * * -0.5 0 0.5 1 1.5 2 2.5 3 3.5 original pixel indices -1 -0.75 -0.5 -0.25 0 0.25 0.5 0.75 1 resampled pixel indices: factor=2, offset=1
Attributes Summary
The bounds (in pixel coordinates) inside which the WCS is defined, as a list with
pixel_n_dim(min, max)tuples.The shape of the data that the WCS applies to as a tuple of length
pixel_n_dimin(x, y)order (where for an image,xis the horizontal coordinate andyis the vertical coordinate).Methods Summary
pixel_to_world_values(*pixel_arrays)Convert pixel coordinates to world coordinates.
world_to_pixel_values(*world_arrays)Convert world coordinates to pixel coordinates.
Attributes Documentation
- pixel_bounds#
- pixel_shape#
Methods Documentation
- pixel_to_world_values(*pixel_arrays)[source]#
Convert pixel coordinates to world coordinates.
This method takes
pixel_n_dimscalars or arrays as input, and pixel coordinates should be zero-based. Returnsworld_n_dimscalars 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 should be returned. The coordinates should be specified in the(x, y)order, where for an image,xis the horizontal coordinate andyis the vertical coordinate.If
world_n_dimis1, this method returns a single scalar or array, otherwise a tuple of scalars or arrays is returned.
- world_to_pixel_values(*world_arrays)[source]#
Convert world coordinates to pixel coordinates.
This method takes
world_n_dimscalars or arrays as input in units given byworld_axis_units. Returnspixel_n_dimscalars 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 should be returned. The coordinates should be returned in the(x, y)order, where for an image,xis the horizontal coordinate andyis the vertical coordinate.If
pixel_n_dimis1, this method returns a single scalar or array, otherwise a tuple of scalars or arrays is returned.