Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
20 changes: 8 additions & 12 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,

Returns
--------
numeric, OrderedDict, or DataFrame
numeric, Dict, or DataFrame
Return type controlled by ``return_components`` argument.
If `False`, ``sky_diffuse`` is returned.
If `True`, ``diffuse_components`` is returned.
Expand All @@ -792,13 +792,12 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
The sky diffuse component of the solar radiation on a tilted
surface. [Wm⁻²]

diffuse_components : OrderedDict (array input) or DataFrame (Series input)
diffuse_components : Dict (array input) or DataFrame (Series input)
Keys/columns are:
* poa_sky_diffuse: Total sky diffuse
* poa_isotropic
* poa_circumsolar
* poa_horizon (always zero, not accounted for by the
Hay-Davies model)
The model does not include a horizon brightening component.

Notes
------
Expand Down Expand Up @@ -856,14 +855,11 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
sky_diffuse = poa_isotropic + poa_circumsolar

if return_components:
diffuse_components = OrderedDict()
diffuse_components['poa_sky_diffuse'] = sky_diffuse

# Calculate the individual components
diffuse_components['poa_isotropic'] = poa_isotropic
diffuse_components['poa_circumsolar'] = poa_circumsolar
diffuse_components['poa_horizon'] = np.where(
np.isnan(diffuse_components['poa_isotropic']), np.nan, 0.)
diffuse_components = {
'poa_sky_diffuse': sky_diffuse,
'poa_isotropic': poa_isotropic,
'poa_circumsolar': poa_circumsolar
}

if isinstance(sky_diffuse, pd.Series):
diffuse_components = pd.DataFrame(diffuse_components)
Expand Down
6 changes: 2 additions & 4 deletions tests/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,11 @@ def test_haydavies(irrad_data, ephem_data, dni_et):


def test_haydavies_components(irrad_data, ephem_data, dni_et):
keys = ['poa_sky_diffuse', 'poa_isotropic', 'poa_circumsolar',
'poa_horizon']
keys = ['poa_sky_diffuse', 'poa_isotropic', 'poa_circumsolar']
expected = pd.DataFrame(np.array(
[[0, 27.1775, 102.9949, 33.1909],
[0, 27.1775, 30.1818, 27.9837],
[0, 0, 72.8130, 5.2071],
[0, 0, 0, 0]]).T,
[0, 0, 72.8130, 5.2071]]).T,
columns=keys,
index=irrad_data.index
)
Expand Down
Loading