diff --git a/docs/sphinx/source/whatsnew/v0.16.0.rst b/docs/sphinx/source/whatsnew/v0.16.0.rst new file mode 100644 index 0000000000..90523eaa84 --- /dev/null +++ b/docs/sphinx/source/whatsnew/v0.16.0.rst @@ -0,0 +1,48 @@ +.. _whatsnew_0_16_0: + + +v0.16.0 +------------------------------------- + +Breaking Changes +~~~~~~~~~~~~~~~~ +* Change output type of :py:func:`pvlib.irradiance.perez` and + :py:func:`pvlib.irradiance.perez_driesse` from OrderedDict to dict when + ``return_components=True`` to be consistent with other models. + (:pull:`2789`) + +Deprecations +~~~~~~~~~~~~ + + +Bug fixes +~~~~~~~~~ + + +Enhancements +~~~~~~~~~~~~ + + +Documentation +~~~~~~~~~~~~~ + + +Testing +~~~~~~~ + + +Benchmarking +~~~~~~~~~~~~ + + +Requirements +~~~~~~~~~~~~ + + +Maintenance +~~~~~~~~~~~ + + +Contributors +~~~~~~~~~~~~ +* Carolina Crespo (:ghuser:`cbcrespo`) \ No newline at end of file diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 6c39303b99..3d98c92e65 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1109,7 +1109,7 @@ def perez(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 ``return_components=False``, `sky_diffuse` is returned. If ``return_components=True``, `diffuse_components` is returned. @@ -1118,7 +1118,7 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra, The sky diffuse component of the solar radiation on a tilted surface. - 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 @@ -1205,13 +1205,12 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra, sky_diffuse = np.where(np.isnan(airmass), 0, sky_diffuse) if return_components: - diffuse_components = OrderedDict() - diffuse_components['poa_sky_diffuse'] = sky_diffuse - - # Calculate the different components - diffuse_components['poa_isotropic'] = dhi * term1 - diffuse_components['poa_circumsolar'] = dhi * term2 - diffuse_components['poa_horizon'] = dhi * term3 + diffuse_components = { + 'poa_sky_diffuse': sky_diffuse, + 'poa_isotropic': dhi * term1, + 'poa_circumsolar': dhi * term2, + 'poa_horizon': dhi * term3 + } # Set values of components to 0 when sky_diffuse is 0 mask = sky_diffuse == 0 @@ -1351,7 +1350,7 @@ def perez_driesse(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 ``return_components=False``, `sky_diffuse` is returned. If ``return_components=True``, `diffuse_components` is returned. @@ -1360,7 +1359,7 @@ def perez_driesse(surface_tilt, surface_azimuth, dhi, dni, dni_extra, The sky diffuse component of the solar radiation on a tilted surface. - 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 @@ -1425,13 +1424,12 @@ def perez_driesse(surface_tilt, surface_azimuth, dhi, dni, dni_extra, sky_diffuse = np.maximum(dhi * (term1 + term2 + term3), 0) if return_components: - diffuse_components = OrderedDict() - diffuse_components['poa_sky_diffuse'] = sky_diffuse - - # Calculate the different components - diffuse_components['poa_isotropic'] = dhi * term1 - diffuse_components['poa_circumsolar'] = dhi * term2 - diffuse_components['poa_horizon'] = dhi * term3 + diffuse_components = { + 'poa_sky_diffuse': sky_diffuse, + 'poa_isotropic': dhi * term1, + 'poa_circumsolar': dhi * term2, + 'poa_horizon': dhi * term3 + } if isinstance(sky_diffuse, pd.Series): diffuse_components = pd.DataFrame(diffuse_components)