PypeIt Reduction State
What it is
While run_pypeit reduces your data it records a machine-readable state
of the reduction to a JSON file in the reduction directory,
named after the .pypeit file:
<pypeit_root>_state.json # e.g. shane_kast_blue_A_state.json
The state captures, per calibration group and per detector/mosaic, the
status of each calibration step (bias, dark, arc, tiltimg,
slits, wv_calib, tilts, scattlight, flats, align).
For each step it records:
a
requiredflag and astatus(see Status values below);the
input_filesused, the processedoutput_file, and anyqa_files; andstep-specific metrics and per-slit/order detail — e.g.
biasmean and standard deviation;slitscount and per-slit center;wv_calibandtiltsper-slit RMS; andflatscorrections (pixel-to-pixel, spatial and spectral illumination), provenance, and per-slit per-correction mean/RMS.
In addition to the calibrations, the state records the science frames (see Science-frame state below): one entry per reduced science/standard exposure and detector, with the status of each science macro-step and the per-object / per-slit detail.
The state is modeled by RunPypeItState (a
pydantic model);
a tabular summary of the calibrations is available via
get_status(), and of the science
frames via
get_science_status() (both return
an astropy.table.Table).
Status values
Each step’s status is one of a small, fixed vocabulary:
Status |
Meaning |
|---|---|
|
The step has not (yet) been run. This is the initial value, and the value a step is reset to when its output is not found on disk during a status-only read. |
|
The step is currently being built (set just before a build starts, so a live reader sees the step in progress). |
|
The step was built successfully (its output exists and was written, or an existing output was successfully reloaded). |
|
The step raised an error and its output was not produced. |
Per-slit/order entries use the same vocabulary, with one addition: skip
(currently used by flats), meaning the slit was intentionally skipped
(e.g. flagged SKIPFLATCALIB), as distinct from a failure.
Science-frame state
Alongside the calibrations, the state records a list of science-frame entries — one per reduced science or standard exposure and detector/mosaic. The science reduction is tracked as four macro-steps,
process -> findobj -> skysub -> extract
(findobj and skysub are produced together). For each (frame,
detector) entry the state records:
the
objtype(scienceorstandard) and the contributing raw frame(s);the
statusof each of the four macro-steps (the same vocabulary as the calibrations — see Status values);the data products — the
spec2dandspec1dfiles — and the object countnobj;per-slit detail (a status from the
BADSKYSUB/BADEXTRACTslit bitmask, and the object count on the slit); andper-object detail for each detected object —
snr_find(the object-finding S/N),s2n(the extraction S/N), the spatial pixel position, FWHM, the tracesign, and whether it wasextracted.
A tabular per-frame summary is available via
get_science_status() (an
astropy.table.Table with columns frame,
detector, calib, objtype, the four step statuses, nobj,
spec2d, spec1d). The PypeIt Dashboard renders this in its
Science view.
How and when it is generated
During a run.
run_pypeitupdates the state as it goes: it marks a steprunningbefore building it andsuccess/failafterward, writing the JSON file at each transition — for both the calibrations and the science macro-steps. So the file is a live, per-step record of the run’s progress.pypeit_run_to_calibstep(rebuilding a single calibration) andpypeit_reduce_by_step(rebuilding a single science step) likewise write the state as they run and refresh it from disk on completion. Because each of these single-purpose runs only populates its own portion of the state, they first merge the existing on-disk state (merge_from_disk()) so a calibration build does not blank the science entries, nor a science build the calibration statuses.Without running (read-only). The pypeit_status script derives the same state without performing any processing — it instantiates PypeIt in
calib_onlymode, checks what calibration outputs exist, reconstructs the science state from the on-diskspec2d/spec1dproducts (and anyIntermediate/files), and prints the status tables to the screen. It always re-derives the status from the current on-disk products — it never simply reads<pypeit_root>_state.json— so its output reflects the disk even when the state file is missing, stale, or wrong (e.g. after files have been deleted by hand). Being a read, it does not write the state file. The dashboard derives the state the same way on launch when no state file is present.
The PypeIt Dashboard reads <pypeit_root>_state.json to render its
Status, Calibrations, and Science views; if the file is absent it derives the
state the same way pypeit_status does.
Warning
Do not edit the _state.json file by hand. It is generated and
overwritten by PypeIt and is meant to be read by tools (the dashboard,
pypeit_status), not edited. Hand edits will be lost on the next write
and can make the file unreadable. To refresh the state, re-run the reduction
with run_pypeit (or pypeit_run_to_calibstep to rebuild a single
calibration).
Note
State I/O is deliberately non-essential to the reduction: PypeIt writes the state defensively, so a failure to write or update it is logged as a warning and never aborts a run.
See also
PypeIt Dashboard — the GUI that visualizes the state.
pypeit_status — print the reduction status from the command line.
run_pypeit — the core
run_pypeitexecution.