-
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 N. Martin & J. M. Ruiz spectral response mismatch modifiers model #1658
Add N. Martin & J. M. Ruiz spectral response mismatch modifiers model #1658
Conversation
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'm a bit puzzled by the omission of the leading term S_{ef Gbar(lambda))
. As coded, this function returns the ratio S_{ef} / S_{ef Gbar(lambda))
. Is this the appropriate factor to apply to the broadband irradiance?
Yes, you are right, the func is returning a ratio. In fact, it returns 3 of them, each one for a different POA component; this mismatch is for all the spectrum (with respect to the standard spectrum) response - it is independent from the wavelength. |
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 for this excellent PR @echedey-ls! Well done all around -- code, docs, tests, etc. I plan to take a closer look later, but here are some comments until then.
Waiting for milestone assignment
I've assigned this to 0.9.5, so that's the relevant what's new file. You might need to update your branch with pvlib:main
for it to exist.
Hope submitted notebook spectral_mismatch_modifiers.ipynb and tests clarify the use.
I think it is better to make a new gallery example here instead of a new notebook. We have talked about getting rid of the notebooks entirely. Also, a comment on the notebook code: I think the use of pvlib.irradiance.poa_components
in cell 21 is not quite correct, since it is passing a poa_direct
to dni
, so the AOI projection will be incorrectly applied again.
I am also a bit puzzled. I think, if this paper describes a factor suitable for multiplying with broadband irradiance, it must be this ratio. But its formulation, especially the integration limit in the denominator of Eq 1, seems strange to me. Need to chew a bit more on what this equation really represents. |
Thank you very much @kanderso-nrel ! I didn't know many of the things you spotted.
|
Yes, there was a mistake in some other PR that created this duplication. We will fix that later so don't worry about it in this PR. For this PR it's fine to just add a new entry to
You can mimic a plot from the reference if you like. It would also be fine to just translate the notebook to this format. Basically the examples just need to show how to do something useful; it's up to you to decide what "useful" means ;) We do try to keep them relatively short, so if you want to show how to obtain custom model parameters, it may be better to create a new example file. |
79b8a7e
to
bebee82
Compare
pvlib/spectrum/mismatch.py
Outdated
airmass_absolute : numeric | ||
Absolute airmass. Give attention to algorithm used (``kasten1966`` is | ||
recommended for default parameters of ``monosi``, ``polysi`` and | ||
``asi``, see [1]_). |
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 the model requires a specific air mass calculation, then perhaps it is better to have zenith angle as input.
This comment applies to a number of other existing pvlib functions as well, actually.
* Upgrade docstring
Now, even if not given parameters for a irradiation, a result is yield with value None.
commit 8f3b965 Author: echedey-ls <80125792+echedey-ls@users.noreply.github.com> Date: Fri Feb 3 19:25:42 2023 +0100 Update mismatch_modifiers.ipynb commit 3486069 Author: echedey-ls <80125792+echedey-ls@users.noreply.github.com> Date: Thu Feb 2 23:28:31 2023 +0100 Create mismatch_modifiers.ipynb commit 0747a43 Author: echedey-ls <80125792+echedey-ls@users.noreply.github.com> Date: Fri Jan 27 13:05:49 2023 +0100 I did fck it with the tmy_data.shift, never again commit 0e600b2 Author: echedey-ls <80125792+echedey-ls@users.noreply.github.com> Date: Tue Dec 6 17:12:04 2022 +0100 Example draft
Result new keys are ('poa_direct', 'poa_sky_diffuse', 'poa_ground_diffuse') For irradiances obtained thru pvlib.irradiance.poa_components
* doi backticks * cell_type --> module_type * spectrum.martin_ruiz_spectral_modifer --> spectrum.martin_ruiz * change hastattr __iter__ to np.isscalar * behaviour: providing module_type and model_parameters raises an error instead of a warning
* update tutorial
fbfc527
to
30c66b9
Compare
I've added the sphinx example. I think this is the minimum needed to merge. @kanderso-nrel thank you very much for your guidance.
Thanks for the input @adriesse . |
in coordination with pvlib#1658, drop "spectral_correction" from the new function names
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-Authored-By: Cliff Hansen <5393711+cwhanse@users.noreply.github.com>
# Data to run tests of spectrum.martin_ruiz | ||
kwargs = { | ||
'clearness_index': [0.56, 0.612, 0.664, 0.716, 0.768, 0.82], | ||
'airmass_absolute': [2, 1.8, 1.6, 1.4, 1.2, 1], |
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.
Have you checked the full range of possible kt and am values to see if the model behaves ok?
[1.024, -.222, 920e-5, .840, -.728, -.0183, .989, -.219, .0179], | ||
]) | ||
|
||
# Argument validation and choose components and model parameters |
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.
Most functions in pvlib have less friendly input checking, which may be good or bad. You might just see what happens in each case without these checks and see whether the message python produces upon failure is comprehensible. In that case you may not need some of these custom messages.
Other than that I would prefer two nested if/else structures over the four combined conditions.
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 have tried what you say, but I don't get nice results - when both are provided, one of the inputs is ignored without telling so; and when neither of them are, _params is not defined
is raised, which could be a good error message.
In my humble opinion, being verbatim in the interface is not a problem, and is better than seeing a variable you did not write is not being defined. It will save time for the user, essentially.
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.
numpy and scipy use the None, None default pattern, where if both are None the function fails, so I think we're among good company.
0. We've found that MR model does not match other spectral mismatch models as expected - this commit shows that, in case some insight can be given 1. Uses atmosphere.first_solar_spectral_correction--> to be changed before merging 2. Compares with: * pvsystem.sapm_spectral_loss * atmosphere.first_solar_spectral_correction 3. Docs are already up-to-date with the first_solar renaming
Addressed in this commit: * docstring: use "must" * TypeError --> ValueError (func & tests updated) * Make use of a local TMY data file * Show per component maths behind modifier application Co-Authored-By: Anton Driesse <9001027+adriesse@users.noreply.github.com>
I had a meeting with the profs I mentioned some time ago.
I started learning about PV almost by myself last summer as these profs asked me to, in order to use my knowledge in Python to try to make this addition possible. So please, bear with me for some of the scientific inconsistencies I might have done. The researchers at Instituto de Energía Solar of UPM, the profs, are trying to explain the difference compared to the other models and come to conclusions in following days/weeks. You will hear from me if I'm told anything. Whether this PR should close, change to draft status or can be merged, is a decision I will leave up to you. Edit: for the example I use func |
The comparison in the example does look a bit odd. Anyway, don't give up. This would be an interesting addition to pvlib if the wrinkles can be sorted out. If problems remain with the model, then identifying those is scientific progress too! |
I had a little conversation with the researchers and I was told the model won't work for this purpose, so I'm closing this issue. |
* migrate spectral modifiers to pvlib.spectrum * stickler * get fslr correction to 100% coverage * stickler! * change new names to sapm and first_solar in coordination with #1658, drop "spectral_correction" from the new function names * improve whatsnew * more renaming * rename to spectral_factor_X * tweaks * v0.9.5 -> v0.9.6 * 0.9.5 whatsnew cleanup * 0.9.6 -> 0.10.0 in deprecation warnings Co-Authored-By: Cliff Hansen <5393711+cwhanse@users.noreply.github.com> --------- Co-authored-by: Cliff Hansen <5393711+cwhanse@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.Hi! As promised, I did a bigger PR.
This proposal adds a new function,
pvlib.spectrum.martin_ruiz_spectral_modifier
, with the spectral mismatch model proposed in this paper.Details about the function can be read in the docstring, but to sum it up, it takes the type of material (m-Si, p-Si or a-Si), the absolute airmass and the clearness index to compute a small mismatch for each component's POA irradiance.
This PR has been done with the help of researchers at Instituto de Energía Solar, at Universidad Politécnica de Madrid.
There are a bit of things I'm unsure about, so I'd like to hear your opinion on them:
model_parameters
(this is almost only to be used if anyone computes its model params)spectral_mismatch_modifiers.ipynb
and tests clarify the use.Feel free to make comments on everything. English is not my mother tongue, so an in depth inspection of code comments and docs is also welcome.
Idk if I should add something else here, ask whatever you need, I will address it.
Doc links
Function docstring
Gallery example