Skip to content

Add ability to read local NSRDB PSM3 CSVs #841

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

Closed
kandersolar opened this issue Dec 19, 2019 · 5 comments · Fixed by #842
Closed

Add ability to read local NSRDB PSM3 CSVs #841

kandersolar opened this issue Dec 19, 2019 · 5 comments · Fixed by #842

Comments

@kandersolar
Copy link
Member

Unless I've missed something in the docs, the only pvlib function that parses PSM3 CSVs is iotools.get_psm3, which requires making a network request to the NSRDB PSM3 API. It would be nice to be able to read local PSM3 files (e.g. those downloaded manually from the NSRDB Viewer) in addition to requesting them from the web API. Here are a couple proposals:

  • Break out the parsing code in iotools.get_psm3 into its own function iotools.read_psm3, leaving get_psm3 as a networking wrapper around the PSM3 API that then calls read_psm3 on the API response.
  • Modify get_psm3 to check if the input is a filename instead of API parameters and retrieve data as appropriate.

I'd favor the former since it separates networking code from parsing code. Some other iotools.read_* functions can make web requests, but those are just simple urls and more or less equivalent to reading a local file whereas get_psm3 has to construct a full API request.

@cwhanse
Copy link
Member

cwhanse commented Dec 19, 2019

Does a PSM3 file for a specific year follow the TMY3 format? I think the PSM3 also delivers TMY3 files, if requested. If it doesn't, then I'd say yes, a read_psm3 function would be of value.

@kandersolar
Copy link
Member Author

I believe the both the NSRDB Viewer and its API export single-year and TMY data in the SAM CSV format, which is what get_psm3 is currently parsing. I took a look and didn't see an option to change the output format in the web interface, but if there a way to export in TMY3 format then I'm happy to just use that.

It occurs to me that a better name might be read_sam_csv or similar instead of read_psm3.

@cwhanse
Copy link
Member

cwhanse commented Dec 19, 2019

My earlier comment is an unclear mess. Let me try again.

Does a PSM3 file for a specific year follow the TMY3 format? If the format is not TMY3, then I'd say a separate function to read that format could be of value. I don't have a preferred name, although read_sam seems too specific for a function that also reads NSRDB files.

You can get TMY3 files from the NSRDB by passing names='tmy' although this is not mentioned in the NSRDB documentation.

@kandersolar
Copy link
Member Author

You can get TMY3 files from the NSRDB by passing names='tmy'

I think we need to distinguish TMY3 data from the TMY3 format. It is true that TMY data can be retrieved from the PSM3 API, but I believe it is returned in the SAM CSV format, not the TMY3 format.

Does a PSM3 file for a specific year follow the TMY3 format?

No, and furthermore (as far as I am aware), all PSM3 data (both single-year and TMY; both web viewer and API) is returned in the SAM CSV format.

[1] https://nsrdb.nrel.gov/about/tmy.html (scroll to "Format of TMY Data")
[2] https://nsrdb.nrel.gov/about/u-s-data.html (ctrl-F "Data Header")
[3] https://rredc.nrel.gov/solar/old_data/nsrdb/2005-2012/wfcsv.pdf

@cwhanse
Copy link
Member

cwhanse commented Dec 20, 2019

all PSM3 data (both single-year and TMY; both web viewer and API) is returned in the SAM CSV format.

Thanks; this clarifies that a new read_xxx function for this format would not duplicate pvlib.tmy.read_tmy3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants