Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
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
1 change: 1 addition & 0 deletions docs/sphinx/source/reference/irradiance/decomposition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ DNI estimation models
irradiance.boland
irradiance.campbell_norman
irradiance.gti_dirint
irradiance.pvl_louche
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.9.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Deprecations

Enhancements
~~~~~~~~~~~~

* Lakshya Garg (:ghuser:`Lakshyadevelops` :pull:`1705`)

Bug fixes
~~~~~~~~~
Expand Down
68 changes: 68 additions & 0 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3117,3 +3117,71 @@ def complete_irradiance(solar_zenith,
'dhi': dhi,
'dni': dni})
return component_sum_df


def pvl_louche(ghi, solar_zenith, datetime_or_doy):
"""
Determine DNI and GHI from GHI using Louche model.

Parameters
----------
ghi : Series
Global horizontal irradiance. [W/m^2]

solar_zenith : Series
True (not refraction-corrected) zenith angles in decimal
degrees. Angles must be >=0 and <=90.

datetime_or_doy : numeric, pandas.DatetimeIndex
Day of year or array of days of year e.g.
pd.DatetimeIndex.dayofyear, or pd.DatetimeIndex.

Returns
-------
data: OrderedDict or DataFrame
Contains the following keys/columns:

* ``dni``: the modeled direct normal irradiance in W/m^2.
* ``dhi``: the modeled diffuse horizontal irradiance in
W/m^2.
* ``kt``: Ratio of global to extraterrestrial irradiance
on a horizontal plane.
Notes
-----
solar_zenith angles should be between 0 and 90 degrees else NaN will be
returned. doy should be between 1 and 366 else NaN will be returned.

References
-------
.. [1] Louche A, Notton G, Poggi P, Simmonnot G. Correlations for direct
normal and global horizontal irradiation on French Mediterranean site.
Solar Energy 1991;46:261-6

"""
bool = np.logical_or(solar_zenith > 90, solar_zenith < 0)
solar_zenith = np.where(bool, np.NaN, solar_zenith)

if np.isscalar(datetime_or_doy):
bool = (np.any(datetime_or_doy > 366 or datetime_or_doy < 1, axis=0))
datetime_or_doy = np.where(bool, np.NaN, datetime_or_doy)

# this is the I0 calculation from the reference
# SSC uses solar constant = 1366.1
I0 = get_extra_radiation(datetime_or_doy)

Kt = clearness_index(ghi, solar_zenith, I0)

kb = -10.627*Kt**5 + 15.307*Kt**4 - 5.205 * \
Kt**3 + 0.994*Kt**2 - 0.059*Kt + 0.002
dni = kb*I0
dhi = ghi - dni*tools.cosd(solar_zenith)

data = OrderedDict()
data['dni'] = dni
data['dhi'] = dhi
data['kt'] = Kt

if isinstance(datetime_or_doy, pd.DatetimeIndex):
data = pd.DataFrame(data, index=datetime_or_doy)

return data
27 changes: 25 additions & 2 deletions pvlib/tests/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def test_haydavies_components(irrad_data, ephem_data, dni_et):
assert_allclose(result['horizon'], expected['horizon'][-1], atol=1e-4)
assert isinstance(result, dict)


def test_reindl(irrad_data, ephem_data, dni_et):
result = irradiance.reindl(
40, 180, irrad_data['dhi'], irrad_data['dni'], irrad_data['ghi'],
Expand Down Expand Up @@ -903,8 +904,12 @@ def test_dirindex(times):
assert np.allclose(out, expected_out, rtol=tolerance, atol=0,
equal_nan=True)
tol_dirint = 0.2
assert np.allclose(out.values, dirint_close_values, rtol=tol_dirint, atol=0,
equal_nan=True)
assert np.allclose(
out.values,
dirint_close_values,
rtol=tol_dirint,
atol=0,
equal_nan=True)


def test_dirindex_min_cos_zenith_max_zenith():
Expand Down Expand Up @@ -1203,3 +1208,21 @@ def test_complete_irradiance():
dhi=None,
dni=i.dni,
dni_clear=clearsky.dni)


def test_pvl_louche():

index = pd.DatetimeIndex(['20190101']*3 + ['20190620']*2)
ghi = pd.Series([0, 50, 1000, 1000, 1000], index=index)
zenith = pd.Series([91, 85, 10, 10, -2], index=index)
expected = pd.DataFrame(np.array(
[[np.NaN, np.NaN, np.NaN],
[130.089669, 38.661938, 0.405724],
[828.498650, 184.088106, 0.718133],
[887.407348, 126.074364, 0.768214],
[np.NaN, np.NaN, np.NaN]]),
columns=['dni', 'dhi', 'kt'], index=index)

out = irradiance.pvl_louche(ghi, zenith, index)

assert assert_frame_equal(out, expected) is None