From 231f2be6874ead6f0315c51586cceba9bae4f62d Mon Sep 17 00:00:00 2001 From: "Timothy P. Ellsworth Bowers" Date: Wed, 5 Nov 2025 12:32:21 -0700 Subject: [PATCH 1/2] Modernize modified: obstools/scrub_deveny_pickup.py modified: obstools/utils.py --- obstools/scrub_deveny_pickup.py | 4 ++-- obstools/utils.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/obstools/scrub_deveny_pickup.py b/obstools/scrub_deveny_pickup.py index 2b50d2c..30ee0ac 100644 --- a/obstools/scrub_deveny_pickup.py +++ b/obstools/scrub_deveny_pickup.py @@ -127,7 +127,7 @@ def iterative_pypeit_clean( try: # Look for the spec2d file - spec2d_file = utils.flatten_comprehension( + spec2d_file = utils.flatten_itertools( [ sorted(d.joinpath("Science").glob(f"spec2d_{filename.stem}-*.fits")) for d in pyp_dir @@ -1012,7 +1012,7 @@ def package_into_fits( suffix (Default: False) """ # Add a little history - time_str = datetime.datetime.utcnow().isoformat(sep=" ", timespec="seconds") + time_str = datetime.datetime.now(datetime.UTC).isoformat(sep=" ", timespec="seconds") history_str = f"Written by package obstools: {time_str} UTC" # For the image HDUs, include a basic header img_hdr = astropy.io.fits.Header({"BUNIT": "ADU", "HISTORY": history_str}) diff --git a/obstools/utils.py b/obstools/utils.py index 8bfc394..8cca85d 100644 --- a/obstools/utils.py +++ b/obstools/utils.py @@ -25,6 +25,7 @@ import argparse from functools import reduce from importlib import resources +import itertools import pathlib import textwrap import sys @@ -139,6 +140,22 @@ def flatten_comprehension(nested_list: list[list]) -> list: return [item for row in nested_list for item in row] +def flatten_itertools(nested_list: list[list]) -> list: + """Flatten a single-depth nested list via itertools + + Parameters + ---------- + nested_list : :obj:`list` + The single-depth nested list to flatten + + Returns + ------- + :obj:`list` + The flattened list + """ + return [itertools.chain.from_iterable(nested_list)] + + def gaussfit( x: np.ndarray, y: np.ndarray, From a65ff519c83772cfe90ee482c7630fc3aac9db05 Mon Sep 17 00:00:00 2001 From: "Timothy P. Ellsworth Bowers" Date: Tue, 3 Feb 2026 11:56:48 -0700 Subject: [PATCH 2/2] Remove pypeit.msgs --- obstools/scrub_deveny_pickup.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/obstools/scrub_deveny_pickup.py b/obstools/scrub_deveny_pickup.py index 30ee0ac..348bc06 100644 --- a/obstools/scrub_deveny_pickup.py +++ b/obstools/scrub_deveny_pickup.py @@ -60,7 +60,7 @@ import ccdproc.utils.slices import matplotlib.pyplot as plt import numpy as np -from pypeit import msgs +# from pypeit import msgs import pypeit.spec2dobj import scipy.fft import scipy.ndimage @@ -135,10 +135,10 @@ def iterative_pypeit_clean( )[0] except (StopIteration, IndexError): # And... fail. - msgs.warn( - f"File {filename.name} does not have a corresponding PypeIt-processed 2D spectrum. " - "Check the image type and whether you have `run_pypeit`." - ) + # msgs.warn( + # f"File {filename.name} does not have a corresponding PypeIt-processed 2D spectrum. " + # "Check the image type and whether you have `run_pypeit`." + # ) return # Define (and create, if needed) the QA directory for these plots qa_dir = spec2d_file.parents[1] / "QA" / "PDFs"