From 00bd39a098501b2d15d34eada8e095814e59a6c5 Mon Sep 17 00:00:00 2001 From: ftong Date: Wed, 10 Sep 2025 16:33:11 +0200 Subject: [PATCH] impose requirement of minimum size of range of output data to do image processing --- src/seismic_hazard_forecasting.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/seismic_hazard_forecasting.py b/src/seismic_hazard_forecasting.py index 6d314f7..12e9abe 100644 --- a/src/seismic_hazard_forecasting.py +++ b/src/seismic_hazard_forecasting.py @@ -519,8 +519,8 @@ verbose: {verbose}") dtype=np.float64) # this reduces values to 8 decimal places iml_grid_tmp = np.nan_to_num(iml_grid[j]) # change nans to zeroes - # upscale the grid if there are at least 10 grid values - if np.count_nonzero(iml_grid_tmp) >= 10: + # upscale the grid if there are at least 10 grid values with range greater than 0.1 + if np.count_nonzero(iml_grid_tmp) >= 10 and vmax-vmin > 0.1: up_factor = 4 iml_grid_hd = resize(iml_grid_tmp, (up_factor * len(iml_grid_tmp), up_factor * len(iml_grid_tmp)), mode='reflect', anti_aliasing=False) @@ -529,9 +529,10 @@ verbose: {verbose}") iml_grid_hd[iml_grid_hd == 0.0] = np.nan # change zeroes back to nan - # trim edges so the grid is not so blocky - vmin_hd = min(x for x in iml_grid_hd.flatten() if not isnan(x)) + #vmin_hd = min(x for x in iml_grid_hd.flatten() if not isnan(x)) vmax_hd = max(x for x in iml_grid_hd.flatten() if not isnan(x)) + + # trim edges so the grid is not so blocky trim_thresh = vmin iml_grid_hd[iml_grid_hd < trim_thresh] = np.nan