From 73f2e3e78dd3737da1c2276915b1c56eaff9e848 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Tue, 12 Sep 2023 10:11:45 -0600 Subject: [PATCH 1/2] change filt variable from global to local --- rdtools/normalization.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rdtools/normalization.py b/rdtools/normalization.py index df0821008..8629c2373 100644 --- a/rdtools/normalization.py +++ b/rdtools/normalization.py @@ -380,7 +380,7 @@ def irradiance_rescale(irrad, irrad_sim, max_iterations=100, ''' if method == 'iterative': - def _rmse(fact): + def _rmse(fact, filt): """ Calculates RMSE with a given rescale fact(or) according to global filt(er) @@ -392,10 +392,9 @@ def _rmse(fact): def _single_rescale(irrad, irrad_sim, guess): "Optimizes rescale factor once" - global filt csi = irrad / (guess * irrad_sim) # clear sky index filt = (csi >= 0.8) & (csi <= 1.2) & (irrad > 200) - min_result = minimize(_rmse, guess, method='Nelder-Mead') + min_result = minimize(_rmse, guess, (filt), method='Nelder-Mead') factor = min_result['x'][0] return factor From 7e2b095f4e43884bec2181a3cdc1cf3775458aec Mon Sep 17 00:00:00 2001 From: martin-springer Date: Thu, 16 Nov 2023 10:25:26 -0700 Subject: [PATCH 2/2] update minimize in single_opt --- rdtools/normalization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdtools/normalization.py b/rdtools/normalization.py index 8629c2373..c46ef79ea 100644 --- a/rdtools/normalization.py +++ b/rdtools/normalization.py @@ -428,7 +428,7 @@ def _rmse(fact): guess = np.percentile(irrad.dropna(), 90) / \ np.percentile(irrad_sim.dropna(), 90) - min_result = minimize(_rmse, guess, method='Nelder-Mead') + min_result = minimize(_rmse, guess, (filt), method='Nelder-Mead') factor = min_result['x'][0] out_irrad = factor * irrad_sim