From 2ee7660007dbe7eb1ac73b53ecfcb79e4e1d8f80 Mon Sep 17 00:00:00 2001 From: Davey Elder Date: Tue, 11 Aug 2026 17:52:50 -0400 Subject: [PATCH] Fix percentile threshold for DSD normalisation Signed-off-by: Davey Elder --- representative_periods/database_processing_v4_0.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/representative_periods/database_processing_v4_0.py b/representative_periods/database_processing_v4_0.py index ad848c8..161d01c 100644 --- a/representative_periods/database_processing_v4_0.py +++ b/representative_periods/database_processing_v4_0.py @@ -262,9 +262,9 @@ def process_single_day_period(database: str, hours: list): # Get a running proportion sum of DSD df['run_sum'] = df['dsd'].cumsum()/df['dsd'].sum() - # Get the smallest DSD above thresh to zero out actual table + # Get the largest DSD whose cumulative proportion is still below the threshold thresh_dsd = df["dsd"].loc[df["run_sum"] < utils.config["dsd_threshold"]].max() - thresh_dsd += 1e-12 # Small buffer to avoid floating point issues + thresh_dsd -= 1e-10 # Small buffer to avoid floating point issues # There might be nothing under the threshold if using few rep days if not pd.isna(thresh_dsd) and thresh_dsd < df["dsd"].max():