Source code for pypeit.scripts.pypeit_status

"""
Script to check and display the status of a PypeIt reduction
without actually running any processing steps.

.. include common links, assuming primary doc root is up one directory
.. include:: ../include/links.rst
"""

from pypeit.scripts import scriptbase


[docs] class PypeItStatus(scriptbase.ScriptBase): """ The ``pypeit_status`` console script: report a reduction's calibration and science status without running any processing. Generated by JXP and Claude. """
[docs] @classmethod def name(cls): """ Return the name of the executable. Generated by JXP and Claude. Returns: str: The script name, ``pypeit_status``. """ return 'pypeit_status'
[docs] @classmethod def get_parser(cls, width=None): """ Construct the command-line argument parser. Generated by JXP and Claude. Args: width (:obj:`int`, optional): Restrict the formatted help width to this many characters. Returns: `argparse.ArgumentParser`_: The command-line parser. """ import argparse parser = super().get_parser( description='Check the status of a PypeIt reduction', width=width, formatter=argparse.RawDescriptionHelpFormatter, default_log_file=True) parser.add_argument('pypeit_file', type=str, help='PypeIt reduction file (must have .pypeit extension)') return parser
[docs] @classmethod def main(cls, args): """ Check and print a PypeIt reduction's status without processing. Loads the reduction in ``calib_only`` mode, derives the calibration status from the on-disk ``Calibrations/`` outputs (a status-only read, no processing), derives the science-frame status from the on-disk ``Science/`` products (see :func:`~pypeit.state.science_status.derive_science_from_disk`), and pretty-prints both (:meth:`~pypeit.state.RunPypeItState.print_status`). Generated by JXP and Claude. Args: args (`argparse.Namespace`_): The parsed command-line arguments. Returns: int: ``0`` on success. """ from pathlib import Path from IPython import embed from pypeit import pypeit from pypeit.state import science_status from pypeit import log from pypeit import PypeItError # Set a default log file (avoid over-writing the standard one) if args.log_file == 'default': _pypeit_file = Path(args.pypeit_file) if _pypeit_file.suffix != '.pypeit': raise PypeItError('Input file must have a .pypeit extension!') args.log_file = _pypeit_file.with_suffix('.status.log') cls.init_log(args) # Instantiate PypeIt in calib_only mode to skip science frame checks pypeIt = pypeit.PypeIt( args.pypeit_file, reuse_calibs=True, calib_only=True) # Run calibration status check only (no processing) pypeIt.calib_all(status_only=True, reload_only=True) # Derive the science-frame state from the on-disk products (Science # spec2d/spec1d, with Intermediate/ as a fallback); no processing. science_status.derive_science_from_disk( pypeIt.run_state, pypeIt.par['rdx']['redux_path'], fitstbl=pypeIt.fitstbl) # Write state to JSON #pypeIt.run_state.write() # Pretty-print the state (calibrations + science) pypeIt.run_state.print_status() return 0