Utilities API¶
This page documents the shared utility helpers used throughout the package.
identical_units ¶
Check whether two units are exactly identical.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u1
|
str or `~astropy.units.UnitBase`
|
First unit specification. |
required |
u2
|
str or `~astropy.units.UnitBase`
|
Second unit specification. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
calc_pixel_area ¶
Calculate the projected area of one image pixel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header
|
`~astropy.io.fits.Header`
|
FITS header describing a celestial image. |
required |
Returns:
| Type | Description |
|---|---|
`~astropy.units.Quantity`
|
Pixel area returned by the WCS projection. |
calc_pixel_per_beam ¶
Calculate the number of pixels per synthesized beam.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header
|
`~astropy.io.fits.Header`
|
FITS header describing a radio image. |
required |
suppress_no_beam_error
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
float or None
|
Number of pixels per beam, or |
Raises:
| Type | Description |
|---|---|
NoBeamException
|
Raised when beam information is missing and
|
nanaverage ¶
Compute a weighted average while ignoring NaN values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
array_like
|
Array containing data to be averaged. |
required |
**kwargs
|
Any
|
Additional keyword arguments passed to |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray or scalar
|
Weighted average along the requested axis. |
nanrms ¶
Compute a weighted root-mean-square while ignoring NaN values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
array_like
|
Array containing data to be summarized. |
required |
**kwargs
|
Any
|
Additional keyword arguments passed to |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray or scalar
|
Root-mean-square along the requested axis. |
reduce_image_input ¶
Normalize image inputs to data, header, and WCS objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str, bytes, path-like, `~astropy.io.fits.HDUList`, FITS HDU,
|
or ndarray Image source to normalize. |
required |
ihdu
|
int
|
HDU index to use when |
0
|
header
|
`~astropy.io.fits.Header`
|
FITS header describing the array when |
None
|
suppress_error
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
data |
ndarray or None
|
Image data array. |
hdr |
`~astropy.io.fits.Header` or None
|
Header associated with the image data. |
wcs |
`~astropy.wcs.WCS` or None
|
Celestial WCS built from |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when the input image cannot be found, is not two-dimensional, has inconsistent dimensions, or does not use celestial RA/Dec axes. |
deproject ¶
deproject(center_coord=None, incl=0 * u.deg, pa=0 * u.deg, header=None, wcs=None, naxis=None, ra=None, dec=None, return_offset=False)
Calculate deprojected coordinates from sky coordinates.
This function deals with sky images of astronomical objects with
an intrinsic disk geometry. Given disk center coordinates,
inclination, and position angle, it calculates the deprojected
coordinates in the disk plane (radius and azimuthal angle) from
(1) a FITS header (header), or
(2) a WCS object with specified axis sizes (wcs + naxis), or
(3) RA and DEC coodinates (ra + dec).
Note that the deprojected azimuthal angle is defined w.r.t. the
line of nodes (given by the position angle). For (1) and (2), the
outputs are 2D images; for (3), the outputs are arrays with shapes
matching the broadcasted shape of ra and dec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_coord
|
`~astropy.coordinates.SkyCoord` or 2-tuple
|
Sky coordinates of the disk center. |
None
|
incl
|
number or `~astropy.units.Quantity`
|
Disk inclination angle. Zero degrees corresponds to a face-on disk. |
0 * deg
|
pa
|
number or `~astropy.units.Quantity`
|
Disk position angle for the receding major axis, measured from north through east. |
0 * deg
|
header
|
`~astropy.io.fits.Header`
|
FITS header specifying the WCS and output map shape. |
None
|
wcs
|
`~astropy.wcs.WCS`
|
WCS of the output maps when |
None
|
naxis
|
sequence of int
|
Two-element map shape associated with |
None
|
ra
|
array_like or `~astropy.units.Quantity`
|
Right ascension values to deproject when working from explicit coordinates instead of a WCS description. |
None
|
dec
|
array_like or `~astropy.units.Quantity`
|
Declination values to deproject when working from explicit coordinates instead of a WCS description. |
None
|
return_offset
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
deprojected_coordinates |
tuple of ndarray
|
Returns |
Notes
This is the Python version of an IDL function deproject included
in the cpropstoo package. See URL below:
https://github.com/akleroy/cpropstoo/blob/master/cubes/deproject.pro