listpixels¶
- astroimtools.utils.listpixels(data, position, shape, subarray_indices=False, wcs=None)[source]¶
Return a
Tablelisting the(y, x)positions anddatavalues for a subarray.Given a position of the center of the subarray, with respect to the large array, the array indices and values are returned. This function takes care of the correct behavior at the boundaries, where the small array is appropriately trimmed.
- Parameters:
- dataarray-like
The input data.
- positiontuple (int) or
SkyCoord The position of the subarray center with respect to the data array. The position can be specified either as an integer
(y, x)tuple of pixel coordinates or aSkyCoord, in which casewcsis a required input.- shapetuple (int)
The integer shape (
(ny, nx)) of the subarray.- subarray_indicesbool, optional
If
Truethen the returned positions are relative to the small subarray. IfFalse(default) then the returned positions are relative to thedataarray.- wcs
WCS, optional The WCS transformation to use if
positionis aSkyCoord.
- Returns:
- table
Table A table containing the
xandypositions and data values.
- table
Notes
This function is decorated with
support_nddataand thus supportsNDDataobjects as input.Examples
>>> import numpy as np >>> from astroimtools import listpixels >>> np.random.seed(12345) >>> data = np.random.random((25, 25)) >>> tbl = listpixels(data, (8, 11), (3, 3)) >>> for col in tbl.colnames: ... tbl[col].info.format = '%.8g' # for consistent table output >>> tbl.pprint(max_lines=-1) x y value --- --- ----------- 10 7 0.75857204 11 7 0.069529666 12 7 0.70547344 10 8 0.8406625 11 8 0.46931469 12 8 0.56264343 10 9 0.034131584 11 9 0.23049655 12 9 0.22835371