analysis.utils¶
The utils
module provides a variety of general utility functions used across the analysis package.
Usage Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from sndata.csp import dr3
from analysis import utils
# Convert dates from the Snoopy or MJD formats to JD format
dates = [350, 53350] # snoopy and MJD respectively
jd_dates = utils.convert_to_jd(dates)
print(jd_dates)
# Get certain CSP data for a given target
t0 = utils.get_csp_t0(('2005kc'))
ebv = utils.get_csp_ebv(('2005kc'))
# Iterate over photometric data while only including targets with a published t0 and E(B-V)
for data in dr3.iter_data(filter_func=utils.filter_has_csp_data)
|
Function Documentation¶
-
analysis.utils.
calc_model_chisq
(data, result, model)[source]¶ Calculate the chi-squared for a given data table and model
Chi-squared is calculated using parameter values from
model
. Degrees of freedom are calculated using the number of varied parameters specified is theresult
object.Parameters: - data (Table) – An sncosmo input table
- model (Model) – An sncosmo Model
- result (Result) – sncosmo fitting result
Returns: The un-normalized chi-squared The number of data points used in the calculation
-
analysis.utils.
filter_has_csp_data
(data_table)[source]¶ A filter function for an SNData table iterator
Returns whether the object ID associated with a data table has an available t0 and E(B - V) value.
Parameters: data_table (Table) – A table from sndata Returns: A boolean
-
analysis.utils.
get_csp_ebv
(obj_id)[source]¶ Get the E(B - V) value published by CSP DR1 for a given object
Parameters: obj_id (str) – The object Id value Returns: The published E(B - V) value
-
analysis.utils.
get_csp_t0
(obj_id)[source]¶ Get the t0 value published by CSP DR3 for a given object
Parameters: obj_id (str) – The object Id value Returns: The published date of maximum in JD format
-
analysis.utils.
get_effective_wavelength
(band_name)[source]¶ Get the effective wavelength for a given band
Band name must be registered with SNCosmo.
Parameters: band_name (str) – The name of a registered bandpass Returns: The effective wavelength in Angstroms
-
analysis.utils.
parse_spectra_table
(data)[source]¶ Convert spectral data from an astropy table to arrays
Parameters: data (Table) – A table of spectral data from sncosmo Returns: - A sorted list of observed MJD dates for each spectra
- A 2d list of wavelength values for each date
- A 2d list of flux values for each date