Sample#

class Sample(targets, setup_spectrograph=True)[source]#

Bases: object

A 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. LazuliSupernova instances.

  • setup_spectrograph (bool, optional) – If True, set the Lazuli field of each target according to its redshift (see setup_spectrograph). This requires Lazuli targets with a redshift. 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_down

Call a method (or get an attribute) of each target.

change_property

Change simulation parameters of all targets.

from_sneia

Create a Sample of SALT Type Ia supernovae.

get_data_volume

Get the data volume of each target.

get_exposure_time

Get the total exposure time of each target.

get_readout_config

Get the read-out configuration of each target.

get_summary_stats

Get the data volume, exposure time and read-out mode of each target.

get_target

Retrieve a target from the sample by index.

get_total_surveyduration

Estimate the duration of a survey observing sample_size targets.

setup_spectrograph

Set the Lazuli field of each target according to its redshift.

setup_to_snr

Find, for each target, the read-out configuration reaching a target SNR.

Attributes

ntargets

Number of targets in the sample (int).

targets

Targets of the sample (list).

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 if mapargs is given. Default is True.

  • level_down (str, optional) – Nested attribute of each target to apply which to, e.g. "simulation" to use target.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")
change_property(**kwargs)[source]#

Change simulation parameters of all targets.

Parameters:

**kwargs – Parameters to update, as name=value, passed to update for each target.

Returns:

list – Output of update for each target (None).

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 (float or array_like, optional) – SALT color c of the supernovae. Default is 0.

  • stretchs (float or array_like, optional) – SALT stretch x1 of the supernovae. Default is 0.

  • **kwargs – Goes to LazuliSupernova, for all targets (e.g. phase).

Returns:

Sample – A sample of LazuliSupernova targets, with their field set up according to redshift (see setup_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 to get_exposure_time. Only False is currently supported: the dicts returned with True cannot be converted to units. Default is False.

  • **kwargs – Goes to get_exposure_time.

Returns:

numpy.ndarray – Exposure time of each target, in units.

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_target(index)[source]#

Retrieve a target from the sample by index.

Parameters:

index (int) – The index of the target to retrieve.

Returns:

object – The target at index.

get_total_surveyduration(sample_size=8000, fraction_survey=0.4, units='yr')[source]#

Estimate the duration of a survey observing sample_size targets.

The mean exposure time of the sample is scaled to sample_size targets and divided by the fraction of the survey time spent on these observations: sum(exptime) * sample_size / ntargets / fraction_survey.

Parameters:
  • sample_size (int, optional) – Total number of targets in the survey. Default is 8000.

  • fraction_survey (float, optional) – Fraction of the survey time spent observing these targets. Default is 0.4.

  • units (str, optional) – Unit of the returned duration (any astropy time unit). Default is "yr".

Returns:

float – Survey duration in units.

setup_spectrograph(redshift_cut=0.8)[source]#

Set the Lazuli field of each target according to its redshift.

Targets with redshift <= redshift_cut are observed in the "narrow" field, the others in the "wide" field (see change_spectrograph).

Parameters:

redshift_cut (float, optional) – Redshift threshold between the narrow and wide fields. Default is 0.8.

Returns:

None

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, snr is given per spectral resolution element, otherwise per wavelength bin. Default is True.

  • lbda_range (list of float, optional) – Wavelength range [min, max] in Angstrom over which the SNR is computed. Default is [4000, 6800].

  • frame (str, optional) – Reference frame of lbda_range: "rest" or "obs". Default is "rest".

  • statistic (callable, optional) – Function used to summarise the SNR over lbda_range. Default is numpy.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).