snsim.utils¶
This module contains usefull function for the simulation.
Classes¶
Class to generate random variable on custom dist. |
Functions¶
|
Gaussian function. |
function that read DES X1-mass probability file and return |
|
|
Load an astropy cosmological model. |
|
|
|
Compute a value of M0 corresponding the cosmology used in the simulation. |
|
Take a date and give a astropy.time.Time object. |
|
Compute the cumulative distribution function of redshift. |
|
Generate random parameters using an asymetric Gaussian distribution. |
|
Compute the redshifts of a list of objects relative to the CMB. |
|
Initialise a sncosmo source. |
|
Rescale the flux to a given zeropoint. |
|
Give the factor to convert flux in uJy. |
|
|
|
|
|
list names of templates in sncosmo built-in sources catalogue |
|
from a given list of sncosmo Template select the ones from Vincenzi et al. 2019 |
|
Make a sinus interpolation of a function. |
|
Create child random seeds. |
|
compute the mass dependent weights for HOST - SN matching |
|
compute the SFR dependent weights for HOST - SN matching |
|
compute the SFR dependent weights for HOST - SN matching |
Module Contents¶
- class snsim.utils.CustomRandom(pdf, xmin, xmax, ndiv=10000.0, dx=None)[source]¶
Class to generate random variable on custom dist.
- Parameters:
pdf (lambda function) – Function that return the pdf of the vairable x.
xmin (float) – Inferior bound of the distribution.
xmax (float) – Superior bound of the distribution.
ndiv (float, optional) – Number of division used to integrate the pdf.
dx (float, optional) – Precision used to integrate the pdf.
Notes
If dx and ndiv are set, only dx will be used. If none of the 2 is set, the default will be ndiv=1e4
Init the CustomRandom class.
- x¶
- dx¶
- pdfx¶
- norm¶
- cdf¶
- plot_pdf(ax=None)[source]¶
Plot the pdf function.
- Parameters:
ax (matplotlib axes, optional) – Figure axis, by default None
- snsim.utils.reshape_prob_data()[source]¶
function that read DES X1-mass probability file and return grid values fro interpolation
- snsim.utils.set_cosmo(cosmo_dic)[source]¶
Load an astropy cosmological model.
- Parameters:
cosmo_dic (dict) – A dict containing cosmology parameters.
- Returns:
An astropy cosmological model.
- Return type:
astropy.cosmology.object
- snsim.utils.scale_Mabs_cosmology(h, Mabs_to_scale, h_ref)[source]¶
Compute a value of M0 corresponding the cosmology used in the simulation.
- snsim.utils.init_astropy_time(date)[source]¶
Take a date and give a astropy.time.Time object.
- snsim.utils.compute_z_cdf(z_shell, shell_time_rate)[source]¶
Compute the cumulative distribution function of redshift.
- Parameters:
z_shell (numpy.ndarray(float)) – The redshift of the shell edges.
shell_time_rate (numpy.ndarray(float)) – The time rate of each shell.
- Returns:
redshift, CDF(redshift).
- Return type:
- snsim.utils.asym_gauss(mu, sig_low, sig_high=None, seed=None, size=1)[source]¶
Generate random parameters using an asymetric Gaussian distribution.
- snsim.utils.compute_zpcmb(ra, dec, cmb)[source]¶
Compute the redshifts of a list of objects relative to the CMB.
- snsim.utils.init_snia_source(name, model_dir=None, version=None)[source]¶
Initialise a sncosmo source.
- Parameters:
- Returns:
sncosmo Model corresponding to input configuration.
- Return type:
- snsim.utils.Templatelist_fromsncosmo(source_type=None)[source]¶
list names of templates in sncosmo built-in sources catalogue :param source_type: type of sources could be snii,sniipl,sniib,sniin,snib/c,snic,snib or snic-bl :type source_type: str
- Return type:
list on names of sources with the given source_type from snscomo catalogue
- snsim.utils.select_Vincenzi_template(model_list, corr=None)[source]¶
- from a given list of sncosmo Template select the ones from Vincenzi et al. 2019
- model_listlist
starting list of templates
- corrbool
If True select templates that have been corrected for the host galaxy dust
list of template names
- snsim.utils.sine_interp(x_new, fun_x, fun_y)[source]¶
Make a sinus interpolation of a function.
- Parameters:
x_new (numpy.ndarray(float)) – Points where interpolate.
fun_x (numpy.ndarray(float)) – x values of the function
fun_y (numpy.ndarray(float)) – values of the function evaluate at fun_x
- Returns:
Values of the function at x_new.
- Return type:
- Raises:
ValueError – fun_x and fun_y don’t have the same length
ValueError – x_new is out of range
- snsim.utils.gen_rndchilds(seed, size=1)[source]¶
Create child random seeds.
- Parameters:
seed (numpy.random.SeedSequence or int) – A random seed.
size (int, optional) – number of child random seed to generate, by default 1
- Returns:
The desired number of child random seeds
- Return type:
- snsim.utils.compute_weight_mass_for_type(mass, sn_type, cosmology)[source]¶
compute the mass dependent weights for HOST - SN matching