-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Set negative values of AOI loss to 0 rather than np.nan #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks Cliff for opening an issue! It refers to my question in the google group. If I find time in the next couple of days, and if there is consent on the issue, I will start working on a pull request. |
(waves at Johannes) you’re welcome ☺
|
I can see arguments for nans or 0s. I think nan could be the right result because maybe it doesn't make sense to talk about an AOI modifier when the sun is behind the array plane. In a similar fashion, pvlib's relative airmass function returns nan when the zenith angle is greater than 90. On the other hand, I can think of at least a few of my results where I've failed to account for these nans, so that's a good indicator that something should change. One thing is for certain: ModelChain fails to account for the nans in its effective_irradiance calculation and that should be fixed as soon as possible. |
I am in favour of having having all the iam functions return a value of zero or greater for any angle, except maybe an angle that is nan. It appears that currently the comments for physicaliam don't correspond to the code, and furthermore, each of the three available iam models has slightly different constraints. |
The code below should allow you to monkey patch your modelchain objects until we get this fixed: import types
def effective_irradiance_model_corrected(self):
fd = self.system.module_parameters.get('FD', 1.)
self.effective_irradiance = self.spectral_modifier * (
self.total_irrad['poa_direct']*self.aoi_modifier.fillna(0) +
fd*self.total_irrad['poa_diffuse'])
return self
mc = ModelChain(system, location, **your_normal_kwargs)
mc.effective_irradiance_model = types.MethodType(effective_irradiance_model_corrected, mc)
mc.run_model(times, weather=weather) # as if nothing has changed AC power without the patch: and with the patch: |
Thanks for the fix, @wholmgren. I forked the project and changed the functions for myself though (see PR). |
* changed np.nan to 0 in functions ashraeiam, physicaliam, sapm_aoi_loss * updated docstrings * updated tests to account for changes in functions * replace 0-degree aoi in physicaliam with 1e-06, analogous to the calculation of tau0 * updated tests to account for input angles of np.nan * updated test for ashraeiam to check for possible negative values for input angles close to 90° * updated docstring with info about nan-inputs resulting in nan. * updated variables-and-symbols-page with allowable range of aoi * changed whatsnew for v0.5 * applied @adriesse suggestion to split calculation of tau * forgot to delete unused line * typo :-( * typo in variables_styles_rules * implemented code suggestion by @adriesse
closed by #339 |
The current AOI loss models set negative values to np.nan, rather than zero. When np.nans are propagated to the effective irradiance model, the beam irradiance (and the effective irradiance) becomes np.nan rather than 0. As a consequence, pvlib cannot compute effective irradiance when AOI>90, i.e., when the sun is behind the array plane. In this circumstance there's still diffuse irradiance on the array plane.
I think it would be better to implement the AOI loss models as
f(AOI) = model value if AOI<90
f(AOI) = 0 otherwise.
The text was updated successfully, but these errors were encountered: