Catalog Modules
These modules contain the functions used to query external databases (including NED, PS1, and TNS) for data that astro_ghost needs to run.
NEDQueryFunctions
- astro_ghost.NEDQueryFunctions.getNEDInfo(df)[source]
Gets galaxy information from NED, if it exists.
- Parameters:
df (Pandas DataFrame) – Dataframe of the PS1 objects for which to query NED.
- Returns:
The same dataframe as input, with NED info added.
- Return type:
Pandas DataFrame
- astro_ghost.NEDQueryFunctions.getNEDSpectra(df, path, verbose=False)[source]
Downloads NED spectra for the host galaxy, if it exists.
- Parameters:
df (Pandas DataFrame) – Dataframe containing the associated transients and their host galaxies in PS1.
path (str) – Filepath where NED spectra should be saved.
verbose (boolean) – Whether to print relevant debugging information.
PS1QueryFunctions
- astro_ghost.PS1QueryFunctions.checklegal(table, release)[source]
- Checks if this combination of table and release is acceptable.
Raises a ValueError exception if there is problem.
- Parameters:
- Raises:
ValueError – Raises error if table and release combination are invalid.
- astro_ghost.PS1QueryFunctions.create_dummy_df(nRows=1, fullDF=False)[source]
Creates a dummy PS1 dataframe (useful for running scripts when no sources found).
- Parameters:
fullDF – If True, the dummy DataFrame replaces the full GHOST database.
- Dtype fullDF:
Boolean
- Returns:
Empty Pandas DataFrame with PS1 columns.
- Return type:
Pandas DataFrame
- astro_ghost.PS1QueryFunctions.find_all(name, path)[source]
- Crawls through a directory and all its sub-directories looking for a file matching
'name'. If found, it is returned.
- astro_ghost.PS1QueryFunctions.find_host_info_PS1(df, fn, dict_fn, path, rad, append=0)[source]
Querying PS1 for all objects within rad arcsec of each SN.
- Parameters:
df (Pandas DataFrame) – Dataframe of transient information (name and coordinates).
fn (str) – Filename of PS1 candidate host dataframe.
dict_fn (dictionary) – The filename of the dictionary to keep track of transient-candidate host matches. Keys are transient names, values are lists containing objIDs of all host candidates.
path (str) – The filepath where df will be saved.
rad (float) – The search radius, in arcsec.
append (bool, optional) – If True, append results to fn. If False, create a new file.
- astro_ghost.PS1QueryFunctions.find_host_info_SH(df, fn, dict_fn, path, rad)[source]
VO Cone Search for all objects within rad arcsec of SNe (for Southern-Hemisphere (SH) objects).
- Parameters:
df (Pandas DataFrame) – Dataframe of transient information (name and coordinates).
fn (str) – Filename of PS1 candidate host dataframe.
dict_fn (dictionary) – The filename of the dictionary to keep track of transient-candidate host matches. Keys are transient names, values are lists containing objIDs of all host candidates.
path (str) – The filepath where df will be saved.
rad (float) – The search radius, in arcsec.
append (bool, optional) – If True, append results to fn. If False, create a new file.
- astro_ghost.PS1QueryFunctions.getAllPostageStamps(df, tempSize, path='.', verbose=False)[source]
- Loops through a pandas dataframe and saves PS1 stacked color images of all
host galaxies.
- astro_ghost.PS1QueryFunctions.getDR2_halfLightSizes(ra_arr, dec_arr, rad)[source]
Retrieves half-light radius information from DR2 for panstarrs sources.
- astro_ghost.PS1QueryFunctions.getDR2_petrosianSizes(ra_arr, dec_arr, rad)[source]
Retrieves petrosian radius information from DR2 for panstarrs sources.
- astro_ghost.PS1QueryFunctions.get_PS1_Pic(path, objID, ra, dec, size, band, safe=False)[source]
Downloads PS1 picture (in fits) centered at a given location.
- Parameters:
path (str) – The filepath where the fits file will be saved.
objID (int) – The PS1 objID of the object of interest (to save as filename).
ra (float) – Right ascension of position, in degrees.
dec (float) – Declination of position, in degrees.
size (int) – The extracted image size in pixels (0.25 arcsec/pixel)
band (str) – The PS1 band.
safe (bool, optional) – If True, include the objID of the object of interest in the filename (useful when saving multiple files at comparable positions).
- astro_ghost.PS1QueryFunctions.get_PS1_type(path, ra, dec, size, band, type)[source]
Download and save PS1 imaging data in a given band of a given type.
- Parameters:
path (str) – filepath where the image will be saved.
ra (float) – Right ascension of position, in degrees.
dec (float) – Declination of position, in degrees.
size (int) – The extracted image size in pixels (0.25 arcsec/pixel)
band (str) – The PS1 band.
type (str) – The type of imaging data to obtain. Options are given below for the PS1 stack. 'stack.mask' - indicate which pixels in the stack are good and which are bad 'stack.wt' - stack variance images 'stack.num' - contain the number of warps with valid data which contributed to each pixel 'stack.exp' - contain the exposure time in seconds which contributed to each pixel 'stack.expw' - weighted exposure time maps See more information at https://outerspace.stsci.edu/display/PANSTARRS/PS1+Stack+images.
- astro_ghost.PS1QueryFunctions.get_hosts(path, transient_fn, fn_Host, rad)[source]
- Wrapper function for getting candidate host galaxies in PS1 for dec>-30 deg and
in Skymapper for dec<-30 deg.
- Parameters:
path (str) – Filepath where csv of candidate hosts should be saved.
transient_fn (str) – Filename of csv containing the transients to associate (and their coordinates).
fn_Host (str) – Filename of csv containing candidate host galaxy properties.
rad (float) – Search radius of the algorithm, in arcseconds.
- Returns:
Dataframe of all candidate host galaxies.
- Return type:
Pandas DataFrame
- astro_ghost.PS1QueryFunctions.getcolorim(ra, dec, size=240, output_size=None, filters='grizy', format='jpg')[source]
Get a PS1 color image at a sky position.
- Parameters:
ra (float) – Right ascension of position, in degrees.
dec (float) – Declination of position, in degrees.
size (int) – The extracted image size in pixels (0.25 arcsec/pixel)
output_size (int) – output (display) image size in pixels (default = size). The output_size has no effect for fits format images.
filters (str) – The string with filters to include.
format (str) – The data format (options are 'jpg', 'png' or 'fits').
- Returns:
The image.
- Return type:
PIL Image
- astro_ghost.PS1QueryFunctions.getimages(ra, dec, size=240, filters='grizy', type='stack')[source]
Query ps1filenames.py service to get a list of images.
- Parameters:
- Returns:
The results of the search for relevant images.
- Return type:
Astropy Table
- astro_ghost.PS1QueryFunctions.geturl(ra, dec, size=240, output_size=None, filters='grizy', format='jpg', color=False, type='stack')[source]
Get the URL for images in the table.
- Parameters:
ra (float) – Right ascension of position, in degrees.
dec (float) – Declination of position, in degrees.
size (int) – The extracted image size in pixels (0.25 arcsec/pixel)
output_size (int) – output (display) image size in pixels (default = size). The output_size has no effect for fits format images.
filters (str) – The string with filters to include.
format (str) – The data format (options are "jpg", "png” or "fits").
color (bool, optional) – If True, creates a color image (only for jpg or png format). If False, return a list of URLs for single-filter grayscale images.
- Returns:
The url for the image to download.
- Return type:
- astro_ghost.PS1QueryFunctions.mastQuery(request)[source]
Perform a MAST query.
- Parameters:
request (dictionary) – The MAST request json object.
- Returns:
The response HTTP headers.
- Return type:
HTTP header
- Returns:
The data obtained.
- Return type:
- astro_ghost.PS1QueryFunctions.ps1cone(ra, dec, radius, table='stack', release='dr1', format='csv', columns=None, baseurl='https://catalogs.mast.stsci.edu/api/v0.1/panstarrs', verbose=False, **kw)[source]
Do a cone search of the PS1 catalog. Note that this is just a thin wrapper for the function 'ps1search'.
- Parameters:
ra (float) – Right ascension of central coordinate, in J200 degrees.
dec (float) – Declination of central coordinate, in J2000 degrees.
radius (float) – Search radius, in degrees (<= 0.5 degrees)
table (str) – Table type. Can be 'mean', 'stack', or 'detection'
release (str) – The Pan-STARRS data release. Can be 'dr1' or 'dr2'.
format (str) – Can be 'csv', 'votable', or 'json'.
columns (str) – Column names to include (None means use defaults).
baseurl (str) – Base URL for the request.
verbose (bool) – If true, print info about request.
**kw (dictionary) – Other parameters (e.g., 'nDetections.min':2). Note that this is required!
- Returns:
Result of PS1 query, in 'csv', 'votable', or 'json' format.
- Return type:
Same as ‘format’
- astro_ghost.PS1QueryFunctions.ps1crossmatch_GLADE(foundGladeHosts)[source]
Gets PS1 photometry for GLADE sources by crossmatching.
- Parameters:
foundGladeHosts (Pandas DataFrame) – DataFrame of Glade sources to cross-match in ps1
- astro_ghost.PS1QueryFunctions.ps1metadata(table='mean', release='dr1', baseurl='https://catalogs.mast.stsci.edu/api/v0.1/panstarrs')[source]
- Return metadata for the specified catalog and table. Snagged from the
wonderful API at https://ps1images.stsci.edu/ps1_dr2_api.html.
- astro_ghost.PS1QueryFunctions.ps1search(table='mean', release='dr1', format='csv', columns=None, baseurl='https://catalogs.mast.stsci.edu/api/v0.1/panstarrs', verbose=False, **kw)[source]
Do a general search of the PS1 catalog (possibly without ra/dec/radius).
- Parameters:
table (str) – Table type. Can be 'mean', 'stack', or 'detection'
release (str) – The Pan-STARRS data release. Can be 'dr1' or ‘dr2'.
format (str) – Can be 'csv', 'votable', or 'json'.
columns (str) – Column names to include (None means use defaults).
baseurl (str) – Base URL for the request.
verbose (bool) – If true, print info about request.
**kw (dictionary) – Other parameters (e.g., 'nDetections.min':2). Note that this is required!
- Returns:
Result of PS1 query, in 'csv', 'votable', or 'json' format.
- Return type:
Same as ‘format’
- astro_ghost.PS1QueryFunctions.resolve(name)[source]
Get the RA and Dec for an object using the MAST name resolver.