snat_sim.sn_magnitudes

The sn_magnitudes.py module is responsible for calculating supernova magnitudes as a function of PWV and redshift. Functionality includes calculating magnitudes directly from a supernova model or via a light-curve fit.

Warning

DO NOT USE THIS MODULE FOR NEW DEVELOPMENT. This module is deprecated. All functionality provided by this module is now available elsewhere in the package.

Module Docs

snat_sim.sn_magnitudes.get_config_pwv_vals(config_path=PosixPath('/home/runner/work/SN-PWV/SN-PWV/data/defaults/ref_pwv.yaml'))[source]

Retrieve PWV values to use as reference values

Returned values include:
  • Lower pwv bound for calculating slope

  • Reference PWV value for normalizing delta m

  • Upper pwv bound for calculating slope

Parameters:

config_path (Union[str, Path]) – Path of config file if not default

Return type:

Dict[str, Union[float, float16, float32, float64, float128, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, longlong, ulonglong]]

Returns:

Dictionary with PWV values in mm

snat_sim.sn_magnitudes.tabulate_mag(model, pwv_arr, z_arr, bands, verbose=True)[source]

Calculate apparent magnitude due to presence of PWV

Magnitude is calculated for the model by adding PWV effects to a model and leaving all other parameters unchanged.

Parameters:
  • model (Union[SNModel, Model]) – The sncosmo model to use in the simulations

  • pwv_arr (Collection[Union[float, float16, float32, float64, float128, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, longlong, ulonglong]]) – Array of PWV values

  • z_arr (Collection[Union[float, float16, float32, float64, float128, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, longlong, ulonglong]]) – Array of redshift values

  • bands (List[str]) – Name of the bands to tabulate magnitudes for

  • verbose (bool) – Show a progress bar

Return type:

Dict[str, ndarray]

Returns:

A dictionary with 2d arrays for the magnitude at each PWV and redshift

snat_sim.sn_magnitudes.tabulate_fiducial_mag(model, z_arr, bands, fid_pwv_dict=None)[source]

Get SN magnitudes corresponding to the fiducial atmosphere

Returns a dictionary of the form

{<band>: [<slope start mag> , <reference pwv mag>, <slope end mag>]

Parameters:
  • model (SNModel) – The sncosmo model to use in the simulations

  • z_arr (ndarray) – Array of redshift values

  • bands (List[str]) – Name of the bands to tabulate magnitudes for

  • fid_pwv_dict (Optional[Dict[str, Union[float, float16, float32, float64, float128, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, longlong, ulonglong]]]) – Config dictionary for fiducial atmosphere

Return type:

Dict[str, ndarray]

Returns:

A dictionary with fiducial magnitudes in each band

snat_sim.sn_magnitudes.correct_mag(model, mag, params, alpha=0.141, beta=3.101)[source]

Correct fitted supernova magnitude for stretch and color

calibrated mag = mag + α * x1 - β * c

Parameters:
  • model (SNModel) – Model used to fit the given magnitudes

  • mag (ndarray) – (n)d array of magnitudes for pwv and redshift

  • params (ndarray) – (n+1)d array with dimensions for pwv, redshift, parameter

  • alpha (Union[float, float16, float32, float64, float128, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, longlong, ulonglong]) – Alpha parameter value

  • beta (Union[float, float16, float32, float64, float128, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, longlong, ulonglong]) – Beta parameter value

Return type:

ndarray

Returns:

Array of calibrated magnitudes with same dimensions as mag

snat_sim.sn_magnitudes.fit_mag(model, light_curves, vparams, bands, pwv_arr=None, z_arr=None, **kwargs)[source]

Determine apparent mag by fitting simulated light-curves

Returned arrays are shape (len(pwv_arr), len(z_arr)).

Parameters:
  • model (SNModel) – The sncosmo model to use when fitting

  • light_curves (Collection[Table]) – Array of light-curves to fit

  • vparams (List[str]) – Parameters to vary with the fit

  • bands (Collection[str]) – Name of the bands to tabulate magnitudes for

  • pwv_arr (Optional[Collection[Union[float, float16, float32, float64, float128, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, longlong, ulonglong]]]) – Array of PWV values

  • z_arr (Optional[Collection[Union[float, float16, float32, float64, float128, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, longlong, ulonglong]]]) – Array of redshift values

  • sncosmo.fit_lc. (Any arguments for) –

Return type:

Tuple[Dict[str, ndarray], ...]

Returns:

Dictionary with arrays for fitted magnitude at each PWV and redshift Dictionary with arrays for fitted parameters at each PWV and redshift

snat_sim.sn_magnitudes.calc_delta_mag(mag, fiducial_mag, fiducial_pwv)[source]

Determine the change in magnitude relative to the fiducial atmosphere

This is also equivalent to determining the apparent magnitude of a SN normalized to the magnitude at the fiducial atmosphere.

Parameters:
  • mag (Dict[str, ndarray]) – Dictionary with magnitudes in each band

  • fiducial_mag (Dict[str, ndarray]) – Dictionary for fiducial atmosphere mag vals

  • fiducial_pwv (Dict[str, ndarray]) – Dictionary for fiducial atmosphere pwv vals

Return type:

Tuple[Dict[str, ndarray], ...]

Returns:

  • A dictionary with the change in magnitude for each band

  • A dictionary with the slope (mag / pwv) for each band

snat_sim.sn_magnitudes.calc_mu_for_model(model, cosmo=FlatLambdaCDM(H0=70 km / (Mpc s), Om0=0.295, Tcmb0=0 K, Neff=3.04, m_nu=None, Ob0=None))[source]

Calculate the distance modulus of a model

Parameters:
  • model (SNModel) – An sncosmo model

  • cosmo (Cosmology) – Cosmology to use in the calculation

Return type:

float

Returns:

mu = m_B - M_B

snat_sim.sn_magnitudes.calc_mu_for_params(model, params)[source]

Calculate the distance modulus for an array of fitted params

Parameters:
  • model (SNModel) – The sncosmo model to use in the simulations

  • params (ndarray) – n-dimensional array of parameters

Return type:

ndarray

Returns:

An array of distance moduli with one dimension less than params

snat_sim.sn_magnitudes.calc_calibration_factor_for_params(model, params)[source]

Calculate the distance modulus for an array of fitted params

returns constants.alpha * x_1 - constants.beta * c

Parameters:
  • model (SNModel) – The sncosmo model to use in the simulations

  • params (ndarray) – n-dimensional array of parameters

Return type:

ndarray

Returns:

An array of calibration factors with one dimension less than params