You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The user guide definition of variables and symbols section (found here) does not currently have a standard definition for "spectral irradiance".
Describe the solution you'd like
Agree a standard definition for spectral irradiance as a variable
I think having a standard "root" variable that can have super/subscripts added to for function-specific requirements would be good, for example, something like ghi / ghi_extra, aoi / aoi_projection , or temp_air / temp_cell / temp_dew (the "root" here being ghi, aoi, and temp)
Suggestions: (updated from comments) si, (si_sun, si_ref...) spectral_irr e spectrum spectra spectral_irradiance _spectral (suffix, e.g. ghi_spectral)
e_sun and e_ref make sense in calc_spectral_mismatch_field() but, for a function that doesn't require the _sun/_ref specification, e alone might be ambiguous. I like spectral_irr as it's clear, but it is potentially too long? A shorter alternative is si.
Any irradiance quantity could have a corresponding spectral variable. Broadband irradiance (a single number) is an integration over wavelength of a vector of wavelength-dependent values. I think the plane and nature of the measurement matter. Perhaps "_spectral" is a modifier on ghi, dni, etc.
Maybe the lack of experience or the language barrier, but personally I find spectrum or spectra stand-alone reasonable. In the context of PV I doubt there is a spectrum other than of irradiance, and I've always (again, inexperience disclaimer) seen it as $W/m^2/[\mu , n]m$ so it's pretty normalized I think.
Perhaps "_spectral" is a modifier on ghi, dni, etc.
I don't dislike that possibility either, but I don't want to clog a name.
Regarding spectral_irrad, usually it is pythonic to write full words. So if you pursue that path, I recommend spectral_irradiance
Any irradiance quantity could have a corresponding spectral variable.
I think the plane and nature of the measurement matter. Perhaps "_spectral" is a modifier on ghi, dni, etc.
Good point, I hadn't considered it in that way. However, this formulation might not be as useful at this time since we do not currently have any functions that require the user to specify individual components of spectral irradiance. We do, however, have functions that operate on any spectral irradiance component as an input, so we still need some general variable to represent any spectral irradiance data (eg function 1 and 3 in the additional context of original post)
Regarding spectral_irrad, usually it is pythonic to write full words. So if you pursue that path, I recommend spectral_irradiance
Fair enough. Feels good as a function argument for the user but a bit long for writing out calculations (but maybe I am just lazy when I write code)
si / spectral_irradiance remove the singular/plural aspect, unlike spectrum/spectra, but I guess that's not a major issue. I think I could be on board with spectra if not spectral_irr or si
+1 to spectrum for a general variable (not specific to plane or aperture of the measurement). Spectrum "is the intensity of light as it varies with wavelength or frequency." (Brittannica). So a value of spectrum is a vector of ordered pairs (wavelength/frequency, intensity), or a function F intensity=F(wavelength) spectra would be more than one "value". We should give some thought as to preferred units, and how to represent the pair of vectors (or vector of pairs) of values.
I still favor adding ghi_spectral to the dictionary but after a need arises.
+1 to spectrum for a general variable (not specific to plane or aperture of the measurement)
Okay based on the discussion so far this sounds reasonable.
One question: could there be any conflict due to the package being called spectrum as well?
I still favor adding ghi_spectral to the dictionary but after a need arises.
Agreed, I do too (you are ahead of your time Cliff!)
We should give some thought as to preferred units, and how to represent the pair of vectors (or vector of pairs) of values.
Current functions in pvlib.spectrum handle wavelength in nm, so I lean towards Wm^-2nm^-1 as the units of spectral irradiance. I think this is common outside of pvlib too but by no means universal, e.g. (IIRC) NSRDB FARMS-NIT simulations express wavelength in um.
If I understood your point about representation correctly, I think it would be okay to stick with the current pvlib convention for now (wavelength index for a single pandas.Series spectrum, wavelength column headers for multiple spectra in a pandas.DataFrame)
One question: could there be any conflict due to the package being called spectrum as well?
Since I now see spectrum as a variable does not work with from pvlib import spectrum, which is used in all pvlib spectrum tests (and I for one find very convenient to use in my own work) I am not in favour of spectrum as a variable. I think spectra, si, or even spectral_irr / spectral_irradiance would be better.
I have left spectrum in #2140 (but not the tests) as that currently has the most votes but perhaps this issue could be left open for a bit longer to see if anyone else has any thoughts before concluding/closing and adding something to the user guide variables page.
The different input parameter names in spectrum.calc_spectral_mismatch_field seem harmless to me. I'm more concerned that the spectrum.spectrl2 output parameter is named spectra. This parameter is a dict of arrays. A user may expect that the output of spectrl2 (clear-sky spectral irradiance) should "fit" into the input of e.g. average_photon_energy.
I am now stuck in a loop of wanting to be helpful but not be unnecessary
I'm more concerned that the spectrum.spectrl2 output parameter is named spectra. This parameter is a dict of arrays. A user may expect that the output of spectrl2 (clear-sky spectral irradiance) should "fit" into the input of e.g. average_photon_energy.
Ah good observation, I had not noticed that. Since the input for both spectrum.calc_spectral_mismatch_field and spectrum.average_photon_energy is pd.Series or pd.DataFrame, rather than changing the inputs there would the appropriate remedy be to modify the output of spectrum.spectrl2 to be a dataframe of spectra? I'd be happy to work on this. It would be good to have cross-compatibility, especially since now the variable (for at least two) is the same.
modify the output of spectrum.spectrl2 to be a dataframe of spectra?
I don't think we want to do that. There are multiple arrays in the output of spectrl2, for the different irradiance quantities, and each array can be a 2D array, with the columns corresponding to timestamps. Bundling the different irradiance quantities into a single Dataframe makes that Dataframe 3D, and that just feels awkward.
The simplest change would be to remove the word spectra from the docstring of spectrl2, i.e.,
I don't think we want to do that. There are multiple arrays in the output of spectrl2, for the different irradiance quantities, and each array can be a 2D array, with the columns corresponding to timestamps. Bundling the different irradiance quantities into a single Dataframe makes that Dataframe 3D, and that just feels awkward.
Ah of course, you are right
The simplest change would be to remove the word spectra from the docstring of spectrl2
Activity
cwhanse commentedon Aug 1, 2024
Any irradiance quantity could have a corresponding spectral variable. Broadband irradiance (a single number) is an integration over wavelength of a vector of wavelength-dependent values. I think the plane and nature of the measurement matter. Perhaps "_spectral" is a modifier on
ghi,dni, etc.echedey-ls commentedon Aug 1, 2024
Maybe the lack of experience or the language barrier, but personally I find$W/m^2/[\mu , n]m$ so it's pretty normalized I think.
spectrumorspectrastand-alone reasonable. In the context of PV I doubt there is a spectrum other than of irradiance, and I've always (again, inexperience disclaimer) seen it asI don't dislike that possibility either, but I don't want to clog a name.
Regarding
spectral_irrad, usually it is pythonic to write full words. So if you pursue that path, I recommendspectral_irradianceRDaxini commentedon Aug 2, 2024
Good point, I hadn't considered it in that way. However, this formulation might not be as useful at this time since we do not currently have any functions that require the user to specify individual components of spectral irradiance. We do, however, have functions that operate on any spectral irradiance component as an input, so we still need some general variable to represent any spectral irradiance data (eg function 1 and 3 in the additional context of original post)
Fair enough. Feels good as a function argument for the user but a bit long for writing out calculations (but maybe I am just lazy when I write code)
si/spectral_irradianceremove the singular/plural aspect, unlikespectrum/spectra, but I guess that's not a major issue. I think I could be on board withspectraif notspectral_irrorsicwhanse commentedon Aug 2, 2024
+1 to
spectrumfor a general variable (not specific to plane or aperture of the measurement). Spectrum "is the intensity of light as it varies with wavelength or frequency." (Brittannica). So a value ofspectrumis a vector of ordered pairs (wavelength/frequency, intensity), or a function F intensity=F(wavelength)spectrawould be more than one "value". We should give some thought as to preferred units, and how to represent the pair of vectors (or vector of pairs) of values.I still favor adding
ghi_spectralto the dictionary but after a need arises.RDaxini commentedon Aug 2, 2024
Okay based on the discussion so far this sounds reasonable.
One question: could there be any conflict due to the package being called
spectrumas well?Agreed, I do too (you are ahead of your time Cliff!)
Current functions in
pvlib.spectrumhandle wavelength in nm, so I lean towards Wm^-2nm^-1 as the units of spectral irradiance. I think this is common outside of pvlib too but by no means universal, e.g. (IIRC) NSRDB FARMS-NIT simulations express wavelength in um.If I understood your point about representation correctly, I think it would be okay to stick with the current pvlib convention for now (wavelength index for a single
pandas.Seriesspectrum, wavelength column headers for multiple spectra in apandas.DataFrame)RDaxini commentedon Aug 5, 2024
@kandersolar you might be interested in this discussion
RDaxini commentedon Aug 13, 2024
Since I now see
spectrumas a variable does not work withfrom pvlib import spectrum, which is used in all pvlib spectrum tests (and I for one find very convenient to use in my own work) I am not in favour ofspectrumas a variable. I thinkspectra,si, or evenspectral_irr/spectral_irradiancewould be better.I have left
spectrumin #2140 (but not the tests) as that currently has the most votes but perhaps this issue could be left open for a bit longer to see if anyone else has any thoughts before concluding/closing and adding something to the user guide variables page.cwhanse commentedon Aug 13, 2024
Since the function is designed to work with spectra (multiple spectrum) as input, I yield,
spectracan be the variable.Update irradiance.py
Update test_irradiance.py
Create function to calculate average photon energy (#2140)
RDaxini commentedon Aug 15, 2024
Thoughts on the second and third bullet points in the original post?
Is a user guide variable entry necessary, and should existing functions/tests be revised to all use the same
spectra(Wm⁻²nm⁻¹) variable?cwhanse commentedon Aug 15, 2024
It is helpful but not necessary
The different input parameter names in
spectrum.calc_spectral_mismatch_fieldseem harmless to me. I'm more concerned that thespectrum.spectrl2output parameter is namedspectra. This parameter is adictof arrays. A user may expect that the output ofspectrl2(clear-sky spectral irradiance) should "fit" into the input of e.g.average_photon_energy.RDaxini commentedon Aug 15, 2024
I am now stuck in a loop of wanting to be helpful but not be unnecessary
Ah good observation, I had not noticed that. Since the input for both
spectrum.calc_spectral_mismatch_fieldandspectrum.average_photon_energyispd.Seriesorpd.DataFrame, rather than changing the inputs there would the appropriate remedy be to modify the output ofspectrum.spectrl2to be a dataframe of spectra? I'd be happy to work on this. It would be good to have cross-compatibility, especially since now the variable (for at least two) is the same.cwhanse commentedon Aug 15, 2024
I don't think we want to do that. There are multiple arrays in the output of
spectrl2, for the different irradiance quantities, and each array can be a 2D array, with the columns corresponding to timestamps. Bundling the different irradiance quantities into a single Dataframe makes that Dataframe 3D, and that just feels awkward.The simplest change would be to remove the word
spectrafrom the docstring ofspectrl2, i.e.,RDaxini commentedon Aug 15, 2024
Ah of course, you are right
#2168
I will have a think about modifying / how to modify
average_photon_energyto accept more input types at a later date.