SurveySampler#

class uvex_transients.phase_space.sampling.core.SurveySampler(schedule: SurveySchedule, mission=None, *, band: str | None = None, snr_threshold: float | None = None, n_visits: int | None = None, exclude_first_visit_detections: bool | None = None, detection: Sequence[Mapping] | None = None, mag_limit: float | None = None, time_bins: int | None = None, nside: int | None = None, order: str | None = None, cosmology: Cosmology | None = None, schedule_name: str | None = None)[source]#

Count the recoveries of a transient simulated against a survey: what every survey-backed sampler shares.

A subclass is built in its own __init__, which calls super().__init__ and then _configure() once, with its space, the redshift out to which the volume is tabulated and the settings it adds to the ones recorded here. It supplies make_transient(), redshift_limit(), _place() and _log_window(). If its axes are parameters of the SED, it lists them in parameter_axes, a tuple of ParameterAxis, and _place() calls _fix_parameters() for them and only sets the window and the redshift limit itself.

Every setting that is None (the default) takes its default from the configuration, which is resolved once by SurveySettings: config["phase_space.<kind>.<name>"] if the kind of the sampler (or a kind it is built on) has the key, else config["phase_space.detection.<name>"] or config["phase_space.simulation.<name>"]. A subclass takes these as **survey and passes them on, so a new survey setting is added in this one place.

Parameters:
  • schedule (SurveySchedule) – The survey to recover events against.

  • mission (str or m4opt.missions.Mission, optional) – The mission (detector and background), or the name of one.

  • band (str, optional) – The detector band that recovers events.

  • snr_threshold (float, optional) – The signal-to-noise a visit must reach.

  • n_visits (int, optional) – How many visits must reach it.

  • exclude_first_visit_detections (bool, optional) – Whether a detection that is only on a field’s first visit is discarded; see SurveySimulator.filter_by_snr.

  • detection (sequence of Mapping, optional) – What counts as a recovery, as a list of the simulator’s registered cuts (see check_detection()). By default one snr cut, which is the three settings above. A cut that takes snr_threshold, n_visits, exclude_first_visit_detections or bands and is not given them gets the sampler’s, with bands the band of the map. A rule that is not a list of cuts is written by overriding detect().

  • mag_limit (float, optional) – The AB depth that sets the redshift limit of a point. Only events brighter than it are drawn.

  • time_bins (int, optional) – Number of equal explosion-time bins spanning the survey; see SurveySimulator.sample_N_events.

  • nside (optional) – HEALPix resolution of the sampling grid; the package defaults if omitted.

  • order (optional) – HEALPix resolution of the sampling grid; the package defaults if omitted.

  • cosmology (Cosmology, optional) – Defaults to the configured cosmology.

  • schedule_name (str, optional) – The registry name of schedule (see get_schedule()), recorded in settings so that from_settings() can fetch the same schedule. Leave it out for a schedule that is not in the registry.

Notes

The tables a sampler interpolates (volume, exposure) are sized by config["phase_space.numerics"]. They set the precision of the scales, not what is measured, so they are not recorded in settings.

Methods

all_sky_volume_time(x)

Return the volume-time of the whole sky over the whole survey out to the redshift limit, in Mpc^3 yr.

annotate_map(ax, overlay)

Draw the overlay of a sampler on the axes of a figure of its map.

coverage(x)

Return the fraction of the sky and survey window that the sampled footprint covers, for points of the space.

describe(settings)

Describe the map of a survey sampler: its band and what it counts as a detection.

detect(simulator, catalog)

Return the events of a catalog that count as recovered.

draw(x, n, seed)

Simulate n events at a point and return how many the survey recovers.

draw_map(grid, points, path, title, *[, ...])

Draw the fitted map of a sampler of this class and save the figure.

from_run_config(run, **options)

Build a sampler from the arguments of a map in a run-config, for the survey and mission the run-config names.

from_settings(settings, *[, schedule, ...])

Rebuild a sampler from the settings of another one.

kinds()

Return the registered kinds this class is, the most specific first.

make_transient()

Return a new transient of this sampler, not yet placed at a point of the space.

measure_overlay([n_draws, seed])

Measure a population in the plane of the map, to be shaded on its figure.

parameters_at(x)

Return the SED parameters that a point of the space sets, from the axes bound to a parameter.

rate_products(rate)

Return the products that need a volumetric rate: the expected number of recoveries over the survey.

redshift_limit(x)

Return the redshift out to which events are drawn at points of the space.

volume_time(x)

Return the effective volume-time \(\mathcal V T\) of points of the space, in Mpc^3 yr.

Attributes

HAS_OVERLAY

Whether measure_overlay() is implemented, for the callers that decide whether to ask for one.

TRANSIENT_KEY

The name the one transient goes by in the simulator.

kind

The name the class is registered under, which a file records.

parameter_axes

The axes that are parameters of the SED, which parameters_at() uses to place a point.

products

The quantities of a map of this sampler beyond the success fraction.

settings

The arguments that rebuild this sampler, as plain types that an ECSV header can hold.

space

The axes of the sampler, with their default ranges.

table_meta

What a figure of the map needs to label its axes, and what a comparison checks before it differences two.

yield_weight

The name of the Scale product that turns the success fraction into the quantity two maps are compared on (the volume-time, for a survey sampler: the recovered volume-time is its product with the fraction).

survey

What counts as a recovery and how a point is simulated, with the defaults applied.

detection

The cuts that define a recovery, or None for the default (see detect()).