uvex_transients.simulation.core.SurveySimulator.iter_epochs#
- SurveySimulator.iter_epochs(catalog: EventCatalog, mission: Mission | None = None, bands: list[str] | None = None, chunk_size: int | None = None, detection_floor: float = 0.0, mask: ndarray | None = None, progress: bool = True, include_snr: bool = True, lookback: Quantity | None = <Quantity 0. d>, collapse_bands: bool = True) Iterator[QTable][source]#
Lazily yield every observation of every event, one chunk of events at a time.
The core iterator the schedule-aware cuts are built on: any threshold-, visit-count-, or cadence-style reduction can be computed from these tables without re-measuring anything. For every (event, observation) pair of a chunk it makes the same measurement ~uvex_transients.simulation.event.Event.simulate_photometry makes, with the same noise.
Each yielded ~astropy.table.QTable has one row per (event, observation) pair for up to chunk_size events of a single transient type, sorted by
(event_id, t_obs)so each event’s rows are contiguous (see event_boundaries), with columns:event_id: the event’s ownevent_idin catalog.observation_index: row index intosurvey_schedule.observe_rows.t_obs: ~astropy.time.Time the observation started.t_since_explosion: ~astropy.units.Quantity (day),t_obs - t_explosion; negative before the explosion.pre_explosion: bool,t_since_explosion < 0. Such a row has no source, so it is measured as pure background and can never be a detection. For a transient that is measured over the whole exposure (~uvex_transients.transients.base.TransientBase.AVERAGE_OVER_EXPOSURE) it is instead whether the exposure ends at or before the explosion, so an exposure that starts before the explosion and ends after it is a measurement of the source, diluted by the part before.snr,band,flux,flux_err(if include_snr): the measured SNR of the observation in its best band (bands are collapsed to the best one, so an observation is never counted once per band), that band, its measured flux density (~astropy.units.Quantity in Jy), and the one-sigma uncertainty on it.snrisflux / flux_err. The measurement is a Gaussian draw around the true flux, keyed on the event’sparameter_seed, the observation’s start time and the band (see ~uvex_transients.utils.keyed_noise.keyed_standard_normal), so it is the same draw ~uvex_transients.simulation.event.Event.simulate_photometry makes for that measurement, whatever else is evaluated alongside it. For a pre-explosion row it is a draw from the background noise alone, at that observation’s real depth.
With collapse_bands False the epochs are not reduced to their best band. There is then one row per (event, observation, band), sorted by
(event_id, t_obs, band)so an epoch’s bands are adjacent, and the rows gainband_index(the band’s position in bands) andis_best_band, True for the one row of each epoch that the default would have kept. Selecting those rows therefore reproduces the default output exactly. A band that could not be measured has a NaNsnr, so it is neither a detection nor a non-detection.With include_snr False only the geometry columns are produced, and neither mission nor the SED is touched.
A chunk in which no event was observed, or in which every row falls below detection_floor, yields nothing. An event with no rows at or above detection_floor therefore never appears in any chunk.
- Parameters:
catalog (
EventCatalog) – The events to evaluate. Needsevent_id,coord,t_explosion,transient_typeandhealpix_id, plusredshift,luminosity_distance,ebvandparameter_seed(all filled in by generate_events) when include_snr.mission (
m4opt.missions.Mission, optional) – Supplies the ~m4opt.synphot.Detector bands selects from. Required unless include_snr is False.bands (
listofstr, optional) – Which of mission.detector’s bandpasses to evaluate. Defaults to all of them.chunk_size (
int, optional) – Number of events (per transient type) evaluated together. If None, usesconfig["simulation.filter_by_snr.chunk_size"].detection_floor (
float, optional) – Rows with a measuredsnrbelow this are dropped before being yielded. This bounds the size of the output, but also means a later reduction can’t use a threshold below it. The default, 0, keeps every row with a non-negative SNR. Ignored when include_snr is False. Use-numpy.infto keep every row, e.g. to see non-detections.mask (
numpy.ndarray, optional) – Restricts evaluation to a subset of catalog’s events: either a boolean array of lengthlen(catalog)or an integer index array intocatalog.table. Masked-out events cost nothing. None evaluates them all.progress (
bool, optional) – Whether to show a progress bar over chunks.include_snr (
bool, optional) – Whether to measure each observation and yield thesnr/band/flux/flux_errcolumns. If False, only the geometry of which observations covered which events is returned, which is much cheaper.lookback (
QuantityorNone, optional) – How far before each event’s explosion to include observations. The default, 0 days, keeps only observations that overlap the post-explosion window (this can include an exposure that starts just before the explosion, flaggedpre_explosion). For a transient measured over the whole exposure (~uvex_transients.transients.base.TransientBase.AVERAGE_OVER_EXPOSURE) it includes every exposure that ends after the explosion, one that started before it too. A positive duration also yields the earlier observations of the event’s position, e.g. to find the last pre-explosion non-detection. None looks back to the start of the schedule.collapse_bands (
bool, optional) – Whether to keep only each epoch’s best band (the default). If False, every band is kept, as described above. detection_floor is then applied to each band’s ownsnr, so it can drop an epoch’s weaker bands and keep its best one. Ignored when include_snr is False.
- Returns:
One epoch table per chunk of events, as described above.
- Return type:
- Raises:
TypeError – If catalog is not an EventCatalog, or an SNR is requested without a ~m4opt.missions.Mission.
ValueError – If chunk_size, bands, mask, or lookback is invalid, or catalog lacks a required column.