Utils#
- epsf.utils.download_jwst1pass(overwrite=False)[source]#
Download all FITS files from JWST1PASS library
Downloads to EPSF_PATH/jwst1pass if EPSF_PATH env var is set, otherwise to ~/.local/share/epsf/jwst1pass
- Parameters:
overwrite (bool) – If True, use timestamping to update existing files. If False, skip existing files.
- epsf.utils.get_cutout(img, pos, half_size)[source]#
Get a cutout from an image around a given position.
- Parameters:
img (ndarray) – Array to take a cutout from with shape
(Ny, Nx)pos (tuple[int, int]) – indices of the x and y positions around which to take a cutout
half_size (int) – Half-size of the cutout to extract
- Returns:
Returns a copy of the desired cutout from the original image
- Return type:
ndarray
- epsf.utils.get_epsf_data_path()[source]#
Get the EPSF data directory path
Returns EPSF_PATH env var if set, otherwise ~/.local/share/epsf
- Returns:
Path to EPSF data directory
- Return type:
Path
- epsf.utils.get_final_img(img, final_size, pos_int=None)[source]#
Get a cutout with size
final_sizearound a given position in an image. This is very similar toget_cutout().get_cutout()was written to extract a wider array from a full-frame image while this function was written to extract the final, small cutout from a single-PSF image.Concretely, the main differences are that
get_cutout()requires a position and anhalf_size, while here we use the final size of the image and take the middle pixel by default.- Parameters:
img (ndarray) – Array to take a cutout from with shape
(Ny, Nx)final_size (int) – Final size of the cutout, in pixels
pos – indices of the x and y positions around which to take a cutout. Take the central pixel if None. Defaults to None.
pos_int (tuple[int] | None)
- Returns:
Returns a copy of the desired cutout from the original image.
- Return type:
ndarray
- epsf.utils.open_jwst_image(path, pos_cut=None, half_size_cut=None, final_size=None, recenter=True)[source]#
Open a JWST image with uncertainties
- Parameters:
path (Path) – Path to a JWST cal file (output of the stage 2 image pipeline).
pos_cut (tuple[int, int] | None) – Rough position of the target in the full-frame image. Used to center a first cutout.
half_size – Half size of the first cutout taken from the full-frame image in pixels.
final_size (int | None) – Size of the final image to return in pixels.
recenter (bool) – Refine the centroid after the first cutout if True. Uses
photutils.centroids.centroid_quadratic().half_size_cut (int | None)
- Returns:
Science image and associated uncertainties (
SCIandERRextensions).- Return type:
tuple[ndarray, ndarray]
- epsf.utils.radec2seppa(ra, dec)[source]#
Convert RA and Dec to separation and position angle (PA)
PA = 0 is along the Y axis (north) and RA increases to the left (east)
- Parameters:
ra (float | ndarray) – RA in mas
dec (float | ndarray) – Dec in mas
- Returns:
Separation and PA in mas and deg, respectively
- Return type:
tuple[float | ndarray]
- epsf.utils.seppa2radec(sep, pa)[source]#
Convert separation and position angle (PA) to RA and Dec
PA = 0 is along the Y axis (north) and RA increases to the left (east)
- Parameters:
sep (float | ndarray) – Separation in mas
pa (float | ndarray) – Position angle in deg
- Returns:
RA and Dec in mas
- Return type:
tuple[float | ndarray]