Command-Line Interface#
Everything covered in Simulation (sampling an
EventCatalog, screening it down with one or
more cuts, and running synthetic photometry) is also available without writing any Python, via
the uvex-transients console script (uvex_transients.cli). One YAML run-config file
describes what to simulate (which transients, what schedule) and, via its steps: list, how
to process the baseline catalog once it’s sampled – screening cuts, set operations between named
catalogs, and post-processing actions like synthetic photometry, chained in one declared order,
GitHub-Actions style. The CLI’s four subcommands (generate, cut, photometry,
and run) drive that same pipeline, reading and writing plain catalog/table
files between stages. A fifth, phase-space, is separate from that pipeline: it maps the survey’s recovery of a
canonical transient instead of simulating a population (see Phase-Space Maps).
This page is a hands-on tour of the run-config format and the commands themselves. See Simulation for what each stage actually does under the hood; this page is about driving that same pipeline from a config file and a terminal instead of a Python script.
Quick Look#
The repository ships a ready-to-run example, quickstart_tde.yaml,
under configs/. Once the package is installed (pip install -e . from a source checkout
registers the uvex-transients command), running the whole pipeline is one line:
uvex-transients run configs/quickstart_tde.yaml --out-dir quickstart_results/
That samples tidal disruption events against the default UVEX schedule, tabulates the survey’s
effective exposure to them, screens them by magnitude and then by SNR, and runs synthetic
photometry on whatever survives – leaving every checkpointed artifact in
quickstart_results/: baseline.ecsv, exposure.ecsv, one numbered file per declared step
(01_mag_screen.ecsv, 02_snr_screen.ecsv, 03_phot.ecsv). The rest of this page explains
the config file that made that happen and the commands it works with, so you can build your own.
The Run-Config File#
A run-config is a single YAML file with up to six top-level sections. Every CLI command reads the
same file (there’s no separate config per command), but each command only needs the section(s)
it actually touches, resolved lazily by RunConfig: a config
with no steps: block is perfectly valid as long as you only ever run generate.
Section |
Required by |
Purpose |
|---|---|---|
|
all commands |
Which |
|
all commands |
Which |
|
all commands |
At least one |
|
|
|
|
|
An ordered list of |
|
|
Whether |
Important
schedule:, mission:, and transients: are the shared “setup” every command needs to
build a SurveySimulator
(simulator); they’re listed as required by “all
commands” above even though, individually, schedule:/mission: each have a fallback
default.
The Schedule#
schedule:
name: uvex_v0.5.0 # one of the names in `schedules.schedule_urls`
# ...or, to fetch a URL directly instead of a name registered in the package config:
#
# schedule:
# url: https://example.com/plan.ecsv
#
# ...or to read a schedule already saved to disk (as written by
# `SurveySchedule.to_disk(path, fov_path=...)`):
#
# schedule:
# path: my_schedule.ecsv
# fov_path: my_schedule.reg
name:, url:, and path:/fov_path: are mutually exclusive: giving more than one
raises. See Surveys for what a schedule actually is and
list_schedules() for the full set of registered names.
Key |
Type |
Description |
|---|---|---|
|
str |
A name registered in |
|
str |
A direct URL to fetch a schedule table from. Mutually exclusive with |
|
str |
A local schedule table path, as written by |
|
str |
The companion instrument-FOV region file for |
The Mission#
mission: uvex
A bare name, resolved against every Mission instance in
m4opt.missions (rubin, ultrasat, uvex, ztf as of this writing); an
unrecognized name raises, listing the real ones.
Key |
Type |
Description |
|---|---|---|
(bare value) |
str |
A name from |
The Transients#
Each entry under transients: is a label of your choosing (used as the catalog’s
transient_type value; see Simulation) mapping to a class: plus whatever
overrides you want on top of its defaults:
transients:
tde:
class: TidalDisruptionEvent
z_limit: 1.7 # overrides ExtragalacticTransient.redshift_limit
# (or z_limit: {mag_limit: 23.0} to look it up from the horizon curve)
duration_limit: 200 day # overrides TransientBase.duration_limit
cosmology: !astropy_cosmology {name: Planck18}
parameters:
amplitude: !prior {type: power_law, alpha: 2.41, lower: 1.0e+43, upper: 1.0e+46}
sigma_rise: 1.0 day # a bare value fixes the parameter instead
class: must name a registered TransientBase
subclass: every built-in type (TidalDisruptionEvent, Kilonova,
LuminousFastBlueOpticalTransient, LowLuminosityGRB, TypeIIPSNe, TypeIIbSNe,
ShockCoolingIIb, TypeIbSNe, TypeIcSNe) is available by class name; an unrecognized one
raises, listing what is registered.
Everything under parameters: is applied the same way
Event.simulate_photometry
expects to find it later: a plain value fixes that parameter
(fix()), while a !prior node replaces
its prior entirely (set_prior()). A value
with units (like sigma_rise above) needs a unit string ("1.0 day"); a bare, unitless
number only works for a genuinely dimensionless parameter. See Models for what a
model’s parameters actually are.
Tip
!prior takes a type: naming one of Prior’s
built-in subclasses, plus that class’s own fields:
|
Fields |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
An unrecognized type:, a missing type:, or an unknown field for the chosen type all
raise at load time, naming the line the problem is on.
Key |
Type |
Description |
|---|---|---|
|
str |
A registered |
|
float or mapping |
Overrides |
|
str or number |
Overrides |
|
str or number |
Overrides |
|
str or number |
Overrides |
|
|
Overrides the transient’s cosmology. Optional; defaults to the package’s own default cosmology. |
|
mapping |
Per-SED-parameter overrides, keyed by parameter name; each value is either a fixed value
or a |
Generating Events#
generate:
time_bins: 20
nside: 64
sampling_factor: 0.05
seed: 42
A direct pass-through to
generate_events(); see
Simulation for what each field means. Its output is the reserved "baseline"
artifact – the starting point every steps: entry ultimately traces back to (see below) – and
an ExposureCatalog over the same
time_bins/nside/order is always available too, under the reserved id "exposure".
sampling_factor: can also give a different factor per transient type instead of one number for
every type – keys are the transients: section’s own keys, and a type left out is sampled at
its physical rate:
generate:
time_bins: 20
sampling_factor:
tde: 0.05
kilonova: 0.2
seed: 42
uvex-transients generate quickstart_tde.yaml --out baseline.ecsv
Key |
Type |
Description |
|---|---|---|
|
int |
Number of evenly-spaced time bins to divide the schedule’s span into. Required. |
|
int |
HEALPix resolution. Optional; falls back to the package’s |
|
str |
HEALPix pixel ordering ( |
|
float or mapping of str to float |
Multiplier on the physical event rate: the number of events is Poisson with this
multiple of the expected count, so |
|
int |
Root seed for |
The Steps Pipeline#
steps: is an ordered list, run strictly top-to-bottom – like a GitHub Actions job. Every
entry needs a unique id: and a type: of cut, logical_op, or action. Whatever
artifact a step produces (an EventCatalog, a
photometry table, …) is stored under its own id, so a later step can reference it as an
input by name – alongside the two reserved ids "baseline"/"exposure" that generate:
always seeds the pipeline with. A step may only reference "baseline"/"exposure" or an
earlier step’s id – there’s no forward reference, and the whole list is validated (unique
ids, resolvable inputs, known cut/op/action names, correct arity) the moment steps: is
accessed, before anything actually runs.
steps:
- id: mag_screen
type: cut
cut: limiting_magnitude
input: baseline
params:
mag_limit: 25.0
- id: snr_screen
type: cut
cut: snr
input: mag_screen
params:
snr_threshold: 5.0
- id: phot
type: action
action: photometry
inputs:
catalog: snr_screen
params:
bands: [FUV, NUV]
cut steps#
A single-catalog predicate filter – narrows one EventCatalog down to another. cut: must name one
of SurveySimulator.available_cuts(), registered via the
cut() decorator – the schedule/detector-aware
limiting_magnitude/snr pair walked through in Cuts, plus a further
set of cheaper or more specialized screens (redshift, type, peak brightness, detection timing,
sky position, and an arbitrary boolean expression), listed in full below. input: names the
artifact to filter; everything under params: is forwarded as keyword arguments to that cut’s
underlying method.
An optional transient_types: list restricts the cut to rows whose transient_type matches
one of those names – every other row passes through untouched, regardless of what the cut would
otherwise have done to it. This is handled generically by the step executor itself, not by any
individual cut, so it works retroactively for every registered cut, including ones a project adds
later:
steps:
- id: tde_only_screen
type: cut
cut: limiting_magnitude
input: baseline
transient_types: [tde]
params:
mag_limit: 26.0
Hint
Cuts are ordinary SurveySimulator methods, not a
separate plugin class: decorating a new method on a
SurveySimulator subclass with @cut("my_cut")
registers it automatically, immediately usable from a cut: in any run-config.
|
Required params |
Optional params |
|---|---|---|
|
|
|
|
|
|
|
– |
|
|
|
– |
|
– |
|
|
– |
|
|
– |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
– |
|
|
|
|
|
– |
peak_magnitude/peak_flux/peak_luminosity are purely intrinsic-plus-distance screens
(no Milky Way dust attenuation, no detector background, no schedule) on the brightest a modeled
event ever gets – see
filter_by_peak_magnitude() for the exact
evaluation. time_to_first_detection/baseline are schedule-aware, like snr, reusing its
own qualifying-epoch definition (see
filter_by_baseline() for the two-sided
“at least one close pair and a long overall span” semantics). region takes a
SkyRegion/Regions object or a .reg file path (the same
convention the instrument FOV uses); sky_position is a simpler longitude/latitude box in any
coordinate frame, with mode: include (default) or mode: exclude (e.g. Galactic-plane
avoidance: frame: galactic, theta_min: -10, theta_max: 10, mode: exclude). query evaluates
an arbitrary boolean expression string directly against the catalog’s own columns (each bound to
its native Quantity/SkyCoord/
Time type, so comparisons stay unit- and frame-aware) – see
filter_by_query() for the exact evaluation
scope and its “trusted author, not a sandbox” caveat.
logical_op steps#
Combines two or more already-produced EventCatalog artifacts by event_id –
useful for comparing independent cut branches (e.g. which events both a magnitude screen and an
SNR screen agree on, or which ones only one branch caught). op: is one of
union/intersection/difference (see
uvex_transients.simulation.logical_ops); inputs: is a list of earlier
id:s/"baseline"/"exposure". union/intersection accept two or more inputs
(both are associative/commutative); difference requires exactly two (a - b, order
matters, so there’s no n-ary form).
steps:
- id: bright_branch
type: cut
cut: limiting_magnitude
input: baseline
params: {mag_limit: 25.0}
- id: detected_branch
type: cut
cut: snr
input: baseline
params: {snr_threshold: 5.0}
- id: agreement
type: logical_op
op: intersection
inputs: [bright_branch, detected_branch]
action steps#
Post-processing that doesn’t fit cut’s “one EventCatalog in, one EventCatalog out”
shape – synthetic photometry or a per-event summary table. action: must name
one of SurveySimulator.available_actions(), registered the same way cuts
are, via action(). inputs: is a mapping from that
action’s own parameter name(s) to artifact ids (so an action needing several inputs at once, like
event_summary, can name each one); params: are its remaining keyword
arguments.
|
|
Required params |
Optional params |
|---|---|---|---|
|
|
– |
|
|
|
|
|
event_summary writes one row per event of catalog, so that detection timing, cadence, and
peak behavior can be studied from one small table rather than by replaying the event list. It
holds each event’s identity and position, which footprints it falls in, a weight (the
expected number of real events it stands for, so summing it over a selection gives that
selection’s expected yield), the first and last observation and detection times, the time of the first
downlink after the first detection (t_alert), the last non-detection before the first
detection (t_last_nondet and its last_nondet_snr, plus t_last_constraining_nondet,
the last one whose rise to the first detection is at least rise_sigma), t_rise_1mag,
t_rise_2mag and t_rise_3mag (the first detection that many magnitudes above a band’s
detection limit at its last non-detection), a copy of the detection quantities for each band
(t_first_det_FUV, t_last_nondet_NUV, t_rise_2mag_FUV, and so on), and the peak SNR,
magnitude, FUV-NUV color, and time from photometry. catalog is typically the SNR-cut
catalog. Its pre_cut_counts (the number of events of each type when the baseline was generated,
which no cut changes) and the exposure and rate factors of each type are stored in the table’s
meta, so estimate_yield() can turn any selection of its
rows into expected events with confidence bounds from the table alone (see
Simulation).
A photometry action’s output (a plain QTable, one row per (event,
observation, band)) can itself feed a later event_summary action by id, exactly like
any other artifact:
steps:
- id: phot
type: action
action: photometry
inputs: {catalog: snr_screen}
- id: summary
type: action
action: event_summary
inputs: {catalog: snr_screen, exposure: exposure, photometry: phot}
params: {snr_threshold: 5.0}
checkpoint: event_summary.ecsv
Checkpointing#
Any step’s own checkpoint: controls whether (and where) run writes its artifact to
--out-dir:
Value |
Behavior |
|---|---|
(unset, default) |
Falls back to the run’s own |
|
Forces this step to be (or not be) checkpointed, overriding |
a string, e.g. |
Writes to that explicit filename (relative to |
Rerunning run against the same --out-dir without --overwrite resumes: any step
whose checkpoint file already exists is loaded from disk instead of being recomputed (and every
step downstream of it then runs against that loaded artifact). --overwrite disables this –
every step always reruns, replacing any existing checkpoint file.
Running Steps From the CLI#
uvex-transients run quickstart_tde.yaml --out-dir results/
Samples generate:, tabulates exposure, then runs every declared steps: entry in order, all
in one process, writing each checkpointed artifact to results/ as it goes: baseline.ecsv
(if checkpointed), exposure.ecsv (always), then one NN_<step id>.ecsv per checkpointed
step (or its own explicit checkpoint: filename). A config with an empty/absent steps: list
is fine too; run then does nothing beyond generate/exposure.
Set the config’s top-level keep_intermediate: false (or pass --no-keep-intermediate,
which overrides the config either way) to checkpoint only the steps that explicitly opt in via
their own checkpoint::
uvex-transients run quickstart_tde.yaml --out-dir results/ --no-keep-intermediate
For ad hoc, single-step use (useful for inspecting/debugging one stage without rerunning the
whole pipeline), two more subcommands each pick one declared step by its id: and run it
against externally supplied file(s), ignoring that step’s own configured input:/inputs::
# Every declared `cut` step, chained in order, against an explicit input catalog:
uvex-transients cut quickstart_tde.yaml --in baseline.ecsv --out screened.ecsv
# Or just one, by id:
uvex-transients cut quickstart_tde.yaml mag_screen --in baseline.ecsv --out mag_only.ecsv
# A declared `action: photometry` step, by id:
uvex-transients photometry quickstart_tde.yaml phot --in screened.ecsv --out photometry.ecsv
Every command accepts --overwrite to replace an existing output file/directory contents
instead of raising.
Every command also accepts --dry-run, which validates the config and prints what the real
command would do without sampling, computing photometry, or writing anything:
uvex-transients run configs/full_run.yaml --out-dir results/ --dry-run
It resolves every section the command needs, so an unknown transient class:, a bad
parameters: override, an unknown cut/op/action name, a dangling step input, an unknown
mission, or an unreadable schedule fails here exactly as it would in the real run (as a short
dry run failed: ... message). On success it reports the mission, the size of the schedule,
each transient population (class, SED, redshift limit, duration window), the generate:
settings (for generate/run), the resolved steps: list (for run, or the selected
step(s) for cut/photometry), and each output file it would write. If
a real run would refuse to overwrite one that already exists, the dry run flags it as WOULD
FAIL and exits non-zero unless --overwrite is also given. The schedule is loaded (and
downloaded on first use), but the command never reads the --in input of cut/photometry,
only checks that it exists.
Phase-Space Maps#
uvex-transients phase-space configs/phase_space.yaml --out-dir results/phase_space/
The phase-space command reads a different kind of run-config, with no transients: or steps:. It names a
survey and lists maps, each the survey’s recovery of a transient over two of its properties (see
uvex_transients.phase_space). By default a map is of the canonical transient, over the peak luminosity in one
band and the rest-frame half-decline time. The shipped
phase_space.yaml
makes the two detection maps (at least two observations at \(5\sigma\), to 25 AB) in the FUV and the NUV:
schedule:
name: uvex_v0.6.0
mission: uvex_fast
overlay: true # shade the shipped transient classes on every map that can
detection: # shared by every map; a map overrides it key by key
snr_threshold: 5.0
n_visits: 2
simulation:
mag_limit: 25.0
maps:
- id: fuv_detection # names the output directory
detection: {band: FUV}
- id: nuv_detection
detection: {band: NUV}
The sections are named for what they decide, and each may be given at the top level and in a map. A key left out takes
its value from the phase_space: section of the package configuration, whose sections have the same names
(phase_space.detection, phase_space.simulation, phase_space.stopping, phase_space.campaign), plus one
named for each kind of sampler (phase_space.canonical, phase_space.breakout) whose keys take the place of the
shared ones for that kind. A misspelt key is an error, and every problem in the file is reported at once.
Section |
What it decides |
|---|---|
|
What counts as a recovery: |
|
How a point is simulated: |
|
How many tries a point gets: |
|
The arguments of the sampler that belong to no section above, such as the shape of the canonical transient
( |
|
The ranges of the axes of the map, by name: |
|
How the campaign spends its points: |
|
Points per axis of the fitted map. |
A different definition of a detection is a list of cuts:, the cuts that steps: use (see
available_cuts()), applied in order to the events a point draws.
For example, a first detection that the survey brackets to within a day:
detection:
band: FUV
cuts:
- cut: snr
- cut: time_since_last_nondetection
params: {max_delay: 1.0} # days
A map of another transient names its kind:, and uvex-transients phase-space kinds lists the registered ones. A
map that is not of the top-level kind takes none of the top-level detection:, simulation:, stopping:,
settings: or axes:, since what a visit count or an axis name means belongs to the sampler. Only campaign:
and grid_size: are shared by every map. To share another section on purpose, use a YAML anchor.
maps:
- id: breakout_fuv
kind: breakout
detection: {band: FUV}
settings: {z_max: 8.0}
axes: {log_L0: [43.0, 46.0], log_t0: [3.0, 4.0]}
Note
The layout of this file changed. recovery: is now detection:, simulation: and stopping:,
sampler: is campaign:, transient: is part of settings:, and the ranges of map: are axes:.
The old names are refused with what replaces them.
Each map is written to OUT_DIR/<id>/ as points.ecsv (every simulated point, saved after every batch),
map.ecsv (the fitted map on a grid) and map.png, and overlay.ecsv (the measured classes) for a sampler that
has an overlay, which the canonical one does. --map ID makes only one map, --workers N measures the points of a
batch in parallel, and an existing map is refused unless --overwrite replaces it or --resume continues it from
its saved points. --dry-run validates the file and the bands without loading the schedule. The command needs the
phase_space extra (pip install 'uvex_transients[phase_space]').
phase-space CONFIG runs every stage. They are also commands of their own, over the directories of maps and with no
run-config, so that the simulation (the slow part) is run once and the rest repeated or changed:
uvex-transients phase-space run configs/phase_space.yaml --out-dir results/phase_space/ --workers 8
uvex-transients phase-space fit results/phase_space/ --config configs/phase_space.yaml
uvex-transients phase-space plot results/phase_space/
uvex-transients phase-space compare results/a/fuv_detection results/b/fuv_detection --out-dir results/diff
uvex-transients phase-space info results/phase_space/
plot draws the figure that the map’s sampler defines. --field NAME (repeated) draws the columns of map.ecsv you
name instead, one panel each, including a quantity that carries no interval such as z_limit. A figure is of a plane,
so a map over more than two axes has its points.ecsv and map.ecsv but no figure.
Adding a new kind of map is a new Sampler; the module documentation
of uvex_transients.phase_space.sampling.base describes the contract and the optional hooks (describe,
draw_map, annotate_map, HAS_OVERLAY and the others) that keep the rest of the code from asking what kind a sampler is.
Using It From Python#
Every command is a thin wrapper. uvex_transients.cli.pipeline’s
run_generate()/run_exposure()
sample the two reserved artifacts, and uvex_transients.cli.steps.run_steps() executes the
rest of steps: against a plain {id: artifact} dict you seed yourself – no click
dependency, useful if you want the same config-driven setup inside a notebook or a larger script
instead of a fresh subprocess per stage:
from uvex_transients.cli.config import RunConfig
from uvex_transients.cli.pipeline import run_exposure, run_generate
from uvex_transients.cli.steps import run_steps
config = RunConfig.from_yaml("quickstart_tde.yaml")
baseline = run_generate(config)
exposure = run_exposure(config)
store = {"baseline": baseline, "exposure": exposure}
for step, artifact, checkpoint_path in run_steps(config, store):
print(step.id, type(artifact).__name__)
screened = store["snr_screen"] # any step's own artifact, by id
phot = store["phot"]
config.simulator, config.schedule, config.mission, and config.transients are each
resolved once and cached, so building a RunConfig and calling the above costs one schedule
fetch and one round of transient construction, no matter how many steps run. Pass out_dir= to
run_steps to also checkpoint (and resume from) files on disk, exactly like the run command
does.
See uvex_transients.cli in the API reference for exhaustive, method-by-method
documentation of every function/class mentioned above.