10000 Calculate the effect of clouds ("cloud opacity factor") on spectral irradiance (spectrl2) by trondkr · Pull Request #1201 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Calculate the effect of clouds ("cloud opacity factor") on spectral irradiance (spectrl2) #1201

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10000
Prev Previous commit
Next Next commit
Updated to reccomendations from ci-stickler - again
  • Loading branch information
trondkr committed Mar 25, 2021
commit f11b407055e42cb47eef5f49374ae84c574b81c2
52 changes: 33 additions & 19 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,56 @@ def cloud_opacity_factor(irr_dif_clouds: np.ndarray,
irr_ghi_clouds: np.ndarray,
spectra: dict) -> (np.ndarray, np.ndarray):
Copy link
Member
@kandersolar kandersolar Apr 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we might add type hints eventually (see e.g. #1146 (comment)), I think for now better to keep the signature unannotated (and see below points about types anyway).

Edit: also we should think about the function name -- seems like the function name should have something to do with spectrum.

"""
Calculate the effect of "cloud opacity factor" on spectral irradiance under clear sky.

First we calculate the rho fraction based on campbell_norman irradiance
with clouds converted to POA irradiance. In the paper [1] these
values are obtained from observations. The equations used for calculating cloud opacity factor
to scale the clear sky spectral estimates using spectrl2. Results can be compared with sun calculator:
https://www2.pvlighthouse.com.au/calculators/solar%20spectrum%20calculator/solar%20spectrum%20calculator.aspx
Calculate the effect of "cloud opacity factor" on spectral
irradiance under clear sky.

First we calculate the rho fraction based on campbell_norman
irradiance with clouds converted to POA irradiance. In the
paper [1] these values are obtained from observations. The equations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
paper [1] these values are obtained from observations. The equations
paper [1]_ these values are obtained from observations. The equations

Adding an underscore like this turns the [1] into a clickable link to the reference text below

used for calculating cloud opacity factor to scale the clear sky
spectral estimates using spectrl2. Results can be compared
with sun calculator:
https://www2.pvlighthouse.com.au/calculators/solar%20
spectrum%20calculator/solar%20spectrum%20calculator.aspx

Parameters
----------
irr_dif_clouds:np.ndarray
Total diffuse irradiance (poa_diffuse) estimated using pvlib.irradiance.get_total_irradiance and
pvlib.irradiance.campbell_norman irradiance with clouds (transmittance)
Total diffuse irradiance (poa_diffuse) estimated using
`pvlib.irradiance.get_total_irradiance` and
`pvlib.irradiance.campbell_norman` irradiance with clouds
(transmittance)

irr_dir_clouds:np.ndarray
Total direct irradiance (poa_direct) estimated using pvlib.irradiance.get_total_irradiance and
pvlib.irradiance.campbell_norman irradiance with clouds (transmittance)
Total direct irradiance (poa_direct) estimated using
`pvlib.irradiance.get_total_irradiance` and
`pvlib.irradiance.campbell_norman` irradiance with
clouds (transmittance)

irr_ghi_clouds:np.ndarray
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these three parameters (according to [1]) are horizontal components, not in-plane components. It would be good to use the same parameter names as other functions (i.e. ghi and dhi), but I'm not sure pvlib has a name for direct horizontal irradiance -- perhaps dni_cos_zen or dni_projection?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also is np.ndarray a requirement? If scalars and pd.Series also work, then better to use the catch-all term numeric for the type.

Total direct irradiance (poa_global) estimated using pvlib.irradiance.get_total_irradiance and
pvlib.irradiance.campbell_norman irradiance with clouds (transmittance)
Total direct irradiance (poa_global) estimated
using `pvlib.irradiance.get_total_irradiance` and
`pvlib.irradiance.campbell_norman irradiance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is campbell-norman actually a requirement? [1] seems to assume the user has measured irradiance components, so maybe the text for these parameters should be as simple as this: https://github.com/pvlib/pvlib-python/blob/master/pvlib/irradiance.py#L823-L830

with clouds (transmittance)

spectra:np.ndarray
Spectral irradiance output from pvlib.spectrum.spectrl2 under clear-sky conditions
Spectral irradiance output from `pvlib.spectrum.spectrl2`
under clear-sky conditions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Similar to above, I'm not sure that this input needs a recommended source (note that [1] does not use spectrl2).
  2. I think the output of spectrl2 is actually a dict, not an ndarray. But would it make sense to take the spectral inputs as individual parameters (i.e. have the user pass in spectra['poa_sky_diffuse'][:, 0] etc instead of spectra)? Although pvlib often returns many outputs bundled together for convenience, inputs are usually kept separate.



Returns
-------
f_dir, f_diff spectral direct and diffuse irradiance scaled for cloudiness
f_dir, f_diff spectral direct and diffuse irradiance
scaled for cloudiness

References
----------
.. [1] Ref: Marco Ernst, Hendrik Holst, Matthias Winter, Pietro P. Altermatt,
SunCalculator: A program to calculate the angular and spectral distribution of direct and
diffuse solar radiation, Solar Energy Materials and Solar Cells, Volume 157, 2016,
Pages 913-922,
.. [1] Ref: Marco Ernst, Hendrik Holst, Matthias Winter,
Pietro P. Altermatt,
SunCalculator: A program to calculate the angular and spectral
distribution of direct and diffuse solar radiation, Solar Energy
Materials and Solar Cells, Volume 157, 2016,
Pages 913-922,
"""

rho = irr_dif_clouds / irr_ghi_clouds
Expand Down
0