-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add NSRDB GOES v4 to iotools #2378
base: main
Are you sure you want to change the base?
Conversation
What's the best practice for lines like this one that end up too long? Do I simply add GOES_URL = NSRDB_API_BASE + "/api/nsrdb/v2/solar/nsrdb-GOES-aggregated-v4-0-0-download.csv" |
You could use parentheses GOES_URL = NSRDB_API_BASE + ("/api/nsrdb/v2/solar/"
"nsrdb-GOES-aggregated-v4-0-0-download.csv") or just break the string smaller and add them API_STUB = "/api/nsrdb/v2/solar/"
ENDPOINT = "nsrdb-GOES-aggregated-v4-0-0-download.csv"
GOES_URL = (NSRDB_API_BASE
+ API_STUB + ENDPOINT) imo avoid ignoring pep8 warnings or else they become pointless. |
Thanks, @mikofski! |
Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com>
I'm not 100% sure that I set up the tests in See I think it's correct, but I could be misunderstanding the goals of some of the tests. |
Ok, made the switch from "goes4" to "psm4". I haven't done anything with @kandersolar's suggestion for different |
WIP: handful of minor things
Ok, I made an effort to create separate I'll hold off on merging that with the branch in this PR (https://github.com/williamhobbs/pvlib-python/tree/nsrdb_goes_v4) until someone suggests that I do it - I don't want to make a mess of things too quickly. |
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.
A few initial comments
pvlib/iotools/psm4.py
Outdated
return parse_psm4(fbuf, map_variables) | ||
|
||
|
||
def parse_psm4(fbuf, map_variables=True): |
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 personally think we should get rid of the parse functions as it creates a LOT of duplicate documentation and significantly more functions than needed. It's unnecessary clutter and it takes very little to modify read functions to also take filebuffers.
Alternatively, we could consider making the parse functions private.
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 am generally +1 to ditching parse_
and having read_
work with buffers as well as filenames. But let's do it as a follow-up PR.
pvlib/tests/iotools/test_psm4.py
Outdated
@pytest.fixture(scope="module") | ||
def nrel_api_key(): | ||
"""Supplies pvlib-python's NREL Developer Network API key. | ||
Azure Pipelines CI utilizes a secret variable set to NREL_API_KEY | ||
to mitigate failures associated with using the default key of | ||
"DEMO_KEY". A user is capable of using their own key this way if | ||
desired however the default key should suffice for testing purposes. | ||
""" | ||
try: | ||
demo_key = os.environ["NREL_API_KEY"] | ||
except KeyError: | ||
warnings.warn( | ||
"WARNING: NREL API KEY environment variable not set! " | ||
"Using DEMO_KEY instead. Unexpected failures may occur." | ||
) | ||
demo_key = 'DEMO_KEY' | ||
return demo_key |
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.
If it's the same key as for the PSM3, then I suggest importing it from that test module (should be possible?) to avoid duplicating code.
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.
holding off on this, per a conversation with @kandersolar
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 moved the fixture to conftest and imported it in both psmN test modules
Given the unanimous vote and the three weeks passed (see #2326 (comment)), you can go ahead with splitting the functions into individual ones. Please still consider the comments above 😄 |
Ok @AdamRJensen, I implemented many of your comments into https://github.com/williamhobbs/pvlib-python/tree/nsrdb_psm4_dedicated_get_functions. I may be at the limit of my git/GitHub knowledge, though. What do I do next to get those changes (along with the dedicated functions) from that branch into this PR? I can follow up offline if that's best... Edit: I sorted this out, thanks to help from @kandersolar. |
…tions Nsrdb psm4 dedicated get functions
@AdamRJensen - I think I addressed all of your comments in one way or another. Thanks for the review - I think I forgot to say that earlier. |
Co-authored-by: Will Holmgren <william.holmgren@gmail.com>
iotools.get_nsrdb_psm4_conus | ||
iotools.get_nsrdb_psm4_full_disc | ||
iotools.read_nsrdb_psm4 | ||
iotools.parse_nsrdb_psm4 |
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.
Why don't we make this a private function for now so we don't have to deprecate it later?
names : str, default '2023' | ||
PSM4 API parameter specifing year (e.g. ``2023``) to download. The | ||
allowed values update periodically, so consult the NSRDB reference | ||
below for the current set of options. |
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.
No need to follow the strange naming convention of PSM. I suggest renaming this to year
.
url : str, optional | ||
Full API endpoint URL. If not specified, the PSM4 GOES Aggregated v4 | ||
URL is used. | ||
timeout : int, default 30 | ||
time in seconds to wait for server response before timeout | ||
utc: bool, default : False | ||
retrieve data with timestamps converted to UTC. False returns | ||
timestamps in local standard time of the selected location |
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 suggest changing the order such that the api specific parameters comes first, i.e., have utc
come before map_variables, url, and timeout - this is a somewhat unwritten convention for the iotools functions.
PSM4 API parameter specifing TMY variant to download (e.g. ``'tmy'`` | ||
or ``'tgy-2022'``). The allowed values update periodically, so | ||
consult the NSRDB references below for the current set of options. | ||
time_period : int, {60} |
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.
Time period could be thought of as what time period is covered, i.e., start to end. I think time_step
is a better name for this parameter (this is also what is used by the pvlib.iotools.get_cams function).
return data, metadata | ||
|
||
|
||
def read_nsrdb_psm4(filename, map_variables=True): |
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.
Could this function be called read_sam
instead?
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 read_sam
could be misinterpreted. SAM isn't the NSRDB, it is a user of that data; read_sam
could be confused with retrieve_sam
; and SAM is moving towards exporting a JSON file for a simulation, which could be of future interest to pvlib users.
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
docs/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.