-
Notifications
You must be signed in to change notification settings - Fork 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 extraterrestrial and direct spectra of ASTM G173-03 standard spectrum (AM1.5) #2039
Add extraterrestrial and direct spectra of ASTM G173-03 standard spectrum (AM1.5) #2039
Conversation
Implement, test and document spectrum.get_ASTM_G173 Modify spectrum.get_am15g as a wrapper of the latter Delete old file Implementation note: I've used pandas interpolate instead of scipy's because the latter is considered legacy. See docs at https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html
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.
This is looking great @echedey-ls! Thanks for making it easily expandable in the future :)
Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Kevin Anderson <[email protected]>
https: //stackoverflow.com/questions/65255622/anydf-isna-returns-true-when-no-nans-are-present Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Kevin Anderson <[email protected]>
Thanks for the in-depth review @kandersolar !! Ready for another one 👀 Should I open an issue with the deprecation, so it's tasked in a milestone? Docs
|
Co-Authored-By: Kevin Anderson <[email protected]>
@echedey-ls Even with the new function staying in the
instead of
The proposed alternative function name allows future extension to providing non-standards-derived spectra collections without another function name issue/change, and it also reflects that in general a dataframe of (plural) spectra is returned. Removing the interpolation option keeps a separation of concerns between data provision and data transformation in the lowest level functions. That said, I realize that this creates the need to add an additional interpolation function to fully replace the existing functionality in the deprecated This is an example usage pattern (with subsequent interpolation not shown): ASTM_G173_03_SPECTRA = get_spectra_collection(collection="astm_g173_03") # pandas.DataFrame
ASTM_G173_03_SPECTRA_EXTRA = ASTM_G173_03_SPECTRA["extraterrestrial"] # pandas.Series
ASTM_G173_03_SPECTRA_GLOBAL = ASTM_G173_03_SPECTRA["global"] # pandas.Series
ASTM_G173_03_SPECTRA_DIRECT = ASTM_G173_03_SPECTRA["direct"] # pandas.Series |
@markcampanelli can you give an example of a spectra collection this function could be expanded to include in the future? I'm having trouble thinking of anything that would make sense to provide alongside standards-derived spectra except for other standards-derived spectra. If we're talking about particular datasets (rather than static reference spectra) like the spectra measured at SNL (Data Hub link) or the Spectral On Demand service, I think we should be talking about one or more separate functions, likely in
In my view,
Good point! How about |
@kandersolar One case would be a collection of test-problem spectra, but I suppose those types of collections could/should live in a different data provider, be it a different method in I suppose I view
(I don't know |
Thanks @markcampanelli for your feedback, I will change the function name 😃 Regarding the proposed signature, although I prefer reading code with the parameter names, I think it's unnecessary for this function. With just two parameters, one that accepts numbers and other that accepts strings, I doubt we will have any trouble reading someone else's code. |
Co-Authored-By: Kevin Anderson <[email protected]> Co-Authored-By: Mark Campanelli <[email protected]>
@echedey-ls So, are you sure you want to include the
|
@markcampanelli sorry for not being clear enough. I'm usually akin to use keyword-only parameters, but I deem using them here unnecessary. One is a list of numbers that will rarely be provided as a list of magic numbers (i.e., it will in a reasonably-named variable) and the other, a mostly-self-explanatory string. |
@echedey-ls I think the disconnect here is that in my view the To be entirely fair, my preference for named-only function arguments (with or without default values) can cause issues when injecting functions into, say, |
That's a fair point. Anyone wanna weigh in their opinion too? Rn I'm unsure of what to do. |
@echedey-ls I am not trying to request changes at this point, I'm just trying to make the reasons behind my inquiries more clear. It sounds like the maintainers are ok with this PR, and I do not intend to delay you further as it provides significant value :). Having worked on several large Python projects in production, I have seen how small complexities turn into weird unforseen headaches later. I would recommend these commentaries: Also, there are counter arguments where complexity is justified (it's by no means black and white), such as "the lego fallacy" (a pile of legos is not always helpful to dump on a user trying to solve a problem), and locality of behavior. |
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 minor test comment, otherwise LGTM!
Barring any requests for changes, I'll merge this PR next week.
Co-Authored-By: Kevin Anderson <[email protected]>
…ey-ls/pvlib-python into full-read-of-astm-g-173-03
Co-Authored-By: Kevin Anderson <[email protected]>
Co-Authored-By: Mark Campanelli <[email protected]>
@markcampanelli my apologies for being so stubborn. I think I was confused (I don't remember exactly what came to my mind when I engaged in that conversation earlier). I've re-read that conversation and you are completely right, that keyword only asterisk does not serve any purpose. I've removed it. Thanks for bearing with me. |
@echedey-ls No need to for you to apologize or feel silly. Like I said, I think Python would have been better off just making all function/methods arguments keyword only. I find the resulting code considerably easier to read because it becomes self-documenting, and it’s harder to break an interface if/when it grows, inc. if a default value is added. Going the other way, I appreciate you bearing with my raving on about complexity and concerns about API consistency 🙂. |
Thanks @echedey-ls for the PR and @markcampanelli for the reviews! |
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.Adds the remaining extraterrestrial and direct spectra of the AM1.5 standard spectrum bundled with pvlib.
Currently, only get_am15g allows retrieving of the global spectra.
The proposed approach adds a new function
pvlib.spectrum.get_ASTM_G173
which returns apandas.DataFrame
. API designed similarly toget_am15g
, althoughnumpy.interp
has been used instead of thescipy
counterpart since the latter is deprecated.I've changed
get_am15g
to only be a wrapper of this new addition (so we can save the space by removing its data source file).Feel free to point any suggestions, tips or discuss the solutions.
Docs