adler.utilities.cutout_utilities

Attributes

CALIB_DICT

Classes

Cutout

Class to retrieve the cutout for a given source, defined by either diaSourceId or SourceId.

Module Contents

CALIB_DICT[source]
class Cutout(Id=None, IdTable='DiaSource', ra=None, dec=None, visit=None, detector=None, radius=0.01 * u.deg, calib_level=[3], dataset='dp1', outdir='.', outfile=None, cutout_service='cutout-sync-exposure')[source]

Class to retrieve the cutout for a given source, defined by either diaSourceId or SourceId. The additional data required to retrieve the unique image containing the source (visit, detector, calib_level) can be passed or will be queried on initialisation. Likewise the source’s ra and dec required for defining the cutout centre can be passed or will otherwise be queried. NB a source Id is not required if all other unique image data is provided.

Id[source]

Identifier value for the source

Type:

int

IdTable[source]

The table from which the source is queried, e.g. DiaSource or Source. We assume the Id column name is IdTable+”Id”.

Type:

str

ra[source]
Type:

float

dec[source]
Type:

float

visit[source]
Type:

int

detector[source]
Type:

int

radius[source]

Angular radius of cutout image (astropy angular units), NB that the query will return the largest square cutout that fits with the radius

Type:

Quantity

calib_lev

List of what type of images to retrieve: 1,2,3 - raw, visit, diff. NB, this arg will accept a single int

Type:

list(int)

dataset[source]

Name of the RSP dataset to query for image information and data

Type:

str

outdir[source]

Where to save the cutout images, will be created if it does not exist. Set to None to save no images

Type:

str

outfile[source]

Specify a specific filename for the output, otherwise a default will be used

Type:

str

cutout_servcie

Define the pyvo cutout service to be used. Default is “cutout-sync-exposure” which returns the full ExposureF object. Use “cutout-sync”/”cutout-sync-maskedimage” to return a smaller FITS file

Type:

str

Id = None[source]
IdTable = 'DiaSource'[source]
ra = None[source]
dec = None[source]
visit = None[source]
detector = None[source]
radius[source]
calib_level = [3][source]
dataset = 'dp1'[source]
outdir = '.'[source]
outfile = None[source]
cutout_service = 'cutout-sync-exposure'[source]
IdCol = 'DiaSourceId'[source]
service_tap[source]
service_sia[source]
InitFromDict(alert_dict)[source]

Set up a new Cutout object from a dictionary, i.e. an alert packet. One could do Cutout(**co_dict) however any additional columns will cause an error. This function removes any dict keys that do not correspond to a Cutout attribute.

Parameters:

alert_dict (dict) – Dictionary containing the Cutout parameters, and possibly others

Returns:

co – The new Cutout class object

Return type:

object

query_from_Id()[source]

Get all the unique image metadata required to identify which image contains a given source.

Returns:

df_img – DataFrame of the unique image metadata, this should only be 1 row in length

Return type:

pd.DataFrame

query_image_url()[source]

Query the image URL location

Returns:

df_visit – DataFrame with URL links to the image locations on RSP, one row for each calibration level

Return type:

pd.DataFrame

getSodaCutoutMem(url, cal_lev, cutout_service='cutout-sync-exposure')[source]

Retrieve a given image using soda and return it as an lsst.afw.fits MemFileManager object. The MemFileManager object can subsequently be converted into lsst.afw.image ExposureF or FITS. Credit: Rubin Community Science Team tutorial notebook https://dp1.lsst.io/tutorials/notebook/103/notebook-103-4.html

Parameters:
  • url (str) – URL location of image to be retrieved

  • cal_lev (int) – Calibration level of image to retrieve: 1,2,3 - raw, visit, diff

  • cutout_service (str) – Define the cutout service to be used: cutout-sync-exposure: return the full cutout (all planes and metadata). Can be converted to ExposureF. cutout-sync: return only the image pixels and header. Cannot be converted to ExposureF (save as FITS). cutout-sync-maskedimage: return image pixels, header, and masks. Cannot be converted to ExposureF (save as FITS).

Returns:

  • sq (SodaQuery) – SodaQuery result for the cutout query

  • mem (MemFileManager) – The cutout data

sodaCutout(small_fits=True)[source]

Get the image using soda and save it as a fits file. Credit: Rubin Community Science Team tutorial notebook https://dp1.lsst.io/tutorials/notebook/103/notebook-103-4.html

Parameters:

small_fits (Bool) – Flag to save only the image component of the ExposureF object to FITS file (set False to save full ExposureF to FITS file)

plot_img(cal_lev, plot_fits=True, ihdu=0, plot_wcs=False, plot_r=50, wcs_reproj=False, shape_reproj=False)[source]

Plot the cutout image using pyplot. This plot will compare the lsst ExposureF WCS to the FITS approximation if plot_fits=False. Use the arguments wcs_reproj and shape_reproj to reproject the image to a specific wcs and shape (e.g. get North up and East pointing left). NB beware of flux conservation when reprojecting Find the best wcs and shape from a list of hdus using something like: wcs_reproj, shape_reproj = find_optimal_celestial_wcs(hdu_list, hdu_in = “IMAGE”)

Parameters:
  • cal_lev (int) – Calibration level to be plotted

  • plot_fits (Bool) – Flag to plot from the cutout fits file, otherwise the ExposureF object stored in Cutout is required

  • ihdu (int or str) – Index (or hdu label) of fits image containing the image to be plotted

  • plot_wcs (Bool) – Flag to use the wcs projection (wcs is read from the fits header, which is only an approximation of the full LSST GBDES WCS model)

  • plot_r (float) – Radius of circle to highlight target location (pixels?)

  • wcs_reproj (astropy.wcs.wcs.WCS) – Optional, a specific WCS object to reproject this image to

  • shape_reproj (tuple) – Optional, specific dimensions of the image this one will be reprojected to

Returns:

fig – The matplotlib figure object

Return type:

matplotlib.figure.Figure