From 878726d43354d9a4f95e5c766e3dc7985631b4b7 Mon Sep 17 00:00:00 2001 From: Taylor J Bell Date: Fri, 17 Jul 2026 15:35:37 -0400 Subject: [PATCH 1/2] Suppress expected GTVT future-date warnings Limit the ERFA dubious-year suppression to Ephemeris construction, where jwst_gtvt validates its internal maximum date. Add a regression test confirming unrelated ERFA warnings are still emitted. --- exoctk/contam_visibility/new_vis_plot.py | 13 +++++++++++- exoctk/tests/test_contam_visibility.py | 26 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/exoctk/contam_visibility/new_vis_plot.py b/exoctk/contam_visibility/new_vis_plot.py index 29050686..02e7dbf5 100644 --- a/exoctk/contam_visibility/new_vis_plot.py +++ b/exoctk/contam_visibility/new_vis_plot.py @@ -4,6 +4,7 @@ import warnings from astropy.time import Time +from erfa import ErfaWarning from bokeh.models import Band, ColumnDataSource, HoverTool from bokeh.plotting import figure, show @@ -145,7 +146,17 @@ def get_exoplanet_positions(ra, dec, in_FOR=None): while dec[-1] not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.']: dec = dec[:-1] - eph = BoundedEphemeris() + # jwst_gtvt validates its future maximum date during construction, which + # can emit an ERFA warning about uncertain leap seconds. Keep this + # suppression local so other ERFA warnings remain visible to callers. + with warnings.catch_warnings(): + warnings.filterwarnings( + 'ignore', + message=(r'ERFA function "dtf2d" yielded .*' + r'"dubious year \(Note 6\)"'), + category=ErfaWarning, + ) + eph = BoundedEphemeris() exoplanet_data = eph.get_fixed_target_positions(ra, dec) if in_FOR is None: diff --git a/exoctk/tests/test_contam_visibility.py b/exoctk/tests/test_contam_visibility.py index 3d2e8ebf..ed12a0c5 100644 --- a/exoctk/tests/test_contam_visibility.py +++ b/exoctk/tests/test_contam_visibility.py @@ -34,6 +34,7 @@ import pytest import pysiaf import requests +from erfa import ErfaWarning from pandas import DataFrame from astropy.io import fits @@ -359,6 +360,31 @@ def test_build_visibility_plot_reuses_positions(monkeypatch): assert 'times' not in positions +def test_visibility_ephemeris_suppresses_only_expected_erfa_warning(monkeypatch): + """The jwst_gtvt future-date warning must not hide other warnings.""" + + class WarningEphemeris: + def __init__(self, *args, **kwargs): + warnings.warn( + 'ERFA function "dtf2d" yielded 1 of "dubious year (Note 6)"', + ErfaWarning, + ) + warnings.warn('unrelated ERFA warning', ErfaWarning) + + def get_fixed_target_positions(self, ra, dec): + return DataFrame({'in_FOR': [True]}) + + monkeypatch.setattr(new_vis_plot, 'BoundedEphemeris', WarningEphemeris) + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter('always') + result = new_vis_plot.get_exoplanet_positions('24.3544618', + '-45.6777937') + + assert isinstance(result, DataFrame) + assert [str(warning.message) for warning in caught] == [ + 'unrelated ERFA warning'] + + @pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Need access to trace data FITS files. Please try running locally') def test_field_simulation(): """Tests the ``field_simulation`` function in the ``field_simulator`` module""" From bf2685934700e627753ae69461f781cca2d683d9 Mon Sep 17 00:00:00 2001 From: Taylor J Bell Date: Tue, 4 Aug 2026 00:05:36 -0400 Subject: [PATCH 2/2] Clarify and isolate ERFA warning suppression --- exoctk/contam_visibility/new_vis_plot.py | 4 ++-- exoctk/tests/test_contam_visibility.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/exoctk/contam_visibility/new_vis_plot.py b/exoctk/contam_visibility/new_vis_plot.py index 02e7dbf5..6287f8ca 100644 --- a/exoctk/contam_visibility/new_vis_plot.py +++ b/exoctk/contam_visibility/new_vis_plot.py @@ -147,8 +147,8 @@ def get_exoplanet_positions(ra, dec, in_FOR=None): dec = dec[:-1] # jwst_gtvt validates its future maximum date during construction, which - # can emit an ERFA warning about uncertain leap seconds. Keep this - # suppression local so other ERFA warnings remain visible to callers. + # can emit ERFA's expected "dubious year" warning. Keep this suppression + # local so other ERFA warnings remain visible to callers. with warnings.catch_warnings(): warnings.filterwarnings( 'ignore', diff --git a/exoctk/tests/test_contam_visibility.py b/exoctk/tests/test_contam_visibility.py index ed12a0c5..e04004a0 100644 --- a/exoctk/tests/test_contam_visibility.py +++ b/exoctk/tests/test_contam_visibility.py @@ -376,12 +376,13 @@ def get_fixed_target_positions(self, ra, dec): monkeypatch.setattr(new_vis_plot, 'BoundedEphemeris', WarningEphemeris) with warnings.catch_warnings(record=True) as caught: - warnings.simplefilter('always') + warnings.simplefilter('ignore') + warnings.simplefilter('always', ErfaWarning) result = new_vis_plot.get_exoplanet_positions('24.3544618', '-45.6777937') assert isinstance(result, DataFrame) - assert [str(warning.message) for warning in caught] == [ + assert [str(w.message) for w in caught] == [ 'unrelated ERFA warning']