-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add BrightSun clear-sky detection method #1061
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
I'd rather see explict kwargs than hide configuration in the dicts. Do we need to expose this much configuration in the API? I suspect that most users that are willing to modify the Passing zenith seems straightforward, especially if we skip the sunrise/sunset definition kwargs. -1 to passing Location objects. It's inconsistent with the rest of the pvlib function layer and promotes inefficient code. |
I agree about passing zenith, and avoiding sunrise and sunset argument. Hide the constant dicts and remove the kwargs? It might be nice to be able to turn off the duration filtering step. |
I'm probably missing something, but this sounds like 1 kwarg (perhaps a boolean that controls several parameters) and the rest is hard coded within the function. So I don't see where private constant dicts are going to be helpful in this case but you'd know better than me at this point. Are you working from the source code at https://github.com/JamieMBright/csd-library? Looks like you'll need to include a copy of the apache license. |
one kwarg to control if duration filters are used or not. My preference would be to keep private dict constants as a way to bundle like parameters in case a user wants to modify them. To me, that's more convenient than having to find the parameters inside the function. I'm working primarily from the paper, referring to the Matlab code to clarify details, so I suppose a case could be made that it's not a derivative work. Better safe than not, however. Any advice on how to include that lengthy license? Definitely do not want to add 200 lines of text to the docstring. |
Perhaps add a LICENSES directory like pandas https://github.com/pandas-dev/pandas/tree/master/LICENSES |
That's not a bad idea. Are you sure that a native python implementation is a derivative work? The way I read that definition, I don't think it is: For the purposes of this License, Derivative Works The Work is the Matlab code, which isn't used here at all. In effect the code is used as supplemental documentation for the paper. |
I am not. Maybe @mikofski or someone else knows better. Happy to trust your instincts on it. I was initially under the impression that you were more porting the code than re-implementing the paper. |
An issue with using a |
Is this an issue because the filters are based on minutes from sunrise/sunset rather than a zenith angle? The
I'd really like to avoid calculating solar position within the function. It's a relatively expensive computation and it's likely the user already has that data at hand. Is there a requirement that the data is 1 minute or < 15 minute intervals? |
Yes, the filters are defined by minutes from sunrise/sunset, and the algorithm is designed for minute data. No requirement that the data are regular, that's more a limitation of the python implementation. The developers anticipated processing many days of data but there's no inherent reason it couldn't be applied to a single day. If the user has trimmed data to e.g. GHI > 100, then the data won't include sunrise and sunset times. It seems awkward to require that the input span before sunrise/after sunset. Do you think that e.g. |
I'm switching between tabs and projects struggling with solar position. I was under the impression that zenith is needed for other binning purposes, which is part of why I keep coming back to it.
I'd advise this user to perform the GHI trim after the clear sky filter. I don't think that's unreasonable.
https://pvlib-benchmarker.github.io/pvlib-benchmarks/#summarylist?sort=0&dir=asc shows that |
A recent paper describes improvements on
pvlib.clearsky.detect_clearsky
. I've got a port of their Matlab code to a python functiondetect_clearsky_brightsun
, and trying to keep the interface common for the two detect_clearsky functions.Although the BrightSun method uses the similar statistics to determine clearsky times, the limits aren't constants - they are functions of zenith. And the method needs additional parameters for the duration filters and the optimization of the clear-sky model. The duration filters are different in the ~hour after sunrise/before sunset than in midday.
I have the limit and control arguments coded as dicts and provide constant dicts with the default values (which needs to change, since we don't want mutable defaults).
For the solar position related inputs (zenith and sunrise/sunset times), several options:
pvlib.location.Location
and calculate solar position and sunrise/set times internal todetect_clearsky_brightsun
. This is what I have done in the draft function, it makes the code straightforward but at the expense of a less-than-explicit interface.zenith
,sunrise
andsunset
as separate arguments. This seems awkward and somewhat risky, since calculating sunrise and sunset times withpvlib.solarposition.rise_set_transit_xxx
can have different behaviors (e.g., using_spa
the first sunset time is after the first sunrise time, even if the data start at midday,_ephem
has a kwarg that controls this behavior and returns the first sunset after the first data point).zenith
only and a kwarg for a zenith angle that defines sunrise and sunset, rather than asking for sunrise/sunset as input or using thesolarposition
functions.Interested in feedback about this approach before I open a PR.
Current
detect_clearsky
function:Draft new function and dicts:
The values for the
BRIGHT_SUN_LIMITS
dict are functions:The text was updated successfully, but these errors were encountered: