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 (configuration) 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— one ofundone,running,success,complete, orfail;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().
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 (same vocabulary as the calibrations:undone/running/success/fail);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() (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 calibrations exist, and prints a status table; it writes a human-readable<pypeit_root>.status.logbut, being a read, does not write<pypeit_root>_state.json. The dashboard derives the same way on launch when no state file is present, and additionally reconstructs the science state from the on-diskspec2d/spec1dproducts (and anyIntermediate/files).
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.
PypeIt’s Core Data Reduction Executable and Workflow — the core
run_pypeitexecution.