From ae2a0731c1b39781b3242599d1918dc2fcff3e6a Mon Sep 17 00:00:00 2001 From: Barbara Bertozzi Date: Tue, 30 Sep 2025 00:33:01 +0200 Subject: [PATCH] Silence error for log10(0) when expected --- src/sp2xr/calibration.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sp2xr/calibration.py b/src/sp2xr/calibration.py index 7b377c2..b64deb0 100644 --- a/src/sp2xr/calibration.py +++ b/src/sp2xr/calibration.py @@ -227,9 +227,15 @@ def calibrate_single_particle( calibrate_particle_data, config=run_config, meta=meta_cal ) ddf_cal["time_lag"] = ddf_cal["Incand Peak Time"] - ddf_cal["Scatter Peak Time"] - ddf_cal["ratio_inc_scatt"] = np.log10(ddf_cal["Incand relPeak"]) / np.log10( - ddf_cal["Scatter relPeak"] - ) + + # Suppress divide by zero warning for log10(0) - expected for particles with no signal + import warnings + + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", message="divide by zero encountered in log10") + ddf_cal["ratio_inc_scatt"] = np.log10(ddf_cal["Incand relPeak"]) / np.log10( + ddf_cal["Scatter relPeak"] + ) ddf_cal = define_flags(ddf_cal, instr_config, run_config)