diff --git a/docs/sphinx/source/whatsnew/v0.16.0.rst b/docs/sphinx/source/whatsnew/v0.16.0.rst index 67863eb9e5..6d62b9e1c6 100644 --- a/docs/sphinx/source/whatsnew/v0.16.0.rst +++ b/docs/sphinx/source/whatsnew/v0.16.0.rst @@ -2,10 +2,12 @@ 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`) * Remove empty ``poa_horizon`` key from the ``diffuse_components`` output of :py:func:`pvlib.irradiance.haydavies`. (:pull:`2788`) @@ -45,4 +47,4 @@ Maintenance Contributors ~~~~~~~~~~~~ - +* Carolina Crespo (:ghuser:`cbcrespo`) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 048d8aa461..98bd948286 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -1104,7 +1104,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. @@ -1113,7 +1113,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 @@ -1200,13 +1200,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 @@ -1346,7 +1345,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. @@ -1355,7 +1354,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 @@ -1420,13 +1419,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)