Skip to content

Commit a2916b3

Browse files
committed
Implements new strategy for output formatting.
1 parent 07ae57e commit a2916b3

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

pvlib/irradiance.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,12 +624,18 @@ def isotropic(surface_tilt, dhi, return_components=False):
624624
The sky diffuse component of the solar radiation on a tilted
625625
surface.
626626
627-
diffuse_components : OrderedDict (array input) or DataFrame (Series input)
627+
diffuse_components : dict (array input) or DataFrame (Series input)
628628
Keys/columns are:
629-
* sky_diffuse: Total sky diffuse
629+
* sky_diffuse (the sum of the components below)
630630
* isotropic
631631
* circumsolar
632632
* horizon
633+
* poa_sky_diffuse (the sum of the components below)
634+
* poa_isotropic
635+
* poa_circumsolar
636+
* poa_horizon
637+
The first four elements will be deprecated in v0.14.0 and are kept
638+
to avoit breaking changes.
633639
634640
References
635641
----------
@@ -646,14 +652,25 @@ def isotropic(surface_tilt, dhi, return_components=False):
646652
poa_sky_diffuse = dhi * (1 + tools.cosd(surface_tilt)) * 0.5
647653

648654
if return_components:
649-
diffuse_components = OrderedDict()
655+
diffuse_components = dict()
656+
657+
# original formatting (to be deprecated in v0.14.0)
658+
diffuse_components['sky_diffuse'] = poa_sky_diffuse # total
659+
diffuse_components['isotropic'] = poa_sky_diffuse
660+
diffuse_components['circumsolar'] = 0
661+
diffuse_components['horizon'] = 0
662+
663+
# new formatting
650664
diffuse_components['poa_sky_diffuse'] = poa_sky_diffuse
651-
652-
# Calculate the different components
653665
diffuse_components['poa_isotropic'] = poa_sky_diffuse
654666
diffuse_components['poa_circumsolar'] = 0
655667
diffuse_components['poa_horizon'] = 0
656668

669+
if isinstance(poa_sky_diffuse, pd.Series):
670+
# follows `perez` worfklow
671+
# shouldn't it include an argument `index=dhi.index`?
672+
diffuse_components = pd.DataFrame(diffuse_components)
673+
657674
return diffuse_components
658675
else:
659676
return poa_sky_diffuse

0 commit comments

Comments
 (0)