Sample#
- class Sample(targets, setup_spectrograph=True)[source]#
Bases:
objectA collection of targets handled together.
This class manages multiple targets and provides methods to set up their spectrograph field and read-out configuration, retrieve exposure time and data volume estimates, and call any target method on all of them (see
call_down).- Parameters:
targets (
list) – Targets of the sample, e.g.LazuliSupernovainstances.setup_spectrograph (
bool, optional) – If True, set the Lazuli field of each target according to its redshift (seesetup_spectrograph). This requires Lazuli targets with aredshift. Default is True.
Examples
>>> sample = Sample.from_sneia([0.3, 0.6, 1.0]) >>> configs, snrs = sample.setup_to_snr(10) >>> stats = sample.get_summary_stats()
Methods
Call a method (or get an attribute) of each target.
Change simulation parameters of all targets.
Create a Sample of SALT Type Ia supernovae.
Get the data volume of each target.
Get the total exposure time of each target.
Get the read-out configuration of each target.
Get the data volume, exposure time and read-out mode of each target.
Retrieve a target from the sample by index.
Estimate the duration of a survey observing
sample_sizetargets.Set the Lazuli field of each target according to its redshift.
Find, for each target, the read-out configuration reaching a target SNR.
Attributes
- call_down(which, mapargs=None, allow_call=True, level_down='', show_progress=False, **kwargs)[source]#
Call a method (or get an attribute) of each target.
- Parameters:
which (
str) – Name of the method (or attribute) of each target.mapargs (array_like, optional) – Values mapped over targets: each target’s method receives the corresponding entry as first positional argument (see
broadcast_mapping). Default is None.allow_call (
bool, optional) – If True, callable attributes are called; if False, they are returned as is. Ignored ifmapargsis given. Default is True.level_down (
str, optional) – Nested attribute of each target to applywhichto, e.g."simulation"to usetarget.simulation. Default is"".show_progress (
bool, optional) – If True, display a tqdm progress bar. Default is False.**kwargs – Goes to the called method.
- Returns:
list– Output for each target.
Examples
>>> redshifts = sample.call_down("get_properties", "redshift") >>> lbdas = sample.call_down("lbda", level_down="simulation.spectrograph")
- classmethod from_sneia(redshifts, colors=0, stretchs=0, **kwargs)[source]#
Create a Sample of SALT Type Ia supernovae.
- Parameters:
redshifts (array_like) – Redshifts of the supernovae.
colors (
floator array_like, optional) – SALT colorcof the supernovae. Default is 0.stretchs (
floator array_like, optional) – SALT stretchx1of the supernovae. Default is 0.**kwargs – Goes to
LazuliSupernova, for all targets (e.g.phase).
- Returns:
Sample– A sample ofLazuliSupernovatargets, with their field set up according to redshift (seesetup_spectrograph).
- get_data_volume(units='GB')[source]#
Get the data volume of each target.
- Parameters:
units (
str, optional) – Unit of the data volume. Currently ignored: volumes are always returned in GB. Default is"GB".- Returns:
numpy.ndarray– Data volume of each target in GB, all ramps included.
- get_exposure_time(units='second', full=False, **kwargs)[source]#
Get the total exposure time of each target.
- Parameters:
units (
str, optional) – Unit of the returned times (any astropy time unit, e.g."s","hr"). Default is"second".full (
bool, optional) – Passed toget_exposure_time. Only False is currently supported: the dicts returned with True cannot be converted tounits. Default is False.**kwargs – Goes to
get_exposure_time.
- Returns:
numpy.ndarray– Exposure time of each target, inunits.
- get_readout_config()[source]#
Get the read-out configuration of each target.
- Returns:
pandas.DataFrame– One row per target, with columns"nramps","ngroups","nframes_per_group"and"ndrops".
- get_summary_stats()[source]#
Get the data volume, exposure time and read-out mode of each target.
- Returns:
pandas.DataFrame– One row per target, with columns"volume"(GB),"exptime"(s),"nramps","ngroups","nframes_per_group"and"ndrops".
- get_total_surveyduration(sample_size=8000, fraction_survey=0.4, units='yr')[source]#
Estimate the duration of a survey observing
sample_sizetargets.The mean exposure time of the sample is scaled to
sample_sizetargets and divided by the fraction of the survey time spent on these observations:sum(exptime) * sample_size / ntargets / fraction_survey.- Parameters:
- Returns:
float– Survey duration inunits.
- setup_spectrograph(redshift_cut=0.8)[source]#
Set the Lazuli field of each target according to its redshift.
Targets with
redshift <= redshift_cutare observed in the"narrow"field, the others in the"wide"field (seechange_spectrograph).
- setup_to_snr(snr, per_resolution=True, lbda_range=[4000, 6800], frame='rest', statistic=<function mean>, inplace=True, client=None, show_progress=False, **kwargs)[source]#
Find, for each target, the read-out configuration reaching a target SNR.
- Parameters:
snr (
float) – Target signal-to-noise ratio.per_resolution (
bool, optional) – If True,snris given per spectral resolution element, otherwise per wavelength bin. Default is True.lbda_range (
listoffloat, optional) – Wavelength range[min, max]in Angstrom over which the SNR is computed. Default is[4000, 6800].frame (
str, optional) – Reference frame oflbda_range:"rest"or"obs". Default is"rest".statistic (callable, optional) – Function used to summarise the SNR over
lbda_range. Default isnumpy.mean.inplace (
bool, optional) – If True, each target is updated to its configuration. Default is True.client (
dask.distributed.Client, optional) – Dask client to distribute the computation over targets. If None, targets are processed serially. Default is None.show_progress (
bool, optional) – If True, display a tqdm progress bar (serial mode only). Default is False.**kwargs – Goes to
setup_to_snr.
- Returns:
configs (
pandas.DataFrame) – Read-out configuration of each target, with columns"nmd"and"nramps".snrs (
numpy.ndarray) – SNR reached for each target.
- ntargets#
Number of targets in the sample (int).
- targets#
Targets of the sample (list).