alala package
Submodules
alala.alala module
- SECTIONS:
RawDataInitialization; basic functions
Image diagnostics + pre-solving before stacking
Locating coordinates among raw data + writing extensions
Combining/dividing (WIRCam) cubes
Cropping images
Stacking (co-adding images)
StackBad pixel masks / source masks / error arrays
Making images (plots)
Astrometry
PSF photometry
Aperture photometry
PSF/aperture photometry comparison
Source selection
- exception alala.alala.NoDataError
Bases:
ExceptionRaise this error when a RawData object has no data.
- exception alala.alala.TooFewMatchesError
Bases:
ExceptionRaise this error when, during PSF photometry, the no. of sources in the image which match those in some external catalogue is less than 3.
- alala.alala.VALID_DATA_EXT = ('fits', 'fits.fz', 'flt')
Valid file types for the image data.
- alala.alala.VALID_PLOT_EXT = ('pdf', 'jpg', 'bmp', 'png')
Valid file types for any plots which are produced.
- class alala.alala.RawData(data_dir, stack_dir=None, qso_grade_limit=None, fmt='fits', plot_ext='png')
Bases:
object- property data_dir
Directory containing the raw data
- property stack_dir
Directory in which to store stacked images, if stacking
- property fmt
Format (file type/extension) of the data files
- property files
All of the data files
- property plot_ext
Format (file type/extension) of any plots made/to be made
- property instrument
Instrument (WIRCam, MegaCam, or MegaPrime) used to acquire data
- property nextend
Number of extensions in the image data files
- property qso_grade_limit
Queue Service Observer (QSO) grade limit; only relevant if using WIRCam data
- property date
Date (YYYYMMDD) at the start of observations
- property mjdate
Modified Julian Date (MJD) at the start of observations
- property dates
All date(s) (YYYYMMDD) spanned by the data
- property dates_dict
Dictionary with entries {date –> [file1,file2,…]}, e.g., ‘20190816’ –> [‘file1’,’file2’,’file3’]
- property filters
Filters (bands) used in the observations which make up the data
- property filters_dict
Dictionary with entries {filter –> [file1,file2,…]}, e.g., ‘i’ –> [‘file1’,’file2’,’file3’]
- property J
Filenames for images acquired in the J-band
- property H
Filenames for images acquired in the H-band
- property Ks
Filenames for images acquired in the Ks-band
- property Y
Filenames for images acquired in the Y-band
- property u
Filenames for images acquired in the u-band
- property g
Filenames for images acquired in the g-band
- property r
Filenames for images acquired in the r-band
- property i
Filenames for images acquired in the i-band
- property z
Filenames for images acquired in the z-band
- property uS
Filenames for images acquired in the uS-band
- property gS
Filenames for images acquired in the gS-band
- property rS
Filenames for images acquired in the rS-band
- property iS
Filenames for images acquired in the iS-band
- property zS
Filenames for images acquired in the zS-band
- property stack_made
Whether a stack has already been made for the object
- set_stack_dir(stack_dir)
Set the name of the directory in which to store any stacked images.
- set_plot_ext(plot_ext)
Set the file extension of any plots which are produced.
- exclude_date(date)
Exclude a specific date from the data, by parsing through the image files’ fits headers.
- Parameters:
date (str) – A date of the format ‘YYYYMMDD’ or ‘YYYYMM’ or ‘YYYY’ to exclude from the raw data
- exclude_object(obj)
Exclude a specific target object from the data, by parsing through the image files’ fits headers.
- Parameters:
obj (str) – Name of a target object to exclude, e.g., ‘NGC457’
- only_date(date)
Exclude all but one specific date in the data, by parsing through the image files’ fits headers.
- Parameters:
date (str) – A date of the format ‘YYYYMMDD’ or ‘YYYYMM’ or ‘YYYY’ to select in the raw data
- only_object(obj)
Excude all but one specific target object in the data to be used by parsing through the image files’ fits headers.
- Parameters:
obj (str) – Name of the object, e.g., ‘NGC457’
- copy()
Produces a (deep) copy of the object.
- print_headers(ext, *headers)
Print particular fits header(s) for data files.
- Parameters:
ext ({‘fits’, ‘fits.fz’, ‘flt’}) – Extension of interest for the image data to be parsed
headers (str) – Name(s) of any header(s) of interest
- value_at(ra, dec)
Get the value at some RA and Dec, for all images.
- Parameters:
ra, dec (float) – Right Ascension (RA) and Declination of interest
For all of the files contained in the RawData object, prints the ADU value at the given RA and Dec, if these coordinates are within the image’s bounds. Can be used to see if, e.g., the ADU was set to 0 over a source of interest during image de-trending.
- background()
Estimate the background of the images.
- Returns:
List containing the background level of each file
- Return type:
list
Naively estimates the background as the median of the image’s ADU for every raw image in order to see how the data varies.
Notes
Does not mask sources, but this is not important for the purpose of this function: to see if any data is dubious
- radial_PSFs(ra, dec, solved=True, adu_min=4000, adu_max=66000)
Produce radial PSFs for all images.
- Parameters:
ra, dec (float) – Right Ascension (RA) and Declination of interest
solved (bool, optional) – Have the images already been solved with astrometry? (default True)
adu_min, adu_max (float, optional) – Minimum and maximum allowed ADU in the image (default 4000, 66000)
For all of the files in the raw data directory, produces and saves a figure of the radial profile around the input RA and Dec. If solved=False, first solves the image with astrometry.net. (A refined astrometric solution is required to get an accurate radial profile.) A crude technique for estimating the PSF of an image.
Notes
Best to pick a source which is bright, but not one which saturates the detectors.
- solve_all(solved_dir=None, depth=None)
Find the astrometric solution for all images.
- Parameters:
solved_dir (str, optional) – Directory in which to store the solved images (default None –> set automatically)
depth (int, optional) – Number of stars to use in solving with astrometry.net, e.g., depth=100 will use only the 100 brightest stars (default None –> no limit, use all stars)
Using astrometry.net, solve all files, and put them in a new directory. This is necessary when the astrometric solution obtained by CFHT is inaccurate and requires refining, or if you wish to plot the radial PSFs of some point in the raw data images.
Notes
For MegaCam images, detectors (0, 1, …, 17), 36, 37 (top half of camera) are oriented with North ANTI-parallel to the y-axis and East parallel to the x-axis. Detectors (18, 19, …, 35), 38, 39 (bottom half of the camera) are oriented with North parallel to the y-axis and East ANTI-parallel to the x-axis. When trying to make a stack from images in both the top and bottom halves, IRAF sometimes gets confused.
- WCS_check(ra, dec, frac=1.0, verbose=True, checkall=True)
Check if the input coordinates are spanned by any of the data.
- Parameters:
ra, dec (float) – Right Ascension (RA) and Declination of interest
frac (float, optional) – Fraction of the image to consider valid, e.g., 0.9 will exclude the outermost 10% of the image (default 1.0 –> whole image)
verbose (bool, optional) – Print lots of details? (default True)
checkall (bool, optional) – Check all files, or, just return the first matching file? (default True –> check all files)
- Returns:
List of files which span the given coordinates
- Return type:
list
- locate_WCS(ra, dec, frac=1.0)
Given some coordinates and a multi-detector image, find the number ID of the detector where the coordinates are located.
- Parameters:
ra, dec (float) – Right Ascension (RA) and Declination of interest
frac (float, optional) – Fraction of the image to consider valid, e.g., 0.9 will exclude the outermost 10% of the image (default 1.0 –> whole image)
- Returns:
Number ID of the detector where the coordinates are located
- Return type:
int
- write_extensions(n_ext, exten_dir=None)
Write a specific extension of each multi-header fits file to individual files.
- Parameters:
n_ext (int) – Extension number of interest (should be at least 1, n_ext=1 –> extract the 1st extension in the file which corresponds to the 0th detector/CCD)
exten_dir (str, optional) – Name for the directory which will hold the written extensions (default None –> set automatically)
Gets the header and image data for the given extension and writes them to a new .fits file. Does so for all raw data files. Stores them in a new subdirectory. Used to extract image data for one of many CCDs / detectors on either MegaPrime/WIRCam.
Notes
For a given dataset, once
RawData.locate_WCS()has been used to find the extension containing the WCS of interest, run this function once to extract that specific extension. Can then use this newly made folder for stacking.If the extensions are themselves cubes (sometimes the case for WIRCam), see
RawData.combine_WIRCam()orRawData.divide_WIRCam().Currently only works for cubes of the form fits.fz, and produces files of form fits.
- write_extensions_all(all_exten_dir=None)
Write each extension of each multi-header fits file to individual files.
- Parameters:
all_exten_dir (str, optional) – Name for the directory which will hold the written extensions (default None –> set automatically)
Gets the header and image data for all extensions of a multi-header fits file and writes each extension to a new .fits file. Useful for MegaPrime data where the scope moves a lot and the detectors are all calibrated to the same ADU level.
Notes
Currently only works for cubes of the form fits.fz, and produces files of form fits.
- write_extensions_by_WCS(ra, dec, frac=1.0, wcs_exten_dir=None)
Same as
RawData.write_extensions(), but select the extension using an RA and Dec.- Parameters:
ra, dec (float) – Right Ascension (RA) and Declination of interest
frac (float, optional) – Fraction of the image to consider valid, e.g., 0.9 will exclude the outermost 10% of the image (default 1.0 –> whole image)
wcs_exten_dir (str, optional) – Name for the directory which will hold the written extensions (default None –> set automatically)
For a directory full of multi-extension fits files, gets the extensions which contain the input RA, Dec and writes them to a new file.
Notes
Currently only works for cubes of the form fits.fz, and produces files of form fits.
- write_source(name, ra, dec, frac=1.0)
Same as
RawData.write_extensions_by_WCS(), but write the files to a new directory with name name.- Parameters:
name (str) – Name of the source of interest (e.g. some transient)
ra, dec (float) – Right Ascension (RA) and Declination of interest
frac (float, optional) – Fraction of the image to consider valid, e.g., 0.9 will exclude the outermost 10% of the image (default 1.0 –> whole image)
Parses all raw data and copies any images which contain the input RA, Dec to a new sub-directory with the name of the source.
- combine_WIRCam()
For a directory full of WIRCam images, if the images are cubes, combine the multiple 2D arrays into single arrays.
Notes
Use this function once to take a folder full of cubes and turn them into single-frame fits files. Can not be called on non-cubes. Only used for WIRCam.
- divide_WIRCam()
For a directory full of WIRCam images, if the images are cubes, divide the multiple 2D arrays into individual arrays.
Notes
Use this function once to take a folder full of cubes and turn them into single-frame fits files. Can not be called on non-cubes. Only used for WIRCam.
- crop_images(frac_hori=[0, 1], frac_vert=[0, 1])
Crop several fits images.
- Parameters:
frac_hori, frac_vert (length-two list, optional) – Horizontal and vertical fractions of the images to crop (default [0,1] for both –> no cropping)
For a directory full of WIRCam/MegaPrime images (should not be cubes), crops the images based on the input x-axis and y-axis boundaries and writes them all to a new directory.
- crop_images_wcs(ra, dec, size)
Crop several fits images by picking out a source based on its RA and Dec.
- Parameters:
ra, dec (float) – Right Ascension (RA) and Declination of interest, in degrees
size (float) – Size of a box (in pixels) to crop around the input coordinates
For a directory full of WIRCam/MegaPrime images (should not be cubes), crops the images based on the input WCS coordinates, creating a box centred on these coordinates and writing the new files to a new directory. If the given box extends beyond the bounds of the image, the box will be truncated at these bounds.
- make_badpix_masks()
Builds a bad pixel mask for all image files, and places them in a new directory which is stored in
Stack.bp_dir.
- make_stacks(*filters)
Co-add images with PyRaf.
- Parameters:
filters (str, optional) – Filters of interest (defaults to all of the filters for which there is raw data)
Uses PyRaf to coadd all of the raw data into stacks based on filter. Can specify a subset of these filters if you don’t want to process all of them at once.
- class alala.alala.Stack(location, stack_directory, qso_grade_limit, fmt, plot_ext, filt)
Bases:
RawData- property stack_size
Number of files used in the stacking
- property stack_time
Observation time in Modified Julian Date (MJD)
- property image_data
Stacked image data
- property image_header
Image fits header
- property bp_dir
Directory containing the bad pixel mask
- property calib_dir
Directory containing photometric/astrometric calibration files
- property exptime
Total exposure time of the stacked image
- property pixscale
Pixel scale of the instrument used
- property x_size
x dimension of the image, in pixels
- property y_size
y dimension of the image, in pixels
- property astrometric_calib
Has astrometric calibration been performed?
- property psf_fit
Has the effective Point-Spread Function (ePSF) been fit?
- property photometric_calib
Has photometric calibration (i.e., obtaining a zero point) been performed?
- property aperture_fit
Has aperture photometry been performed?
- property bkg
Background-only image
- property bp_mask
Bad pixel mask; array of bools
- property source_mask
Mask of sources; array of ints, where 0=non-masked and 1=masked
- property image_error
Estimate of the error (Gaussian + Poisson) across the image
- property image_data_bkgsub
Background-subtracted image data
- property xy_data
Table of (x, y) coordinates for sources found with astrometry.net
- property xy_name
Name of the file containing
Stack.xy_data
- property epsf_data
Effective Point-Spread Function (ePSF) data
- property epsf_radius
Radius of the effective Point Spread Function (ePSF), in pixels
- property ref_cat
Vizier code/ID for the reference catalogue used in photometric calibration
- property ref_cat_name
Name of the reference catalogue used in photometric calibration
- property zp_mean
Mean zero point from photometric calibration
- property zp_med
Median zero point from photometric calibration
- property zp_std
Standard deviation (uncertainty) of the zero point from photometric calibration
- property ra_offsets_mean
Mean offset in Right Ascension (RA) between the image and reference catalogue
- property dec_offsets_mean
Mean offset in Declination between the image and reference catalogue
- property nmatches
Number of matches between astrometry-detected sources in the image and the reference catalogue
- property sep_mean
Mean separation between sources, in arcseconds
- property mag_diff_mean
Mean difference between calibrated magnitudes and reference catalogue magnitudes
- property psf_sources
Table of sources detected by point-spread function (PSF) photometry
- property aperture_sources
Table of sources detected by aperture photometry
- property limmag_sources
Table of “sources” for which we have a limiting magnitude
- mask_bp()
Make a bad pixel mask of pixels = 0 or nan. The mask is an array of bools, contained in
Stack.bp_mask
- mask_source(sigma=3.0)
Make a mask of pixels containing sources.
- Parameters:
sigma (float, optional) – Detection sigma to use in image segmentation (default 3.0)
Use crude image segmentation to make a proto source mask, use the mask to get the background, and then perform proper image segmentation on the background-subtracted image data. The resulting segmentation image is a proper source mask, to be used in other steps in aperture photometry. The output source mask also flags bad pixels.
Notes
The mask is an array of ints, where 1=masked, 0=non-masked. Will be contained in
Stack.source_mask, Not to be confused withStack.bp_mask.
- bkg_compute(box_size=50, filter_size=5, thresh_sigma=3.0)
Compute the background of the image.
- Parameters:
box_size (int, optional) – Size of box for background estimation (default 50 –> 50x50 boxes)
filter_size (int, optional) – Size of the median filter applied during background estimation (default 5 –> 5x5 filter)
thresh_sigma (float, optional) – Detection to use in image segmentation when producing a source mask (default 3.0; only relevant if a source mask does not already exist and needs to be computed)
Computes the background of the image, the error on the background (as the RMS deviation), and the background-subtracted image. Assigns these to the attributes
Stack.bkg,Stack.bkg_rms,Stack.image_data_bkgsub.Notes
A new source mask will be obtained only if
Stack.source_maskdoes not exist.
- error_array(box_size=50, filter_size=5, thresh_sigma=3.0)
Compute the error (uncertainty) on the background-only image.
- Parameters:
box_size (int, optional) – Size of box for background estimation (default 50 –> 50x50 boxes; only relevant if background not previously computed)
filter_size (int, optional) – Size of the median filter applied during background estimation (default 5 –> 5x5 filter, only relevant if background not previously computed)
thresh_sigma (float, optional) – Detection to use in image segmentation when producing a source mask (default 3.0; only relevant if source mask not previously computed)
Computes the error on the background-only image as the RMS deviation of the background, and then computes the total image error including the contribution of the Poisson noise from detected sources. Necessary for error propagation in aperture photometry.
- make_image(bkgsub=False, border=False, sources=False, ra=None, dec=None, scale=None, title=None, output=None)
Make a plot of the stacked image.
- Parameters:
bkgsub (bool, optional) – Plot the background-subtracted data? (default False)
border (bool, optional) – Demarcate the region in which sources are valid for photometry? (default False)
sources (bool, optional) – Drop circles on detected sources? (default False)
ra, dec (float, optional) – Right Ascension (RA) and Declination at which to place a crosshair (default None)
scale ({None, “log”, “asinh”}, optional) – Scale to apply to the images (default None –> linear scale)
title (str, optional) – Title to place above the plot (default None –> no title)
output (str, optional) – Name for the output image file (default None –> set automatically)
- astrometry(verbose=0)
Perform source extraction with astrometry.net and solve the field.
- Parameters:
verbose (int, optional) – Level of verbosity within astrometry.net (default 0)
Notes
After running this function, can obtain a list of detected sources’ (x, y) coordinates from attribute
self.xy_dataor by reading the fits fileStack.xy_nameCreates a new file appended with _updated.fits with the new astrometric solution
- fit_PSF(nstars=40, thresh_sigma=5.0, pixelmin=20, elongation_lim=1.4, area_max=500, cutout=35, source_lim=None, write=False, output=None, plot_ePSF=True, ePSF_name=None, plot_residuals=False, resid_name=None)
Fit for the effective Point-Spread Function (ePSF) of the image.
- Parameters:
nstars (int, optional) – Maximum number of stars to use in building the ePSF (default 40; set to None to impose no limit)
thresh_sigma (float, optional) – Sigma threshold for source detection with image segmentation (default 5.0)
pixelmin (int, optional) – Minimum number of contiguous pixels for an isophote to be considered a source (default 20)
elongation_lim (float, optional) – Maximum elongation (ratio of semimajor axis / semiminor axis) for an isophote to be considered a source (default 1.4)
area_max (float, optional) – Maximum pixel area (in pix**2) for an isophote to be considered a source (default 500)
cutout (int, optional) – Size of the cutout around each star, in pix (default 35; must be odd, will be rounded down if eve)
source_lim (int, optional) – Limit on the number of sources to fit with the ePSF (default None)
write (bool, optional) – Write the ePSF to a .fits file as an image? (default False)
output (str, optional) – Name for the output .fits file (default None –> set automatically; only relevant if write=True)
plot_ePSF (bool, optional) – Plot the ePSF? (default False)
ePSF_name (str, optional) – Name for the output plot of the ePSF? (default None –> set automatically; only relevant if plot_ePSF=True)
plot_residuals (bool, optional) – Plot the residuals of the iterative PSF fitting? (default False)
resid_name (str, optional) – Name for the output plot of the residuals (default None –> set automatically; only relevant if plot_residuals=True)
Uses image segmentation to obtain a list of sources in the smoothed, background-subtracted image (provided by astrometry.net) with their x, y coordinates. Uses EPSFBuilder to empirically obtain the ePSF of these stars. Uses astrometry.net to find all sources in the image, and fits them with the empirically obtained ePSF. Builds a table containing the instrumental magnitudes and corresponding uncertainties to be used in obtaining the zero point for PSF calibration, in
Stack.psf_sources.Notes
The ePSF obtained here should NOT be used in convolutions. Instead, it can serve as a tool for estimating the seeing of an image.
- zero_point(sep_max=2.0, plot_corr=True, corr_name=None, plot_source_offsets=True, source_offs_name=None, plot_field_offsets=False, field_offs_name=None, gaussian_blur_sigma=30.0, cat_num=None)
Obtain the zero point of the image.
- Parameters:
sep_max (float, optional) – Maximum allowed separation when cross-matching sources, in pix (default 2.0; corresponds to ~ 0.6” for WIRCam and ~ 0.37” for MegaPrime)
plot_corr (bool, optional) – Plot the correlation plot with a linear fit (i.e., instrumental source magnitude in the image versus calibrated catalogue magnitude)? (default True)
corr_name (str, optional) – Name for the output correlation plot (default None –> set automatically; only relevant if plot_corr=True)
plot_source_offsets (bool, optional) – Plot the offsets between the image and catalogue in Right Ascension (RA) and Declination (Dec) space, for all sources? (default True)
source_offs_name (str, optional) – Name for the output offsets plot (default None –> set automatically; only relevant if plot_source_offsets=True)
plot_field_offsets (bool, optional) – Plot the offsets over the image itself, with some Gaussian blur for legibility? (default False)
field_offs_name (str, optional) – Name for the output field offsets plot (default None –> set automatically; only relevant if plot_field_offsets=True)
gaussian_blur_sigma (float, optional) – Standard deviation (sigma) of the Gaussian blur to apply if plotting the field offsets (default 30.0; only relevant if plot_field_offsets=True)
cat_num (str, optional) – Vizier catalogue number for the catalogue to use in cross-matching (default None –> set automatically according to the filter in use)
Uses astroquery and Vizier to query an online catalogue for sources which match those detected by astrometry. Computes the offset between the apparent and instrumental magnitudes of the queried sources for photometric calibration. Computes the mean, median and standard deviation.
Notes
For filters , “g”, “r”, “i”, “z”, “Y”, the default catalogue is Pan-STARRS 1
For filter “u”, the default catalogue is SDSS DR12
For filter “Ks” (“K”), the default catalogue is 2MASS
- PSF_photometry(nstars=40, thresh_sigma=5.0, pixelmin=20, elongation_lim=1.4, area_max=500, cutout=35, source_lim=None, gaussian_blur_sigma=30.0, cat_num=None, sep_max=2.0, box_size=50, filter_size=5, write_ePSF=True, ePSF_data_name=None, plot_ePSF=True, ePSF_name=None, plot_resid=False, resid_name=None, plot_corr=True, corr_name=None, plot_source_offsets=True, source_offs_name=None, plot_field_offsets=False, field_offs_name=None)
Obtain the effective Point-Spread Function (ePSF) of the image, perform zero point calibration, and perform PSF photometry on all detected sources.
- Parameters:
nstars (int, optional) – Maximum number of stars to use in building the ePSF (default 40; set to None to impose no limit)
thresh_sigma (float, optional) – Sigma threshold for source detection with image segmentation (default 5.0)
pixelmin (int, optional) – Minimum number of contiguous pixels for an isophote to be considered a source (default 20)
elongation_lim (float, optional) – Maximum elongation (ratio of semimajor axis / semiminor axis) for an isophote to be considered a source (default 1.4)
area_max (float, optional) – Maximum pixel area (in pix**2) for an isophote to be considered a source (default 500)
cutout (int, optional) – Size of the cutout around each star, in pix (default 35; must be odd, will be rounded down if eve)
source_lim (int, optional) – Limit on the number of sources to fit with the ePSF (default None)
gaussian_blur_sigma (float, optional) – Standard deviation (sigma) of the Gaussian blur to apply if plotting the field offsets (default 30.0; only relevant if plot_field_offsets=True)
cat_num (str, optional) – Vizier catalogue number for the catalogue to use in cross-matching (default None –> set automatically according to the filter in use)
sep_max (float, optional) – Maximum allowed separation when cross-matching sources, in pix (default 2.0; corresponds to ~ 0.6” for WIRCam and ~ 0.37” for MegaPrime)
box_size (int, optional) – Size of box for background estimation (default 50 –> 50x50 boxes; only relevant if background not previously computed)
filter_size (int, optional) – Size of the median filter applied during background estimation (default 5 –> 5x5 filter, only relevant if background not previously computed)
write_ePSF (bool, optional) – Write the ePSF to a .fits file as an image? (default False)
ePSF_data_name (str, optional) – Name for the output .fits file (default None –> set automatically; only relevant if write_ePSF=True)
plot_ePSF (bool, optional) – Plot the ePSF? (default False)
ePSF_name (str, optional) – Name for the output plot of the ePSF? (default None –> set automatically; only relevant if plot_ePSF=True)
plot_residuals (bool, optional) – Plot the residuals of the iterative PSF fitting? (default False)
resid_name (str, optional) – Name for the output plot of the residuals (default None –> set automatically; only relevant if plot_residuals=True)
plot_corr (bool, optional) – Plot the correlation plot with a linear fit (i.e., instrumental source magnitude in the image versus calibrated catalogue magnitude)? (default True)
corr_name (str, optional) – Name for the output correlation plot (default None –> set automatically; only relevant if plot_corr=True)
plot_source_offsets (bool, optional) – Plot the offsets between the image and catalogue in Right Ascension (RA) and Declination (Dec) space, for all sources? (default True)
source_offs_name (str, optional) – Name for the output offsets plot (default None –> set automatically; only relevant if plot_source_offsets=True)
plot_field_offsets (bool, optional) – Plot the offsets over the image itself, with some Gaussian blur for legibility? (default False)
field_offs_name (str, optional) – Name for the output field offsets plot (default None –> set automatically; only relevant if plot_field_offsets=True)
Using image segmentation, finds as many sources as possible in the image with an elongation below some elongation limit. Uses these sources to build an empirical effective PSF (ePSF). Using a list of sources found by astrometry.net, fits the ePSF to all of those sources. Computes the instrumental magnitude of all of these sources. Queries the correct online catalogue for the given filter to crossmatch sources in the image with those in the catalogue (e.g., Pan-STARRS 1). Finds the zero point which satisfies AB_mag = ZP + instrumental_mag and gets the calibrated AB mags for all PSF-fit sources.
- write_PSF_photometry(nstars=40, thresh_sigma=5.0, pixelmin=20, elongation_lim=1.4, area_max=500, cutout=35, source_lim=None, gaussian_blur_sigma=30.0, cat_num=None, sep_max=2.0, verbose=True, box_size=50, filter_size=5, write_ePSF=False, ePSF_data_name=None, plot_ePSF=True, ePSF_name=None, plot_resid=False, resid_name=None, plot_corr=True, corr_name=None, plot_source_offsets=True, source_offs_name=None, plot_field_offsets=False, field_offs_name=None, output=None)
Write the results of PSF photometry.
- Parameters:
… – all of the inputs to
Stack.PSF_photometry()output (str, optional) – Name of the output .fits file (default None –> set automatically)
Performs PSF photometry if it has not already been performed, and then writes a table of the PSF-fit sources to a .fits table.
- aperture_photometry(ra_list, dec_list, sigma=None, bkgsub_verify=True, ap_radius=1.2, r1=2.0, r2=5.0, box_size=50, filter_size=5, thresh_sigma=3.0, plot_annulus=False, ann_name=None, plot_aperture=False, ap_name=None)
Do aperture photometry.
- Parameters:
ra_list, dec_list (list **or* float*) – List or single float of the Right Ascension (RA), Declination around some source of interest
sigma (float, optional) – Limiting sigma below which a source is labeled as not detected, in which case the user should use
Stack.limiting_magnitude()ap_radius (float, optional) – Radius of the aperture, in arcseconds (default 1.2)
r1, r2 (float, optional) – Inner and outer radii of the annulus, in arcseconds (default 2.0, 5.0)
box_size (int, optional) – Size of box for background estimation (default 50 –> 50x50 boxes; only relevant if background not previously computed)
filter_size (int, optional) – Size of the median filter applied during background estimation (default 5 –> 5x5 filter, only relevant if background not previously computed)
thresh_sigma (float, optional) – Detection to use in image segmentation when producing a source mask (default 3.0; only relevant if a source mask does not already exist and needs to be computed)
plot_annulus (bool, optional) – Plot the image data contained in the annulus, centered on the ra, dec of interest? (default False)
ann_name (str, optional) – Name for the plot of the annulus image data (default None –> set automatically)
plot_aperture (bool, optional) – Plot the aperture and annulus as rings (default False)
ap_name (str, optional) – Name for the output aperture+annulus plot (default None –> set automatically)
Computes the the total flux in a defined aperture around the given RA, Dec, computes the background in an annulus around this aperture, and computes the background-subtracted flux of the “source” defined by the aperture. Can be called multiple times if a list of RA/Dec is given.
- limiting_magnitude(ra, dec, sigma=5.0, thresh_sigma=3.0, box_size=50, filter_size=5, plot_annulus=True, ann_name=None, plot_aperture=None, ap_name=None, write=False, output=None)
Obtain the limiting magnitude at some coordinates for some sigma significance.
- Parameters:
ra_list, dec_list (list **or* float*) – List or single float of the Right Ascension (RA), Declination around some source of interest
sigma (float, optional) – Detection significance (default 5.0)
thresh_sigma (float, optional) – Detection to use in image segmentation when producing a source mask (default 3.0; only relevant if a source mask does not already exist and needs to be computed)
box_size (int, optional) – Size of box for background estimation (default 50 –> 50x50 boxes; only relevant if background not previously computed)
filter_size (int, optional) – Size of the median filter applied during background estimation (default 5 –> 5x5 filter, only relevant if background not previously computed)
plot_annulus (bool, optional) – Plot the image data contained in the annulus, centered on the ra, dec of interest? (default True)
ann_name (str, optional) – Name for the plot of the annulus image data (default None –> set automatically)
plot_aperture (bool, optional) – Plot the aperture and annulus as rings (default False)
ap_name (str, optional) – Name for the output aperture+annulus plot (default None –> set automatically)
write (bool, optional) – Write the results to a table? (default False)
output (str, optional) – Name for the output table (default None –> set automatically; only relevant if write=True)
- Returns:
Limiting magnitude
- Return type:
float
Notes
For a given RA, Dec, finds the limiting magnitude at its location. If a source was previously detected <= 3” away from the given coords by astrometry.net, the limiting magnitude at the RA, Dec given will be invalid, and so the aperture will randomly jitter until a valid RA, Dec is found.
- write_aperture_photometry(output=None)
Write the sources detected by aperture photometry to a table.
- write_limiting_magnitude(output=None)
Write the “sources” with limiting magnitudes computed by aperture photometry to a table.
- compare_photometry(ap_radius=1.2, r1=2.0, r2=5.0, nsamples=100, output=None)
Compare the calibrated magnitude obtained with aperture photometry (
Stack.aperture_photometry()) to that obtained with PSF photometry (Stack.PSF_photometry()).- Parameters:
ap_radius (float, optional) – Radius of the aperture, in arcseconds (default 1.2)
r1, r2 (float, optional) – Inner and outer annuli radii, where the annulus is used for estimating the background (default 2.0, 5.0)
nsamples (int, optional) – Number of samples to take from PSF photometry
output (str, optional) – Name of the output figure comparing the two photometries (default None –> set automatically)
- source_selection(ra, dec, radius=1.0)
Parse the table of sources provided by PSF photometry (
Stack.PSF_photometry()) for sources within some distance of the given coordinates.- Parameters:
ra, dec (float) – Right Ascension (RA) and Declination for the source of interest
radius (float) – Radius to search in, in arcseconds (default 1.0)
- Returns:
Table of the source(s) satisfying the conditions
- Return type:
astropy.table.Table
- write_selection(ra, dec, radius=1.0, output=None)
Write some selection of sources based on coordinates.
- Parameters:
… – all of the inputs to
Stack.source_selection()output (str, optional) – Name of the output .fits table (default None –> set automatically)
alala.apphotom module
- CONTENTS:
image2xy(): Make a list of sources with astrometry.netimsegm_make_source_mask(): Make a mask of sources using image segmentationerror_array(): Compute the combination of the Gaussian + Poissonian error in the imageaperture_photom(): Perform aperture photometry on an imagelimiting_magnitude(): Get the limiting magnitude of an image
- NON-STANDARD PYTHON DEPENDENCIES:
astropy
photutils
- NON-PYTHON DEPENDENCIES:
astrometry.net
- alala.apphotom.image2xy(image_file, astrom_sigma=5.0, psf_sigma=5.0, alim=10000, write=False, output=None)
Use astrometry.net’s image2xy to detect sources in an image.
- Parameters:
image_file (str) – Filename for NOT background-subtracted image
astrom_sigma (float, optional) – Sigma threshold for astrometry.net source detection image (default 5.0)
psf_sigma (float, optional) – Sigma of the Gaussian PSF of the image (default 5.0)
alim (int, optional) – Maximum allowed source area, in pixels**2, beyond which sources will be deblended (default 10000)
write (bool, optional) – Write the output list of sources? (default False)
output (str, optional) – Name for output source list file (default set by function)
- Returns:
List of sources
- Return type:
astropy.io.fits.fitsrec.FITS_rec
Notes
Can write sources to a list of sources and/or a file to be used as a source mask in aperture photometry.
- alala.apphotom.imsegm_make_source_mask(image_file, mask_file=None, sigma=3.0, write=False, output=None)
Make a mask which contains sources in the image using image segmentation.
- Parameters:
image_file (str) – Filename for NOT background-subtracted image
mask_file (str, optional) – Filename for a bad pixel mask (default None)
sigma (float, optional) – Detection sigma to use in image segmentation (default 3.0)
write (bool, optional) – Write the source mask to a file? (default False)
output (str, optional) – Name for output file (default set by function)
- Returns:
Source mask where 0 = background, 1 = source
- Return type:
np.ndarray
Notes
Use crude image segmentation to make a proto source mask, use the mask to get the background, and then perform proper image segmentation on the background-subtracted image data. The resulting segmentation image is a source mask, to be used in other steps in aperture photometry. The output source mask also flags bad pixels.
- alala.apphotom.error_array(image_file, source_mask=None, sigma=3.0, write=True, output=None)
Make an array of the error in an image, including root-mean-squared deviation on the background and Poisson noise for detected sources.
- Parameters:
image_file (str) – Filename for NOT background-subtracted image
source_mask (np.ndarray, str, optional) – Filename for a source mask or the mask data itself (default None; in which case a source mask is made)
sigma (float, optional) – Detection sigma to use in image segmentation, if a source mask is to be made (default 3.0; only relevant if source_mask = None)
write (bool, optional) – Write the error array to a file? (default False)
output (str, optional) – Name for output file (default set by function)
- Returns:
Image error array
- Return type:
np.ndarray
Notes
Computes the error on the background-only image as the RMS deviation of the background, and then computes the total image error including the contribution of the Poisson noise for detected sources. Necessary for error propagation in aperture photometry.
- alala.apphotom.aperture_photom(image_file, ra, dec, mask=None, error=None, sigma=None, bkgsub_verify=True, ap_radius=1.2, r1=2.0, r2=5.0, thresh_sigma=3.0, plot_annulus=True, plot_aperture=True, ann_output=None, ap_output=None, write=False, output=None, cmap='bone')
Perform aperture photometry on some image.
- Parameters:
image_file (str) – Filename for NOT background-subtracted image
ra, dec (float, list) – Floats or lists of RA, Dec of interest
mask (np.ndarray, str, optional) – Filename for a source mask or the mask data itself (default None; in which case a source mask is made)
error (np.ndarray, str, optional) – Filename for image error or the image error itself (default None; in which case an error array is made)
sigma (float, optional) – Sigma below which to reject a source (default None –> do not reject any sources)
bkgsub_verify (bool, optional) – Verify that the background-subtracted flux is non-negative? (default True)
ap_radius (float, optional) – Aperture radius, in arcseconds (default 1.2”)
r1, r2 (float, optional) – Inner and outer radius of the annulus, in arcseconds (default 2.0”, 5.0”)
thresh_sigma (float, optional) – Detection sigma to use in image segmentation (default 3.0; only relevant if mask and/or error are not given)
plot_annulus (bool, optional) – Plot the annulus? (default True)
plot_aperture (bool, optional) – Plot the aperture? (default True)
ann_output (str, optional) – Name for output annulus plot (default None; set by function if plot_annulus = True)
ap_output (str, optional) – Name for output aperture plot (default None; set by function if plot_aperture = True)
write (bool, optional) – Write the resultant table? (default False)
output (str, optional) – Name for the output table file (default None; set by function if write = True)
cmap (str, matplotlib.colors.ListedColormap, optional) – Colormap for plots (default “bone”)
- Returns:
Table containing the results of aperture photometry
- Return type:
TYPE
Notes
Finds the total flux in a defined aperture, computes the background in an annulus around this aperture, and computes the background-subtracted flux of the “source” defined by the aperture. Will compute aperture photometry for multiple sources if a list of RA/Decs is given.
If the background-subtracted flux at some location is negative, make sure that no sources remain in the annulus of the data, or consider getting a limiting magnitude at the RA, Dec of interest instead with
limiting_magnitude()
- alala.apphotom.limiting_magnitude(image_file, ra, dec, source_list=None, mask=None, error=None, sigma=5.0, astrom_sigma=5.0, psf_sigma=5.0, alim=10000, ap_radius=1.2, r1=2.0, r2=10.0, thresh_sigma=3.0, plot_annulus=True, plot_aperture=True, ann_output=None, ap_output=None, write=False, output=None, cmap='bone')
Obtain the limiting magnitude of some image.
- Parameters:
image_file (str) – Filename for NOT background-subtracted image
ra, dec (float, list) – Floats or lists of RA, Dec of interest
source_list (str, astropy.io.fits.fitsrec.FITS_rec, optional) – Filename for source list or the source list fits bintable itself (default None –> make a list)
mask (np.ndarray, str, optional) – Filename for a source mask or the mask data itself (default None; in which case a source mask is made)
error (np.ndarray, str, optional) – Filename for image error or the image error itself (default None; in which case an error array is made)
sigma (float, optional) – Sigma to use when computing limiting magnitude (default 5.0)
astrom_sigma (float, optional) – Sigma threshold for astrometry.net source detection image (default 5.0)
psf_sigma (float, optional) – Sigma of the Gaussian PSF of the image to be used in astrometry.net(default 5.0)
alim (int, optional) – Maximum allowed source area, in pixels**2, beyond which sources will be deblended in astrometry.net (default 10000)
ap_radius (float, optional) – Aperture radius, in arcseconds (default 1.2”)
r1, r2 (float, optional) – Inner and outer radius of the annulus, in arcseconds (default 2.0”, 10.0”)
thresh_sigma (float, optional) – Detection sigma to use in image segmentation (default 3.0; only relevant if mask and/or error are not given)
plot_annulus (bool, optional) – Plot the annulus? (default True)
plot_aperture (bool, optional) – Plot the aperture? (default True)
ann_output (str, optional) – Name for output annulus plot (default None; set by function if plot_annulus = True)
ap_output (str, optional) – Name for output aperture plot (default None; set by function if plot_aperture = True)
write (bool, optional) – Write the resultant table? (default False)
output (str, optional) – Name for the output table file (default None; set by function if write = True)
cmap (str, matplotlib.colors.ListedColormap, optional) – Colormap for plots (default “bone”)
- Returns:
Table containing RA, Dec, calibrated magnitude, filter used, and MJD for the limiting magnitude
- Return type:
TYPE
Notes
For a given RA, Dec, finds the limiting magnitude at its location. If a source was previously detected <= 3” away from the given coords by astrometry.net, the aperture will randomly move about until a valid RA, Dec is found.
- alala.apphotom.ellipse_photom(image_file, ra, dec, mask=None, guess_sma=0.9, guess_eps=0.3, guess_pa=60.0, sma_min=0.2, sma_max=2.5, r1=4.0, r2=12.0, thresh_sigma=3.0, flux_sub=0, plot_annulus=True, plot_ellipses=True, ann_output=None, ell_output=None, write=False, output=None, cmap='bone')
Like
aperture_photom(), but use an elliptical aperture.- Parameters:
image_file (str) – Filename for NOT background-subtracted image
ra, dec (float, list) – Floats or lists of RA, Dec of interest
mask (np.ndarray, str, optional) – Filename for a source mask or the mask data itself (default None; in which case a source mask is made)
guess_sma (float, optional) – Initial guess for semi-major of ellipse, in arcseconds (default 1.0)
guess_eps (float, optional) – Initial guess for ellipticity (default 0.3)
guess_pa (float, optional) – Initial guess for position angle of ellipse, in degrees (default 60.0)
sma_min, sma_max (float, optional) – Minimum/maximum allowed semi-major axis of ellipse, in arcseconds (default 0.2)
r1, r2 (float, optional) – Inner and outer radius of the annulus, in arcseconds (default 4.0”, 12.0”)
thresh_sigma (float, optional) – Detection sigma to use in image segmentation (default 3.0)
flux_sub (float, optional) – Additional flux to subtract, if, e.g., want to subtract the flux of some galaxy (default 0)
plot_annulus (bool, optional) – Plot the annulus? (default True)
plot_ellipses (bool, optional) – Plot the elliptical isotophotes? (default True)
ann_output (str, optional) – Name for output annulus plot (default None; set by function if plot_annulus = True)
ell_output (str, optional) – Name for output ellipses plot (default None; set by function if plot_ellipses = True)
write (bool, optional) – Write the resultant table? (default False)
output (str, optional) – Name for the output table file (default None; set by function if write = True)
cmap (str, matplotlib.colors.ListedColormap, optional) – Colormap for plots (default “bone”)
- Returns:
Table containing the results of “ellipse” photometry
- Return type:
TYPE
alala.lightcurve module
Combine aperture and/or PSF photometry generated with apphotom and/or
psfphotom modules, to generate light curves.
Light curves can include 3 kinds of data points:
Magnitudes: Measured magnitudes, including error bars
Limiting magnitudes: Limiting magnitudes, which do not have error bars
Reference magnitudes: Reference magnitudes obtained from some other work / analysis, with (optional) error barts
- alala.lightcurve.plotting_to_agg()
Switch matplotlib backend to ‘agg’
- alala.lightcurve.plotting_to_Qt4Agg()
Switch matplotlib backend to ‘Qt4Agg’
- alala.lightcurve.VALID_PHOT_FILTS = ['u', 'g', 'r', 'i', 'z', 'Y', 'J', 'H', 'K']
Valid photometric filters.
- alala.lightcurve.DEFAULT_PLOT_INSTRUCTIONS = {'H': ['#fac205', 's'], 'J': ['#029386', 's'], 'K': ['#c04e01', 's'], 'Y': ['#8e82fe', 's'], 'g': ['#0165fc', 'o'], 'i': ['#ff9408', 'o'], 'r': ['#00ffff', 'o'], 'u': ['#be03fd', 'o'], 'z': ['#ff474c', 'o']}
Default instructions for plotting magnitudes.
- alala.lightcurve.DEFAULT_PLOT_INSTRUCTIONS_LIM_MAGS = {'H': ['#fac205', 'v'], 'J': ['#ff028d', 'v'], 'K': ['#c04e01', 'v'], 'Y': ['#c65102', 'v'], 'g': ['#0165fc', 'v'], 'i': ['#ff9408', 'v'], 'r': ['#00ffff', 'v'], 'u': ['#be03fd', 'v'], 'z': ['#ff474c', 'v']}
Default instructions for plotting limiting magnitudes.
- alala.lightcurve.DEFAULT_PLOT_INSTRUCTIONS_REF_MAGS = {'H': '#fac205', 'J': '#ff028d', 'K': '#c04e01', 'Y': '#c65102', 'g': '#0165fc', 'i': '#ff9408', 'r': '#00ffff', 'u': '#be03fd', 'z': '#ff474c'}
Default instructions for plotting reference magnitudes.
- alala.lightcurve.PLOT_INSTRUCTIONS_VIEIRA20 = {'g': ['#76cd26', 's'], 'i': ['#0165fc', 'o'], 'z': ['#ff474c', 'D']}
Plotting instructions used in Vieira et al. (2020).
- alala.lightcurve.PLOT_INSTRUCTIONS_LIM_MAGS_VIEIRA20 = {'g': ['#76cd26', 'v'], 'i': ['#0165fc', 'v'], 'z': ['#ff474c', 'v']}
Plotting instructions for limiting magnitudes used in Vieira et al. (2020).
- alala.lightcurve.PLOT_INSTRUCTIONS_REF_MAGS_VIEIRA20 = {'g': '#76cd26', 'i': '#0165fc', 'z': '#ff474c'}
Plotting instructions for reference magnitudes used in Vieira et al. (2020).
- alala.lightcurve.fromfile(readfile)
Read a single .fits table file containing either magnitudes or limiting magnitudes
- Returns:
New
LightCurveobject- Return type:
Notes
Does not work for reference magnitudes. Will assume magnitude is just a regular magnitude. Reference magnitudes must be added one file at a time (see
add_ref_files()andadd_ref_tables()).
- alala.lightcurve.fromdirectory(directory)
Search a directory for .fits files and read in magnitudes or limiting magnitudes
- Returns:
New
LightCurveobject- Return type:
Notes
Assumes that all files in the directory contain magnitudes or limiting magnitudes. Reference magnitudes must be added one file at a time (see
add_ref_files()andadd_ref_tables()).
- alala.lightcurve.frompoint(ra, dec, mag, mag_err, filt, mjd)
Generate a new light curve from a single specified data point
- Parameters:
ra, dec (float) – RA and Dec of the source of interest
mag (float) – Magnitude
mag_err (float) – Error on the magnitude
filt (str) – Photometric filter used during observation
mjd (float) – MJD at time of observation
- Returns:
New
LightCurveobject- Return type:
Notes
Should not be used for a limiting or reference magnitude.
- class alala.lightcurve.LightCurve(mag_tab=None, lim_mag_tab=None, ref_mag_tab=None)
Bases:
object- copy()
Return a (deep) copy of the object
- property mags
Table of magnitudes
- property limmags
Table of limiting magnitudes
- property refmags
Table of reference magnitudes
- property plot_instructions
Instructions for plotting magnitudes
- property plot_instructions_lim_mags
Instructions for plotting limiting magnitudes
- property plot_instructions_ref_mags
Instructions for plotting reference magnitudes
- property mag_colnames
Columns to use as keys when searching for magnitudes in input files/tables
- property limmag_colnames
Columns to use as keys when searching for limiting magnitudes in input files/tables
- add_tables(*tables)
Add one or more new tables to the existing LightCurve’s magnitude table and/or limiting magnitude table
Notes
Changes the LightCurve in place. Assumes that the tables contain either magnitudes or limiting magnitudes. For adding in reference magnitudes, see
add_ref_tables().
- add_files(*files)
Read in from files and then append any new tables to the existing LightCurve’s magnitude table and/or limiting magnitude table
Notes
Changes the LightCurve in place. Assumes that the files contain tables with either magnitudes or limiting magnitudes. For adding in reference magnitudes, see
add_ref_files().
- add_ref_tables(*tables)
Same as
add_tables(), but for reference magnitudes
- add_ref_files(*files)
Same as
add_files(), but for reference magnitudes
- add_mag(ra, dec, mag, mag_err, filt, mjd)
Manually add a single point to the light curve’s magnitude table
- Parameters:
ra, dec (float) – RA and Dec of the source of interest
mag (float) – Magnitude
mag_err (float) – Error on the magnitude
filt (str) – Photometric filter used during observation
mjd (float) – MJD at time of observation
- add_limmag(ra, dec, mag, filt, mjd)
Manually add a single point to the light curve’s limiting magnitude table
- Parameters:
ra, dec (float) – RA and Dec of the source of interest
mag (float) – Limiting magnitude
filt (str) – Photometric filter used during observation
mjd (float) – MJD at time of observation
- add_refmag(ra, dec, mag, filt, mjd, mag_err=None)
Manually add a single point to the light curve’s reference magnitude table
- Parameters:
ra, dec (float) – RA and Dec of the source of interest
mag (float) – Reference magnitude
filt (str) – Photometric filter used during observation
mjd (float) – MJD at time of observation
mag_err (float, optional) – Error on the magnitude, if any (default None)
- coords_select(ra, dec, sep=1.0)
Given some light curve, select only data points for measurements taken within sep arcseconds of RA ra and Dec dec
- Parameters:
ra, dec (float) – RA, Dec of the source of interest
sep (float, optional) – Maximum allowed separation from the RA, Dec, in arcseconds (default 1.0)
- Returns:
New
LightCurveobject containing only sources satisfying the condition- Return type:
Notes
Does NOT change the object in-place. Returns a new object.
- set_plot_instructions(filename)
Set the plotting instructions
- Parameters:
filename (str) – Name of .csv file containing plotting instructions
Notes
The .csv should have no header, and should contain separate rows of the form
“u”,”red”,”o”
“g”,”#00ffff”,”s”
…
Indicating the photometric filter, line/marker colour, and marker style to use.
Will not change the marker style for limiting magnitudes, which are fixed at “v” (downwards caret).
- plot(*filters, output='lightcurve.png', title=None, tmerger=None, show_legend=True, connect=True, text=None, mag_min=None, mag_max=None, limmag_min=None, limmag_max=None, refmag_min=None, refmag_max=None)
Plot your light curve!
- Parameters:
*filters (str, optional) – Filter(s) of choice, if we wish to plot only the points for these filters (default None; valid options in
VALID_PHOT_FILTERS)output (str, optional) – Filename for output figure (default “lightcurve.png”; set to None to save no figure)
title (str, optional) – Title for the plot (default None)
tmerger (float, optional) – Time of the merger, in MJD, to plot in time elapsed since merger (default None –> just plot MJD)
show_legend (bool, optional) – Include a legend? (default True)
connect (bool, optional) – Connect points of the same photometric filter with a line, for legibility? (default True)
text (tuple, optional) – Text to place in a text box, in the form (x, y, ‘text you want printed’) (default None)
mag_min, mag_max (float, optional) – Lower, upper limits on the magnitudes in the light curve; omit datapoints outside bounds (default None)
limmag_min, limmag_max (float, optional) – Lower, upper limits on the limiting magnitudes in the light curve; omit datapoints outside bounds (default None)
refmag_min, refmag_max (float, optional) – Lower, upper limits on the reference magnitudes in the light curve; omit datapoints outside bounds (default None)
- Returns:
Figure object, after all plotting
- Return type:
matplotlib.figure.Figure
Notes
“lower” and “upper” limits on the data points are understood in terms of the magnitude system. I.e., m=26 is a lower limit, m=21 is an upper limit.
alala.psfphotom module
- CONTENTS:
PSF_photometry(): Get the effective Point Spread Function (ePSF) of an image, fit all (or as many as desired) stars in the image with the ePSF, get instrumental magnitudes, and then crossmatch with external catalogue to get calibrated magnitudesePSF_FWHM(): Get the full width at half-max (FWHM) of an ePSFcopy_zero_point(): Copy zero point headers from one image to another
- NON-STANDARD PYTHON DEPENDENCIES:
astropy
photutils
astroquery
- NON-PYTHON DEPENDENCIES:
astrometry.net
- alala.psfphotom.PSF_photometry(image_file, mask_file=None, nstars=40, thresh_sigma=5.0, pixelmin=20, elongation_lim=1.4, area_max=500, cutout=35, astrom_sigma=5.0, psf_sigma=5.0, alim=10000, write_xy=False, nsources=None, cat_num=None, sep_max=2.0, write_ePSF=False, ePSF_output=None, plot_ePSF=True, ePSF_plot_output=None, plot_resids=False, resids_output=None, plot_corr=False, corr_output=None, plot_source_offs=False, source_offs_output=None, plot_field_offs=False, field_offs_output=None, gaussian_blur_sigma=30.0, write=False, output=None)
- Parameters:
image_file (str) – Filename for background-subtracted image
mask_file (str, optional) – Filename for a bad pixel mask (default None)
nstars (int, optional) – Maximum number of stars to use in constructing the ePSF (default 40; set to None to impose no limit)
thresh_sigma (float, optional) – Detection sigma to use in image segmentation (default 5.0)
pixelmin (int, optional) – Minimum allowed number of pixels in isophotes to be used in building the ePSF (default 20)
elongation_lim (float, optional) – Maximum allowed elongation of isophotes to used be in building the ePSF (default 1.4)
area_max (float, optional) – Maximum alllowed area for sources to be used in building the ePSF, in square pixels (default 500)
cutout (int, optional) – Size of cutout around each star, in pixels (default 35; must be odd, will be rounded down if even)
astrom_sigma (float, optional) – Sigma threshold for astrometry.net source detection image (default 5.0)
psf_sigma (float, optional) – Sigma of the Gaussian PSF of the image to be used by astrometry.net (default 5.0)
alim (int, optional) – Maximum allowed source area, in pixels**2, beyond which sources will be deblended in astrometry.net (default 10000)
write_xy (bool, optional) – Keep the .xy.fits source list produced by astrometry.net? (default False)
nsources (int, optional) – Limit on number of sources to fit with ePSF for obtaining the zero point (default None –> impose no limit)
cat_num (str, optional) – Vizier catalog number to determine which catalog to cross-match ( default None –> set to PanStarrs 1, SDSS DR12, or 2MASS depending on filter used during observations)
sep_max (float, optional) – Maximum allowed separation between sources when cross-matching to catalog, in pixels (default 2.0 ~ 0.6 arcseconds for WIRCam, 0.37 arcseconds for MegaCam)
write_ePSF (bool, optional) – Write the derived ePSF to a .fits file? (default False)
output_ePSF (str, optional) – Filename for output ePSF fits file (default None –> set by function)
plot_ePSF (bool, optional) – Plot the ePSF? (default True)
ePSF_plot_output (str, optional) – Filename for output ePSF plot (default None –> set by function)
plot_resids (bool, optional) – Plot the residuals of the iterative ePSF fitting? (default False)
resids_output (str, optional) – Filename for output residuals plot (default None –> set by function)
plot_corr (bool, optional) – Plot the instrumental magnitude versus castalogue magnitude correlation used to obtain the zero point (default False)
corr_output (str, optional) – Filename for output correlation plot (default None –> set by function)
plot_source_offs (bool, optional) – Plot offsets between image WCS and catalog WCS (default False)
source_offs_output (str, optional) – Filename for output source offsets plot (default None –> set by function)
plot_field_offs (bool, optional) – Plot offsets across the field, with a Gaussian blur to visualize large-scale structure in the offsets, if any
field_offs_output (str, optional) – Filename for output field offsets plot (default None –> set by function)
gaussian_blur_sigma (float, optional) – Sigma of the Gaussian blur to use in the field offsets plot, if plotting (default 30.0)
write (bool, optional) – Write the table of calibrated sources with PSF photometry to a file? (default False)
output (str, optional) – Name for output fits table of sources (default None –> set by function)
- Returns:
Table of all PSF-fit sources, with their calibrated magnitudes
- Return type:
TYPE
Notes
Using image segmentation, find as many sources as possible in the image with some constraints on number of pixels, elongation, and area. Use these sources to build an empirical effective PSF (ePSF). Use a list of sources found by astrometry.net to fit the ePSF to all of those sources. Compute the instrumental magnitude of all of these sources. Query the correct online catalogue for the given filter to crossmatch sources in the image with those in the catalogue (e.g., Pan-STARRS 1). Find the zero point which satisfies AB_mag = ZP + instrumental_mag and gets the calibrated AB mags for all PSF-fit sources.
- alala.psfphotom.ePSF_FWHM(epsf_data)
Obtain the full width at half-max (FWHM) of an ePSF.
- Parameters:
epsf_data (str, np.ndarray) – Fits file containing ePSF data or the data array itself
- Returns:
FWHM of the ePSF
- Return type:
float
- alala.psfphotom.copy_zero_point(source_file, target_file)
Copy the zero point headers from source_file to target_file
- Returns:
zp_mean (float) – Zero points mean
zp_med (float) – Zero points median
zp_std (float) – Zero points standard deviation
Notes
Copy the zero point obtained via PSF photometry from one fits header to another. Useful when one uses a background-subtracted image to do PSF photometry, obtains the zero point, and then wants to perform aperture photometry on the original, unsubtracted image.
alala.stack module
Module contents
Top-level package for alala.