From 61b2cb3fc916b36c7ee11c02e556345a1d1fb210 Mon Sep 17 00:00:00 2001 From: Nate Tellis Date: Wed, 26 Jun 2024 17:25:53 -0400 Subject: [PATCH] enforce exposure start and duration results from cutouts are float --- cutouts/io/nsc.py | 4 ++++ cutouts/main.py | 28 ++++++++++++++-------------- cutouts/tests/test_plot.py | 10 +++++----- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/cutouts/io/nsc.py b/cutouts/io/nsc.py index 1523551..2379e2a 100644 --- a/cutouts/io/nsc.py +++ b/cutouts/io/nsc.py @@ -67,6 +67,10 @@ def find_cutouts_nsc_dr2( _get_generic_image_url_from_cutout_url ) + # enforce exposure_start_mjd and exptime as float + results["exposure_start_mjd"] = results["exposure_start_mjd"].astype(float) + results["exposure_duration"] = results["exposure_duration"].astype(float) + results["exposure_id"] = results["cutout_url"].apply(exposure_id_from_url) results.reset_index(inplace=True, drop=True) diff --git a/cutouts/main.py b/cutouts/main.py index a8f6e43..4f443b9 100644 --- a/cutouts/main.py +++ b/cutouts/main.py @@ -288,12 +288,12 @@ def run_cutouts_from_precovery( "vdec": observations["pred_vdec_degpday"].values[i], "obj_ra": observations["ra_deg"].values[i], "obj_dec": observations["dec_deg"].values[i], - "mag": np.NaN, - "mag_sigma": np.NaN, + "mag": np.nan, + "mag_sigma": np.nan, "filter": None, "obscode": observations["obscode"].values[i], - "exposure_start": np.NaN, - "exposure_duration": np.NaN, + "exposure_start": np.nan, + "exposure_duration": np.nan, "exposure_id": None, } else: @@ -332,14 +332,14 @@ def run_cutouts_from_precovery( "path": None, "ra": observations["pred_ra_deg"].values[i], "dec": observations["pred_dec_deg"].values[i], - "vra": np.NaN, - "vdec": np.NaN, - "mag": np.NaN, - "mag_sigma": np.NaN, + "vra": np.nan, + "vdec": np.nan, + "mag": np.nan, + "mag_sigma": np.nan, "filter": None, "obscode": observations["obscode"].values[i], - "exposure_start": np.NaN, - "exposure_duration": np.NaN, + "exposure_start": np.nan, + "exposure_duration": np.nan, "exposure_id": None, } else: @@ -347,10 +347,10 @@ def run_cutouts_from_precovery( "path": comparison_result["cutout_image_path"], "ra": observations["pred_ra_deg"].values[i], "dec": observations["pred_dec_deg"].values[i], - "vra": np.NaN, - "vdec": np.NaN, - "mag": np.NaN, - "mag_sigma": np.NaN, + "vra": np.nan, + "vdec": np.nan, + "mag": np.nan, + "mag_sigma": np.nan, "filter": comparison_result["filter"], "obscode": observations["obscode"].values[i], "exposure_start": comparison_result["exposure_start_mjd"], diff --git a/cutouts/tests/test_plot.py b/cutouts/tests/test_plot.py index 3bceeb4..7baab9d 100644 --- a/cutouts/tests/test_plot.py +++ b/cutouts/tests/test_plot.py @@ -11,16 +11,16 @@ def test_add_velocity_vector_raises(): fig, ax = plt.subplots(1, 1) with pytest.raises(ValueError): - add_velocity_vector(ax, np.NaN, 0, 0, 0, 0) + add_velocity_vector(ax, np.nan, 0, 0, 0, 0) with pytest.raises(ValueError): - add_velocity_vector(ax, 0, np.NaN, 0, 0, 0) + add_velocity_vector(ax, 0, np.nan, 0, 0, 0) with pytest.raises(ValueError): - add_velocity_vector(ax, 0, 0, np.NaN, 0, 0) + add_velocity_vector(ax, 0, 0, np.nan, 0, 0) with pytest.raises(ValueError): - add_velocity_vector(ax, 0, 0, 0, np.NaN, 0) + add_velocity_vector(ax, 0, 0, 0, np.nan, 0) with pytest.raises(ValueError): - add_velocity_vector(ax, 0, 0, 0, 0, np.NaN) + add_velocity_vector(ax, 0, 0, 0, 0, np.nan)