pypeit.dashboard.inspect module

Build the command lines that launch PypeIt’s existing inspection tools for a calibration step (Qt-free, so it is unit-testable without a display).

The dashboard does not embed plots; it launches the existing CLI tools (pypeit_chk_* / pypeit_view_fits) as subprocesses (design C8/C14). Those scripts have non-uniform signatures, so this module exposes per-step command builders rather than a flat map (S3-Q12):

  • bias / dark / arc / tiltimg — processed calibration images, opened directly in ``ginga`` (Stage 4 Round-2 #1; these already-oriented PypeIt FITS do not display correctly through pypeit_view_fits).

  • slitspypeit_chk_edges <Edges_*> (the Edges file, not the slits step’s Slits_* output).

  • wv_calib / tilts / flats / align — a single output file with the matching pypeit_chk_* tool.

  • scattlightpypeit_chk_scattlight <ScatteredLight_*> <Slits_*> --det.

Stage 4 adds run_command(), which builds the pypeit_run_to_calibstep argv used by the Calibrations view’s (Re)Build control (design C10).

Each builder takes the DashboardModel (for the Calibrations/ directory, the spectrograph, and file resolution) and returns an argv list, or None if the command cannot be built.

Generated by JXP and Claude.

pypeit.dashboard.inspect._det_run_arg(det)[source]

Format a detector/mosaic for pypeit_run_to_calibstep --det, which parses its value with pypeit.core.parse.eval_detectors(): a single integer ("1") is one detector; a parenthesized tuple ("(1,2)") is a mosaic.

Generated by JXP and Claude.

Parameters:

det – Detector (int) or mosaic (tuple/list of ints).

Returns:

The --det argument string.

Return type:

str

pypeit.dashboard.inspect._edges_file(model, group, det)[source]

Path to the Edges_* file, derived from the slits step’s recorded Slits_* output (so it is correct even when calibrations are shared across groups and named *_all_*, as for fixed-format echelle).

Generated by JXP and Claude.

Parameters:
  • model (DashboardModel) – The model.

  • group (int) – Calibration group ID.

  • det – Detector (int) or mosaic (tuple/list).

Returns:

pathlib.Path or None.

pypeit.dashboard.inspect._slits_output(model, group, det)[source]

Path to the slits step’s Slits_* output, or None.

Generated by JXP and Claude.

Parameters:
  • model (DashboardModel) – The model.

  • group (int) – Calibration group ID.

  • det – Detector (int) or mosaic (tuple/list).

Returns:

pathlib.Path or None.

pypeit.dashboard.inspect._spectrograph(model)[source]

Return the spectrograph name for the model, or None.

Generated by JXP and Claude.

Parameters:

model (DashboardModel) – The model.

Returns:

The spectrograph name.

Return type:

str or None

pypeit.dashboard.inspect.output_command(model, step, group, det)[source]

Build the argv to inspect a step’s processed output (C8).

Generated by JXP and Claude.

Parameters:
  • model (DashboardModel) – The model.

  • step (str) – Calibration step name.

  • group (int) – Calibration group ID.

  • det – Detector (int) or mosaic (tuple/list).

Returns:

The command argv, or None if it cannot be built (e.g. no output file / unknown spectrograph / step not viewable).

Return type:

list or None

pypeit.dashboard.inspect.output_target(model, step, group, det)[source]

Return the primary file the “Inspect output” command will open, so the view can enable the control only when that file exists on disk.

Generated by JXP and Claude.

Parameters:
  • model (DashboardModel) – The model.

  • step (str) – Calibration step name.

  • group (int) – Calibration group ID.

  • det – Detector (int) or mosaic (tuple/list).

Returns:

The file that would be opened, or None if there is no viewer for this step.

Return type:

pathlib.Path or None

pypeit.dashboard.inspect.run_command(model, step, group, det)[source]

Build the argv to (re)build a calibration step via the existing pypeit_run_to_calibstep script (design C10).

The dashboard always fixes the calibration group and detector (the scope drop-downs), so it passes --calib_group and --det (never the script’s alternative --science_frame form) plus --redux_path so the run writes to the same reduction directory. run_to_calibstep generates the requested step and every step that precedes it, reusing the ones already on disk.

Generated by JXP and Claude.

Parameters:
  • model (DashboardModel) – The model.

  • step (str) – Calibration step name (e.g. wv_calib).

  • group (int) – Calibration group ID.

  • det – Detector (int) or mosaic (tuple/list).

Returns:

The pypeit_run_to_calibstep command argv, or None if the model has no .pypeit file.

Return type:

list or None

pypeit.dashboard.inspect.run_pypeit_command(model)[source]

Build the argv to run the full reduction via run_pypeit -o (Round-6): process every science/standard frame, overwriting the existing outputs. This is the science analogue of a “build everything” action, distinct from the per-step (Re)Build controls.

Generated by JXP and Claude.

Parameters:

model (DashboardModel) – The model.

Returns:

The run_pypeit command argv (with -o to overwrite and --redux_path to write to the reduction directory), or None if the model has no .pypeit file.

Return type:

list or None

pypeit.dashboard.inspect.science_object_name(spat_pixpos, slitid, det_name)[source]

Reconstruct a 1D object’s extension name (SPAT####-SLIT####-DET##), matching pypeit.specobj.SpecObj.set_name(), so pypeit_show_1dspec can be pointed at a specific object (Stage 6, S6-Q10 option (a)).

Generated by JXP and Claude.

Parameters:
  • spat_pixpos (float) – The object’s spatial pixel position.

  • slitid (int) – The slit (SPAT_ID) the object is on.

  • det_name (str) – The detector name (e.g. DET01).

Returns:

The object name, or None if it cannot be built.

Return type:

str or None

pypeit.dashboard.inspect.science_run_command(model, frame, det, step)[source]

Build the argv to (re)build a science step via the existing pypeit_reduce_by_step script (Stage 6, design R15).

reduce_by_step takes a raw frame filename (not the combined basename), so the raw frame is taken from the science entry’s recorded raw_files.

Generated by JXP and Claude.

Parameters:
  • model (DashboardModel) – The model.

  • frame (str) – The science exposure basename (table key).

  • det – Detector (int) or mosaic (tuple/list).

  • step (str) – One of process / findobj / extract.

Returns:

The pypeit_reduce_by_step command argv, or None if the model has no .pypeit file or no raw frame is known.

Return type:

list or None

pypeit.dashboard.inspect.spec1d_command(spec1d_file, obj_name=None)[source]

Build the argv to view a science 1D spectrum (pypeit_show_1dspec <spec1d> [--obj <name>]). Per the design, the user picks an object; pass its reconstructed name (see science_object_name()).

Generated by JXP and Claude.

Parameters:
  • spec1d_file (str, pathlib.Path) – Path to the spec1d product (or None).

  • obj_name (str, optional) – The object extension name to plot.

Returns:

The command argv, or None if no file.

Return type:

list or None

pypeit.dashboard.inspect.spec2d_command(spec2d_file, det=None)[source]

Build the argv to view a science 2D spectrum (pypeit_show_2dspec <spec2d> [--det]).

Generated by JXP and Claude.

Parameters:
  • spec2d_file (str, pathlib.Path) – Path to the spec2d product (or None).

  • det (optional) – Detector (int) or mosaic (tuple/list) to show.

Returns:

The command argv, or None if no file.

Return type:

list or None

pypeit.dashboard.inspect.view_input_command(model, input_file, det=None)[source]

Build the argv to view a single input (raw) frame (C7).

Uses pypeit_view_fits --proc so the raw frame is oriented/trimmed and shown properly formatted (not the bare, unoriented FITS; Stage 3b #1).

Generated by JXP and Claude.

Parameters:
  • model (DashboardModel) – The model.

  • input_file (str) – Path to the raw input frame.

  • det (optional) – The detector (int) or mosaic (tuple/list) the frame belongs to, passed to --det so the right detector is processed.

Returns:

The pypeit_view_fits command, or None if the spectrograph is unknown.

Return type:

list or None