Closed
Description
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_psm3into its own functioniotools.read_psm3, leavingget_psm3as a networking wrapper around the PSM3 API that then callsread_psm3on the API response. - Modify
get_psm3to 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.
Reacted by Mark Mikofski
Metadata
Metadata
Assignees
Labels
No labels
Activity
cwhanse commentedon 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_psm3function would be of value.kandersolar commentedon Dec 19, 2019
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_psm3is 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_csvor similar instead ofread_psm3.cwhanse commentedon 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_samseems 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 commentedon Dec 19, 2019
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.
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 commentedon Dec 20, 2019
Thanks; this clarifies that a new
read_xxxfunction for this format would not duplicatepvlib.tmy.read_tmy3.