diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 2e1ed35cb5..30fffe8b60 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -587,7 +587,7 @@ def get_ground_diffuse(surface_tilt, ghi, albedo=.25, surface_type=None): return diffuse_irrad -def isotropic(surface_tilt, dhi): +def isotropic(surface_tilt, dhi, return_components=False): r''' Determine diffuse irradiance from the sky on a tilted surface using the isotropic sky model. @@ -613,10 +613,19 @@ def isotropic(surface_tilt, dhi): dhi : numeric Diffuse horizontal irradiance. [Wm⁻²] DHI must be >=0. + return_components : bool, default False + Flag used to decide whether to return the calculated diffuse components + or not. If `True`, the resulting dataframe will include three more + columns. If not, only ``poa_sky_diffuse`` column is returned. + Returns ------- - diffuse : numeric - The sky diffuse component of the solar radiation. + poa_sky_diffuse : DataFrame + The sky diffuse component of the solar radiation on a tilted + surface. Columns provided controlled by ``return_components`` argument. + If `False`, ``total`` is returned. + If `True`, ``isotropic``, ``circumsolar`` and ``horizon``. + Index is either inherited from dhi or default. References ---------- @@ -630,9 +639,30 @@ def isotropic(surface_tilt, dhi): Energy vol. 201. pp. 8-12 :doi:`10.1016/j.solener.2020.02.067` ''' - sky_diffuse = dhi * (1 + tools.cosd(surface_tilt)) * 0.5 - return sky_diffuse + poa_isotropic = dhi * (1 + tools.cosd(surface_tilt)) * 0.5 + + # if pd.DataFrame or Series handles first output as numerical + is_pandas = isinstance(dhi, (pd.DataFrame,pd.Series)) + if is_pandas: + poa_isotropic = poa_isotropic.values + + poa_sky_diffuse = poa_isotropic + + if not return_components: + poa_sky_diffuse = {'total': poa_sky_diffuse} + else: + poa_sky_diffuse = {'isotropic': poa_isotropic, + 'circumsolar': 0, + 'horizon': 0} + + poa_sky_diffuse = pd.DataFrame(poa_sky_diffuse) + + # if dhi was pandas, out_df inherits index + if is_pandas: + poa_sky_diffuse.index = dhi.index + + return poa_sky_diffuse def klucher(surface_tilt, surface_azimuth, dhi, ghi, solar_zenith, @@ -782,8 +812,9 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra, or supply ``projection_ratio``. return_components : bool, default `False` - If `False`, ``sky_diffuse`` is returned. - If `True`, ``diffuse_components`` is returned. + Flag used to decide whether to return the calculated diffuse components + or not. If `False`, ``sky_diffuse`` is returned. If `True`, + ``diffuse_components`` is returned. Returns --------