-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow read_tmy3 to handle 00:00 timestamps #1494
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
@KWagnerCPR could you provide a TMY3 file from SolarAnywhere that can be added to pvlib for testing purposes? Alternatively, with CPR's permission, I can also easily download one myself. |
@AdamRJensen I've attached the full historical time series in TMY3 format for one of our Public sites here. |
A long time ago in a commit far, far away, that's what the function's return value was called: Lines 42 to 45 in fef3d51
Inherited from the MATLAB code, presumably: https://github.com/sandialabs/MATLAB_PV_LIB/blob/master/pvl_readtmy3.m
This pair of eyes agrees with yours; the index includes a fixed UTC offset. The part about not including DST should be kept though. |
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 we need to add a Note to read_tmy3
to the effect that the function can read TMY3 files from either the NRSDB or from SolarAnywhere. The document references are specific to the NSRDB. SolarAnywhere TMY3 is described here: https://www.solaranywhere.com/support/historical-data/file-formats/
pvlib/tests/iotools/test_tmy.py
Outdated
TMY3_TESTFILE = DATA_DIR / '703165TY.csv' | ||
TMY2_TESTFILE = DATA_DIR / '12839.tm2' | ||
TMY3_FEB_LEAPYEAR = DATA_DIR / '723170TYA.CSV' |
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 would add a comment here identifying the source of these files as the NSRDB, because the NSRDB TMY3 format is different from SolarAnywhere's.
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 tried to remove the |
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 just tagged this PR with remote-data
so that the iotools tests run. I get the same encoding failure locally, FYI.
In hindsight, requiring the remote-data
tag to be present before running any iotools tests, not just the actual --remote-data
tests, is probably not actually what we want. Might be as simple as just removing the --ignore
options in the workflow command.
Huh! I was very surprised to see test failures. I could not replicate them locally, so I imagine it's a windows/linux thing. My best guess is that the ® (registered) symbol in the test file is not parseable on Linux (at least not by default). For now, I have just removed it from the file. I think the best thing would be for CPR to remove it generally from their files and perhaps replace it with (R) or the phrase "Registered, U.S. Patent and Trademark Office". Alternatively, we could look into specifying some specific encoding settings when opening the file 🤷 @kanderso-nrel thoughts?
I'm not quite sure what you're talking about here.. |
I think technically that would be in violation of the CPR license file included in the zip archive posted earlier:
I'm not optimistic that CPR would get rid of that character or change their file encoding just for us (maybe I'm wrong!), but I'm not sure what the best alternative is. FWIW specifying
Sorry, was just thinking out loud that we should probably follow up #1306 with some tweaks. No changes needed here. |
@kanderso-nrel I have added the registrered symbol back in the file. I could always make a custom TMY3 file with 00:00 timestamps for testing. But without the @KWagnerCPR It is probably of interest to you to know that the registered ® symbol may cause issues when parsing SolarAnywhere files. Although I've implemented a workaround, it might be an issue for other users / different software in the future. It may be advisable to replace the symbol with a sentence of equivalent legal meaning, e.g., "Registered, U.S. Patent and Trademark Office". Just for your consideration. |
Co-authored-by: Kevin Anderson <kevin.anderson@nrel.gov>
Changing the SolarAnywhere encoding would break existing code, so I wouldn't recommend that unless they bumped their API to 4.0. |
The |
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.
Thanks @AdamRJensen!
[ ] Closes #xxxx[ ] Updates entries indocs/sphinx/source/reference
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`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.As mentioned by @williamhobbs in #1310 (reply in thread), SolarAnywhere TMY3 files specify midnight as 00:00 instead of 24:00 (which is the NREL TMY3 convention). Currently, the pvlib
read_tmy3
function incorrectly treats 00:00 and 24:00 equally by renaming both time stamps to 00:00 and shifting the time stamp one day ahead. This behavior is correct for the 24:00 timestamps but incorrectly shifts 00:00 instances one day ahead.This PR proposes a minor change to handle both 00:00 and 24:00 timestamps correctly. Additionally, I've made trivial documentation updates to more closely follow the numpydoc style.