Supplemental Modules
These modules are not strictly necessary for the host association, but provide useful ancillary data about the associated hosts.
photoz_helper
- astro_ghost.photoz_helper.build_sfd_dir(fname='./sfddata-master.tar.gz')[source]
Downloads directory of Galactic dust maps for extinction correction.
- Parameters:
fname (str) – Filename for dustmaps.
- astro_ghost.photoz_helper.calc_photoz(hosts)[source]
- PhotoZ beta: not tested for missing objids.
photo-z uses a artificial neural network to estimate P(Z) in range Z = (0 - 1) range_z is the value of z posterior is an estimate PDF of the probability of z point estimate uses the mean to find a single value estimate error is an array that uses sampling from the posterior to estimate a std dev. Relies upon the sfdmap package, (which is compatible with both unix and windows), found at https://github.com/kbarbary/sfdmap.
- Parameters:
hosts (pandas DataFrame) – The matched hosts from GHOST.
- Returns:
The matched hosts from GHOST, with photo-z point estimates and uncertainties.
- Return type:
pandas DataFrame
- astro_ghost.photoz_helper.evaluate(X, mymodel, range_z)[source]
Evaluate the MLP for a set of PS1 inputs, and return predictions.
- Parameters:
X (array-like) – PS1 properties of associated hosts.
mymodel (tensorflow keras Model) – MLP model for photo-z estimation.
range_z (array-like) – Grid over which to evaluate the posterior distribution of photo-zs.
- Returns:
Posterior distributions for the grid of redshifts defined as `np.linspace(0, 1, n)`
- Return type:
numpy ndarray shape of (df.shape[0], n)
- Returns:
Means
- Return type:
numpy ndarray shape of (df.shape[0],)
- Returns:
Standard deviations
- Return type:
numpy ndarray shape of (df.shape[0],)
- astro_ghost.photoz_helper.fetch_information_serially(url, data, verbose=False, format='csv')[source]
A helper function called by serial_objID_search– Queries PanStarrs API for data.
- astro_ghost.photoz_helper.get_common_constraints_columns()[source]
Helper function that returns a dictionary of constraints used for the matching objects in PS1 archive, and the columns of data we requre.
- astro_ghost.photoz_helper.get_photoz(df)[source]
Evaluate photo-z model for Pan-STARRS forced photometry.
- Parameters:
df (pandas DataFrame) – Pan-STARRS forced mean photometry data, you can get it using `ps1objIDsearch` from this module, Pan-STARRS web-portal or via astroquery i.e., `astroquery.mast.Catalogs.query_{criteria,region}(…, catalog='Panstarrs',table='forced_mean')`
- Returns:
Posterior distributions for the grid of redshifts defined as `np.linspace(0, 1, n)`
- Return type:
numpy ndarray shape of (df.shape[0], n)
- Returns:
Means
- Return type:
numpy ndarray shape of (df.shape[0],)
- Returns:
Standard deviations
- Return type:
numpy ndarray shape of (df.shape[0],)
- astro_ghost.photoz_helper.get_photoz_weights(fname='./MLP_lupton.hdf5')[source]
Get weights for MLP photo-z model.
- Parameters:
fname (str) – Filename of saved MLP weights.
- astro_ghost.photoz_helper.load_lupton_model(model_path)[source]
Helper function that defines and loads the weights of our NN model and the output space of the NN.
- Parameters:
model_path (str) – path to the model weights.
- Returns:
Trained photo-z MLP.
- Return type:
tensorflow keras Model
- Returns:
Array of binned redshift space corresponding to the output space of the NN
- Return type:
numpy ndarray
- astro_ghost.photoz_helper.post_url_parallel(results, YSE_ID)[source]
TODO: unused function. The querying of PS servers is the slowest part of the script. How to parallelize?
- astro_ghost.photoz_helper.post_url_serial(results, YSE_ID)[source]
A helper function called by serial_objID_search. Post-processes the data retrieved from PS1 Servers into a pandas.DataFrame object.
- astro_ghost.photoz_helper.preprocess(DF, PATH='../DATA/sfddata-master/', ebv=True)[source]
Preprocesses the data inside pandas.DataFrame object returned by serial_objID_search to the space of Inputs of our Neural Network.
- Parameters:
DF (pandas DataFrame) – Dataframe object containing the data for each matched objID
PATH (str) – string path to extinction maps data
ebv (False) – boolean for lookup of extinction data. If False, all extinctions set to 0.
- Returns:
Preprocessed inputs ready to be used as input to NN
- Return type:
numpy ndarray
- astro_ghost.photoz_helper.ps1objIDsearch(objID, table='mean', release='dr1', format='csv', columns=None, baseurl='https://catalogs.mast.stsci.edu/api/v0.1/panstarrs', verbose=False, **kw)[source]
Do an object lookup by objID.
- Parameters:
objID (List of objIDs) – list of objIDs (or dictionary?)
table (str) – Can be 'mean', 'stack', or 'detection'.
release (str) – Can be ‘dr1’ or ‘dr2’.
format (str) – Can be ‘csv’, ‘votable’, or ‘json’
columns (arrray-like) – list of column names to include (None means use defaults)
baseurl (str) – base URL for the request
verbose (bool,optional) – print info about request
**kw (dictionary) – other parameters (e.g., ‘nDetections.min’:2)
- astro_ghost.photoz_helper.serial_objID_search(objIDs, table='forced_mean', release='dr2', columns=None, verbose=False, **constraints)[source]
Given a list of ObjIDs, queries the PS1 server these object’s Forced Mean Photometry, then returns matches as a pandas.DataFrame.
- Parameters:
objIDs (list) – list of PS1 objIDs for objects user would like to query
table (str) – Which table to perform the query on. Default ‘forced_mean’
release (str) – Which release to perform the query on. Default ‘dr2’
columns (list or None) – list of what data fields to include; None means use default columns. Default None
verbose (bool) – boolean setting level of feedback user received. default False
**constraints (dict) – Keyword dictionary with an additional constraints for the PS1 query
- Returns:
list of pd.DataFrame objects. If a match was found, then the Dataframe contains data, else it only contains a local integer.
- Return type:
pd.DataFrame