Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
1.2.1 (Unreleased)
==================

- Fixed crash for ``astrometric_catalog`` for background observations
- Fixed crash when filtering out guide stars
- Fixed issue with background files in ``move_raw_obs_step``
- Fixed logging, will now properly output to a log file
- Fix crash for background observations in ``get_short_band_name``
- For background association, strip whitespace and lowercase for more robust matching
- Imports update - now supports numpy>2.0!
Expand Down
18 changes: 17 additions & 1 deletion pjpipe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import logging
import os
import re
import sys
from datetime import datetime
from importlib.metadata import version
from logging.handlers import RotatingFileHandler

# Set the CRDS server URL before any imports
os.environ["CRDS_SERVER_URL"] = "https://jwst-crds.stsci.edu"
Expand All @@ -12,6 +14,20 @@
# Get the version
__version__ = version(__name__)

# Set up the logger
log = logging.getLogger(__name__)
dt = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
log_file = f"pjpipe_{dt}.log"
log_level = "INFO"
log_format = "%(asctime)s - %(levelname)s - %(message)s"
logging.basicConfig(level=logging.INFO,
format=log_format,
handlers=[
logging.FileHandler(log_file),
logging.StreamHandler(),
]
)

from .apply_wcs_adjust import ApplyWCSAdjustStep
from .astrometric_align import AstrometricAlignStep
from .astrometric_catalog import AstrometricCatalogStep
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/anchoring/anchoring_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
matplotlib.rcParams['font.family'] = 'STIXGeneral'
matplotlib.rcParams['font.size'] = 14

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


def line_func_curvefit(x, b, m):
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/apply_wcs_adjust/apply_wcs_adjust_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

from ..utils import band_exts

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


class ApplyWCSAdjustStep:
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/astrometric_align/astrometric_align_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"exact",
]

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


def get_lv3_wcs(im):
Expand Down
9 changes: 5 additions & 4 deletions pjpipe/astrometric_catalog/astrometric_catalog_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
from astropy.wcs import WCS
from photutils.detection import DAOStarFinder, IRAFStarFinder

from ..utils import parse_parameter_dict, fwhms_pix, sigma_clip, recursive_setattr
from ..utils import parse_parameter_dict, fwhms_pix, sigma_clip, recursive_setattr, get_short_band_name

from .constrained_diffusion import constrained_diffusion

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

ALLOWED_STARFIND_METHODS = [
"dao",
Expand Down Expand Up @@ -143,7 +142,9 @@ def generate_astro_cat(
mean, median, rms = sigma_clip(data, dq_mask=mask)
threshold = median + snr * rms

kernel_fwhm = fwhms_pix[self.band]
# Make sure we only have the filter here
short_band = get_short_band_name(self.band)
kernel_fwhm = fwhms_pix[short_band]

if self.starfind_method == "dao":
finder = DAOStarFinder
Expand Down
5 changes: 2 additions & 3 deletions pjpipe/download/download_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
from stdatamodels.jwst import datamodels
from tqdm import tqdm

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


def download(
Expand Down Expand Up @@ -437,7 +436,7 @@ def get_products(

# Filter out guide stars if requested
if self.filter_gs:
mask = np.char.find(products["dataURI"], "_gs-") == -1
mask = ["_gs-" not in x for x in products["dataURI"]]
products = products[mask]

# Perform filtering if requested
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/gaia_query/gaia_query_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from astropy.coordinates import name_resolve
from astroquery.gaia import Gaia

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


class GaiaQueryStep:
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/get_wcs_adjust/custom_catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

from ..astrometric_catalog.constrained_diffusion import constrained_diffusion

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


def constrained_diffusion_catalog(datamodel,
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/get_wcs_adjust/get_wcs_adjust_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

from .custom_catalogs import constrained_diffusion_catalog

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

RAD_TO_ARCSEC = 3600 * np.rad2deg(1)

Expand Down
3 changes: 1 addition & 2 deletions pjpipe/level_match/level_match_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
matplotlib.rcParams['font.family'] = 'STIXGeneral'
matplotlib.rcParams['font.size'] = 14

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


def get_dithers(files,
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/lv1/lv1_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

from ..utils import attribute_setter, save_file

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

# Set OpenCV number of threads to 1 to avoid MP issues on newer Macbooks
cv.setNumThreads(1)
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/lv2/lv2_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

from ..utils import get_band_type, get_obs_table, attribute_setter, save_file

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

BGR_CHECK_TYPES = [
"parallel_off",
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/lv3/lv3_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class ModelLibrary:
get_short_band_name,
)

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

BGR_CHECK_TYPES = [
"parallel_off",
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/lyot_mask/lyot_mask_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

from ..utils import get_dq_bit_mask

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

ALLOWED_METHODS = ["mask", "mask_overlap"]

Expand Down
3 changes: 1 addition & 2 deletions pjpipe/lyot_separate/lyot_separate_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

from ..utils import get_dq_bit_mask

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

# Rough lyot outline
LYOT_I = slice(735, None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

from ..utils import parse_parameter_dict, recursive_setattr

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


class MosaicIndividualFieldsStep:
Expand Down
5 changes: 2 additions & 3 deletions pjpipe/move_raw_obs/move_raw_obs_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

from ..utils import get_band_ext, get_band_type, save_file, get_short_band_name

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


class MoveRawObsStep:
Expand Down Expand Up @@ -257,7 +256,7 @@ def move_raw_files(
save_file(im=im, out_name=hdu_out_name, dr_version=self.dr_version)

elif self.band_type == "miri":
if hdu_filter == self.band:
if hdu_filter == band_short:
save_file(im=im, out_name=hdu_out_name, dr_version=self.dr_version)

del im
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/multi_tile_destripe/multi_tile_destripe_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
matplotlib.rcParams['font.family'] = 'STIXGeneral'
matplotlib.rcParams['font.size'] = 14

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

ALLOWED_WEIGHT_METHODS = [
"mean",
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
"release": None,
}

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


class PJPipeline:
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/psf_matching/psf_matching_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

from ..utils import do_jwst_convolution

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


class PSFMatchingStep:
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/psf_model/psf_model_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
from ..utils import get_dq_bit_mask, make_source_mask

matplotlib.use("agg")
log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

ALLOWED_METHODS = ["replace", "subtract"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
matplotlib.rcParams['font.family'] = 'STIXGeneral'
matplotlib.rcParams['font.size'] = 14

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


def get_diff_image(
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/release/release_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from astropy.io import fits
from tqdm import tqdm

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


class ReleaseStep:
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/single_tile_destripe/single_tile_destripe_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
matplotlib.rcParams['font.family'] = 'STIXGeneral'
matplotlib.rcParams['font.size'] = 14

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)

DESTRIPING_METHODS = [
"row_median",
Expand Down
3 changes: 1 addition & 2 deletions pjpipe/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@
"miri": "mirimage",
}

log = logging.getLogger("stpipe")
log.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)


def get_pixscale(hdu):
Expand Down