phrosty API¶
phrosty.imagesubtraction¶
- phrosty.imagesubtraction.gz_and_ext(in_path, out_path)[source]¶
- Utility function that unzips the original file and turns
it into a single-extension FITS file.
- Parameters:
in_path (Path) – The input path of the file to unzip and flatten.
out_path (Path) – The desired output path of the file that is unzipped and flattened, once it is saved.
- Returns:
out_path – The output path of the file that has been unzipped and flattened.
- Return type:
Path
- phrosty.imagesubtraction.sky_subtract(inpath, skysubpath, detmaskpath, temp_dir=PosixPath('/tmp'), force=False)[source]¶
Subtracts background, found with Source Extractor.
- Parameters:
inpath (Path) – Original FITS image
skysubpath (Path) – Sky-subtracted FITS image
detmaskpath (Path) – Detection Mask FITS Image. (Will be uint8, I think.)
temp_dir (Path) – Already-existing directory where we can write a temporary file. (If the image is .gz compressed, source-extractor can’t handle that, so we have to write a decompressed version.)
force (bool, default False) – If False, and outpath already exists, do nothing. If True, clobber the existing file and recalculate it.
- Returns:
skyrms – Median of the skyrms image calculated by source-extractor
- Return type:
- phrosty.imagesubtraction.stampmaker(ra, dec, shape, imgpath, savedir=None, savename=None)[source]¶
Make stamps.
- Parameters:
ra (float) – RA of center of stamp in degrees.
dec (float) – Dec of center of stamp in degrees.
shape (np.array) – Shape of stamp. must be a numpy array. e.g. np.array([100,100])
imgpath (Path) – Path to image that stamp will be extracted from.
savedir (Path) – Directory stamp will be saved to.
savename (Path) – Base name of stamp filepath.
- Returns:
savepath – Full savepath of stamp. Combined inputs “savedir/savename”.
- Return type:
Path
phrosty.photometry¶
- phrosty.photometry.ap_phot(scienceimage, coords, ap_r=9, method='subpixel', subpixels=5, merge_tables=True, **kwargs)[source]¶
- Does aperture photometry on the input science image and
specified coordinates.
- Parameters:
scienceimage (array-like) – Array containing science image.
coords (astropy.table.Table) – Table with columns ‘x’ and ‘y’ representing pixel coordinates for the detected sources. Table can contain more than just ‘x’ and ‘y’, and this may be useful if you use merge_tables=True.
ap_r (int, optional) – Aperture radius to use for aperture photometry. Defaults to 3.
method (str, optional) – _description_. Defaults to ‘subpixel’.
subpixels (int, optional) – _description_. Defaults to 5.
merge_tables (boolean, optional) – If true, output is merged coords and results from aperture photometry. Defaults to True.
- Returns:
Table containing results from aperture photometry.
- Return type:
astropy.table.Table
phrosty.pipeline¶
- class phrosty.pipeline.Pipeline(object_id, ra, dec, band, science_images, template_images, nprocs=1, nwrite=5, verbose=False)[source]¶
Phrosty’s top-level pipeline
Create the a pipeline object.
- Parameters:
object_id (int)
ra (float) – Position of transient in decimal degrees
dec (float) – Position of transient in decimal degrees
band (str) – One of R062, Z087, Y106, J129, H158, F184, K213
science_images (list of tuple) – ( path_to_image, pointing, sca )
template_images (list of tuple) – ( path_to_image, pointing, sca )
nprocs (int, default 1) – Number of cpus for the CPU multiprocessing segments of the pipeline. (GPU segments will run a single process.)
nwrite (int, default 5) – Number of asynchronous FITS writer processes.
- align_and_pre_convolve(templ_image, sci_image)[source]¶
Align and pre convolve a single template/science pair.
- Parameters:
sci_image (phrosty.Image) – The science (new) image.
templ_image (phrosty.Image) – The template (ref) image that will be subtracted from sci_image.
- get_stars(truthpath, nx=4088, ny=4088, transform=False, wcs=None)[source]¶
Get the stars in the science images.
Optional to transform to another WCS.
- class phrosty.pipeline.PipelineImage(imagepath, pointing, sca, pipeline)[source]¶
Holds a snappl.image.Image, with some other stuff the pipeline needs.
Create a PipelineImage
Parameters:¶
- imagepathstr or Path
A path to the image. This will be passed on to an Image subclass constructor; which subclass depends on the config option photometry.phrosty.image_type
- pointingstr or int
An identifier of the pointing of this image. Used e.g. to pull PSFs.
- pipelinephrosty.pipeline.Pipeline
The pipeline that owns this image.
phrosty.utils¶
- phrosty.utils.get_corners(path=None, band=None, pointing=None, sca=None)[source]¶
Retrieves the RA, dec of the corners of the specified SCA in degrees.
- phrosty.utils.get_mjd_info(mjd_start=0, mjd_end=numpy.inf, return_inverse=False, obseq_path=None)[source]¶
Get all pointings and corresponding filters between two MJDs.
Returns an astropy table with columns ‘filter’ and ‘pointing’. Does not return an ‘sca’ column because every sca belonging to a given pointing satisfies an MJD requirement.
- Parameters:
mjd_start (float, optional) – Start MJD, defaults to -np.inf
mjd_end (float, optional) – End MJD, defaults to np.inf
return_inverse (bool) – If true, returns all pointings outside the MJD range specified instead of inside.
obseq_path (str, optional) – Path to obseq file Roman_TDS_obseq_11_6_23.fits.
- Returns:
Astropy table with pointing numbers and corresponding filters that satisfy the MJD requirements.
- Return type:
astropy.table.Table
- phrosty.utils.get_mjd_limits(obseq_path=None)[source]¶
Retrive the earliest and latest MJD in the simulations.
- phrosty.utils.get_radec_limits(obseq_path=None)[source]¶
Retrieve RA, dec limits (boresight coordinates).
- phrosty.utils.get_roman_bands()[source]¶
Get roman passbands.
- Returns:
List of bands included in the Roman-DESC TDS simulations. :rtype: list
- phrosty.utils.get_science(oid, band, infodir, returntype='list', verbose=False)[source]¶
Get science images.
Science images are those images for a given OID actually contain the transient and also contain the RA/dec coordinates.
- phrosty.utils.get_templates(oid, band, infodir, n_templates=1, returntype='list', verbose=False)[source]¶
Get template images.
Template images are those images for a given OID do not actually contain the transient but do contain the RA/dec coordinates.
- phrosty.utils.get_transient_info(oid)[source]¶
Retrieve RA, Dec, MJD start, MJD end for specified object ID.
- phrosty.utils.get_transient_mjd(oid)[source]¶
Retrieve start and end dates of a transient based on its object ID.
- phrosty.utils.get_transient_radec(oid)[source]¶
Retrieve RA, dec of a transient based on its object ID.
- phrosty.utils.get_transient_zcmb(oid)[source]¶
Retrieve z_CMB of a transient based on its object ID.
- phrosty.utils.pointings_near_mjd(mjd, window=3, obseq_path=None)[source]¶
Retrieve pointings near given MJD.
- phrosty.utils.read_truth_txt(path=None, band=None, pointing=None, sca=None)[source]¶
Reads in the txt versions of the truth files as convenient astropy tables.
- Parameters:
truthpath (str, optional) – Path to txt catalog version of truth file. If you do not provide this, you need to specify the arguments band, pointing, and sca.
band (str, optional) – Roman filter. If you do not provide this, you need to provide truthpath.
pointing (str, optional) – Pointing ID. If you do not provide this, you need to provide truthpath.
sca (str, optional) – SCA ID. If you do not provide this, you need to provide truthpath.
- Returns:
Astropy table with contents of the specified catalog txt file.
- Return type:
astropy.table.Table
- phrosty.utils.transform_to_wcs(wcs, path=None, band=None, pointing=None, sca=None)[source]¶
“Transform world coordinates in a truth file to a new WCS.
Outputs pixel coordinates for the transformed coordinates. input wcs is an astropy wcs object.
- phrosty.utils.transient_in_or_out(oid, start, end, band)[source]¶
Retrieve pointings that contain and do not contain the specified SN, per the truth files by MJD.
transient_info_filepath is the output of make_object_table.
Returns a tuple of astropy tables (images with the SN, images without the SN).