NREL / rdtools

PV Analysis Tools in Python
https://rdtools.readthedocs.io/
MIT License
146 stars 61 forks source link

global variable `filt` in `normalization.irradiance_rescale()` causes problems with parallel computing #388

Closed martin-springer closed 8 months ago

martin-springer commented 10 months ago

Describe the bug The function normalization.irradiance_rescale(method='iterative') uses a global variable filt to rescale the modeled irradiance and match with measured irradiance on clear days. This causes problems with parallel computing, since multiple threads share the same global variable filt. Hence, multiple threads will compete between defining and reading filt. This is not the intended behavior since every thread should have it's own variable filt for the computation.

Full error message and traceback IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match)

To Reproduce The bug can only be detected when the length of the irradiance of currently executed parallel computation differ from each other. This will depend on the number of parallel processes and the inverter data that are analyzed. Typically, this bug can be detected by starting a fleets_analysis run performing a clearsky analysis on one system with multiple inverters and changing the number of workers (CPUs). The occurrence of the error message will vary between runs with different CPUs.

Expected behavior The expected behavior is that filt always matches the length of the input irradiance data series. Individual parallel threads should not share the variable filt.

Additional context To resolve that issue, the variable filt needs to be local instead of global in _single_rescale().

mdeceglie commented 8 months ago

Addressed with #399