snsim.sample

SimSample class used to store simulations.

Classes

SimSample

Class to store simulated SN sample.

Module Contents

class snsim.sample.SimSample(sample_name, sim_lcs, header, dir_path=None)[source]

Class to store simulated SN sample.

Parameters:
  • sample_name (str) – Name of the sample.

  • sim_lcs (list(astropy.Table)) – The simulated lightcurves.

  • header (dict) – Simulation header.

  • model_dir (str, opt) – The path to the simulation model files.

  • file_path (str, opt) – Path of the sample.

  • class. (Initialize SimSample)

classmethod fromDFlist(sample_name, sim_lcs, header, dir_path=None)[source]

Initialize the class from a list of pandas.DataFrame.

Parameters:
  • cls (SimSample class) – The SimSample class.

  • sim_file (str) – The file to load.

  • model_dir (str, opt) – The directory of the configuration files of the sim model.

  • sample_name (str) – Name of the simulation.

  • sim_lcs (list(pandas.DataFrame)) – The sim lightcurves.

  • header (dict) – Simulation header.

Returns:

A SimSample class with the simulated lcs.

Return type:

SimSample class object

classmethod fromFile(sim_file, engine='pyarrow')[source]

Initialize the class from a fits or pickle file.

Parameters:
  • cls (SimSample class) – The SimSample class.

  • sim_file (str) – The file to load.

  • model_dir (str, opt) – The directory of the configuration files of the sim model.

  • engine (str) – Engine to use to open the file pyarrow or fastparquet.

Returns:

A SimSample class with the simulated lcs.

Return type:

SimSample class object

get_obj_sim_model(obj_ID)[source]

Get th sim model of one obj.

Parameters:

obj_ID (int) – ID of the obj.

Returns:

sncosmo sim model of the obj.

Return type:

sncosmo.Model

set_fit_model(model, model_dir=None, mw_dust=None)[source]

Set the fit with a given SNCosmo Model.

Parameters:
  • model (sncosmo.models.Model or str) – A sncosmo Model or a model name for utils.init_sn_model(model, model_dir).

  • model_dir (str, opt) – In case you want to set your model via utils.init_sn_model(model, model_dir).

  • mw_dust (dict, opt) – Milky Wat dust model to apply. | mw_dust | ├── model : str (model name) | └── rv : float, opt

Returns:

Set the self._fit_model attribute.

Return type:

None

fit_lc(obj_ID=None, **kwargs)[source]

Fit all or just one SN lightcurve(s).

Parameters:

ID (int, default is None) – The SN ID, if not specified all SN are fit.

Returns:

Directly modified the _fit_res attribute.

Return type:

None

Notes

Use snc_fitter from utils

write_mod(formats=['pkl', 'parquet'])[source]

Write a file containing only the modified SN epochs.

Parameters:

formats (list(str) or str, opt) – The output formats, ‘pkl’ or ‘fits’.

Returns:

Just write a file.

Return type:

None

write_fit(fit_model_name, write_path=None)[source]

Write fits results in fits format.

Returns:

Write an output file.

Return type:

None

Notes

Use write_fit from utils.

plot_hist(key, ax=None, **kwargs)[source]

Plot the histogram of the key metadata.

Parameters:
  • key (str) – A key of lightcurves metadata.

  • ax (matplotlib.axis, opt) – ax on which plot the histogram.

  • **kwargs (type) – matplotlib plot options.

Returns:

Description of returned object.

Return type:

type

plot_lc(obj_ID, plot_sim=True, plot_fit=False, **kwargs)[source]

Plot the given SN lightcurve.

Parameters:
  • obj_ID (int) – The Object ID.

  • mag (boolean, default = False) – If True plot the magnitude instead of the flux.

  • zp (float) – Used zeropoint for the plot.

  • plot_sim (boolean, default = True) – If True plot the theorical simulated lightcurve.

  • plot_fit (boolean, default = False) – If True plot the fitted lightcurve.

  • Jy (boolean, default = False) – If True plot in Jansky.

  • mod (boolean, default = False) – If True use the self.modified_lcs rather than self.sim_lcs

Returns:

Just plot the SN lightcurve !

Return type:

None

Notes

Use plot_lc from utils.

plot_ra_dec(plot_vpec=False, field_dic=None, field_size=None, **kwarg)[source]

Plot a mollweide map of ra, dec.

Parameters:
  • plot_vpec (boolean) – If True plot a vpec colormap.

  • field_dic (dict(int : dict(str : float))) – Dict of fields coordinates -> Field_ID : {‘RA’, ‘Dec’}

  • field_size (list(float, float)) – The size of the field [RA, Dec]

Returns:

Just plot the map.

Return type:

None

get(key, mod=False)[source]

Get an array of sim_lc metadata.

Parameters:

key (str) – The metadata to access.

Returns:

The array of the key metadata for all SN.

Return type:

numpy.ndarray

get_peakmags(band, magsys='ab')[source]

Get peak apparent magnitude in any band.

Parameters:
  • band (str) – The band, the name has to be in sncosmo registry

  • magsys (str) – The magnitude system, default: ab.

Returns:

The array of the peak apparent magnitude for all SN.

Return type:

numpy.ndarray

property name

Get sample name.

property header

Get header.

property n_obj

Get SN number.

property sim_lcs

Get sim_lcs.

property meta

Get lcs meta dict.

property sim_model

Get sim model.

property fit_model

Get fit model.

property fit_res

Get fit results list.