pvlib-python icon indicating copy to clipboard operation
pvlib-python copied to clipboard

DC model unexpectedly fills NaNs with 0

Open harakiricode opened this issue 3 years ago • 4 comments

I would like to report a behaviour in the dc models of pvlib, which was very unintuitive to me. Since it has been coded very explicitly though, I assume the behaviour has been considered.

I am on version 0.6.1 of pvlib, but the issue occurs on the current version, too. Using, for example the desoto dc model, NaNs are filled with 0 after calling scale_voltage_to_current_power. (v0.6.1 and current master). In my specific case, this means, that after having passed NaNs to the model chain in my weather dataframe, I receive valid numbers in the model chain result. I would have either expected the afflicted time steps to be NaN, a warning or an error.

Is this behaviour by the dc model - and as a result by the entire model chain - intended?

harakiricode avatar Feb 18 '22 13:02 harakiricode

You raise a fair point. That has been the behavior since the original ModelChain.singlediode method in v0.4.0. I can't say exactly why; my guess is so that ModelChain.result.dc.sum() returns a valid value.

cwhanse avatar Feb 18 '22 16:02 cwhanse

I agree that behavior is very bad and inconsistent with the general pvlib policy of "nan in, nan out". I don't remember, but if I had to guess, I may have added it as a very lazy way of handling missing nighttime values.

A pull request would be welcome.

wholmgren avatar Feb 23 '22 19:02 wholmgren