Skip to content

Commit

Permalink
change filt variable from global to local
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-springer committed Nov 16, 2023
1 parent 8013982 commit 8de679c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions rdtools/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -429,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
Expand Down

0 comments on commit 8de679c

Please sign in to comment.