-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Prilliman et al transience model to pvlib.temperature #1391
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
Conversation
Ready for review. @mjprilliman comments are welcome :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked at the test details yet
|
||
time_step = (temp_cell.index[1] - temp_cell.index[0]).total_seconds() | ||
if time_step >= 1200: | ||
# too coarsely sampled for smoothing to be relevant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a warning here would be appropriate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extend the message to say that the return values are the original temperature?
Co-authored-by: Cliff Hansen <[email protected]>
Co-authored-by: Anton Driesse <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! All minor (hopefully) comments below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar enough with pvlib to give a full review but the function implementation looks good to me. Thanks @kanderso-nrel !
Thanks @wholmgren for the comments, was just lazy of me to not document that numpy magic. I came up with it and still had to remind myself how it worked! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any further comments or should we merge?
I'd like to take one more look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You win some unnamed award for excellent in-line comments
Co-authored-by: Cliff Hansen <[email protected]>
Actually I think there may be a flaw in this implementation regarding treatment of nans. Please do not merge yet! |
Ok, fixed. The problem was that NaNs in the input temperature were correctly ignored in the numerator ( I don't think this should be controversial but it's probably worth another pair of eyes. Thanks! |
value. At the beginning of the series where a full 20 minute window is not | ||
possible, partial windows are used instead. | ||
|
||
References |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more suggestion: explain in Notes how nan
in inputs corresponds to nan
in output. It makes sense (to me) that output at k
is nan
if windspeed[k]
is nan
. As a user, I may be surprised non-nan
at position k
in output when input temp_cell[k]
is nan
. But that also makes sense, because the non-nan
value can be produced when window of temp_cell
prior to k
has data.
Output ``temp_cell[k]`` is NaN when input ``wind_speed[k]`` is NaN, or when no non-NaN data are
in the input temperature for the 20 minute window preceding index ``k``.
I had noticed these also, with appreciation. |
------- | ||
temp_cell : pandas.Series | ||
Smoothed version of the input cell temperature [C] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add here that the original data is returned if too coarsely sampled.
|
||
time_step = (temp_cell.index[1] - temp_cell.index[0]).total_seconds() | ||
if time_step >= 1200: | ||
# too coarsely sampled for smoothing to be relevant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extend the message to say that the return values are the original temperature?
If no objections, will merge tomorrow. |
# np.sum for denominator to propagate nans in input wind speed. | ||
numerator = np.nansum(subsets * weights, axis=1) | ||
denominator = np.sum(weights, axis=1) | ||
smoothed = numerator / denominator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kanderso-nrel this line emitted a warning despite the comment on lines 967-969 that suggested otherwise. Is this a version-specific issue? My versions are below...
INSTALLED VERSIONS
------------------
commit : 66e3805b8cabe977f40c05259cc3fcf7ead5687d
python : 3.9.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18363
machine : AMD64
processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 1.3.5
numpy : 1.20.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the only way I can reproduce this is if there is a stretch of NaN in the input lasting longer than 20 minutes -- is that true for your case? That comment is referring to a div by zero warning cause by a quirk of this implementation (no weights for the very first value), not a div by zero warning caused by nans in the input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks. Yes, I had 38 minutes of NaN temperatures. I filled only the middle point with a valid number and the warning disappeared.
docs/sphinx/source/api.rst
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).This PR adds a cleaned-up version of
prilliman_v5
from this notebook: https://gist.github.com/kanderso-nrel/1d6da384d7af8afc24c230f1f144eb57Also: I noticed that one of the links in the PR template is out of date so I updated that here too.