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
2 changes: 1 addition & 1 deletion docs/sphinx/source/contributing/style_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ allows for multiple input types to work for many parameters. pvlib uses
the following generic descriptors as short-hand to indicate which
specific types may be used:

* dict-like : dict, OrderedDict, pd.Series
* dict-like : dict, pd.Series
* numeric : scalar, np.array, pd.Series. Typically int or float dtype.
* array-like : np.array, pd.Series. Typically int or float dtype.

Expand Down
6 changes: 3 additions & 3 deletions docs/sphinx/source/user_guide/modeling_topics/clearsky.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ A clear sky time series using only basic pvlib functions.


The input data types determine the returned output type. Array input
results in an OrderedDict of array output, and Series input results in a
results in an dict of array output, and Series input results in a
DataFrame output. The keys are 'ghi', 'dni', and 'dhi'.

Grid with a clear sky irradiance for a few turbidity values.
Expand Down Expand Up @@ -437,7 +437,7 @@ A clear sky time series using only basic pvlib functions.
In [1]: plt.close();

The input data types determine the returned output type. Array input
results in an OrderedDict of array output, and Series input results in a
results in an dict of array output, and Series input results in a
DataFrame output. The keys are 'ghi', 'dni', and 'dhi'.

Irradiance as a function of solar elevation.
Expand Down Expand Up @@ -518,7 +518,7 @@ Contour plots of irradiance as a function of both PW and AOD.

In [1]: aod700, precipitable_water = np.meshgrid(aod700, precipitable_water)

# inputs are arrays, so solis is an OrderedDict
# inputs are arrays, so solis is an dict
In [1]: solis = clearsky.simplified_solis(apparent_elevation, aod700,
...: precipitable_water, pressure,
...: dni_extra)
Expand Down
19 changes: 19 additions & 0 deletions docs/sphinx/source/whatsnew/v0.16.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ Breaking Changes
and :py:func:`pvlib.iam.schlick_diffuse` from tuple to ``dict``, to be
consistent with :py:func:`pvlib.iam.marion_diffuse`. (:issue:`2837`,
:pull:`2842`)
* All ``OrderedDict`` outputs are now ``dict``. The following functions
are affected (:issue:`1684`, :pull:`2856`):

* :py:func:`~pvlib.clearsky.ineichen`
* :py:func:`~pvlib.clearsky.simplified_solis`
* :py:func:`~pvlib.clearsky.detect_clearsky`
* :py:func:`~pvlib.clearsky.bird`
* :py:func:`~pvlib.irradiance.disc`
* :py:func:`~pvlib.irradiance.gti_dirint`
* :py:func:`~pvlib.irradiance.erbs`
* :py:func:`~pvlib.irradiance.erbs_driesse`
* :py:func:`~pvlib.irradiance.orgill_hollands`
* :py:func:`~pvlib.irradiance.boland`
* :py:func:`~pvlib.irradiance.campbell_norman`
* :py:func:`~pvlib.irradiance.louche`
* :py:func:`~pvlib.pvsystem.sapm`
* :py:func:`~pvlib.pvsystem.max_power_point`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the list of functions touched in this PR. I will combine it with similar whatsnew entries in the eventual release finalization PR.




Deprecations
~~~~~~~~~~~~
Expand Down
23 changes: 11 additions & 12 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import os
from collections import OrderedDict
import calendar

import numpy as np
Expand Down Expand Up @@ -56,7 +55,7 @@ def ineichen(apparent_zenith, airmass_absolute, linke_turbidity,

Returns
-------
clearsky : DataFrame (if Series input) or OrderedDict of arrays
clearsky : DataFrame (if Series input) or dict of arrays
Contains the columns/keys ``'dhi', 'dni', 'ghi'``, with the same
unit as the input parameter ``dni_extra``.

Expand Down Expand Up @@ -138,7 +137,7 @@ def ineichen(apparent_zenith, airmass_absolute, linke_turbidity,

dhi = ghi - dni*cos_zenith

irrads = OrderedDict()
irrads = {}
irrads['ghi'] = ghi
irrads['dni'] = dni
irrads['dhi'] = dhi
Expand Down Expand Up @@ -363,8 +362,8 @@ def simplified_solis(apparent_elevation, aod700=0.1, precipitable_water=1.,

Returns
-------
clearsky : DataFrame (if Series input) or OrderedDict of arrays
DataFrame/OrderedDict contains the columns/keys
clearsky : DataFrame (if Series input) or dict of arrays
DataFrame/dict contains the columns/keys
``'dhi', 'dni', 'ghi'``.

References
Expand Down Expand Up @@ -408,7 +407,7 @@ def simplified_solis(apparent_elevation, aod700=0.1, precipitable_water=1.,
ghi = i0p * np.exp(-taug/sin_elev**g) * sin_elev
dhi = i0p * np.exp(-taud/sin_elev**d)

irrads = OrderedDict()
irrads = {}
irrads['ghi'] = ghi
irrads['dni'] = dni
irrads['dhi'] = dhi
Expand Down Expand Up @@ -737,7 +736,7 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
Boolean array or Series of whether or not the given time is
clear. Return type is the same as the input type.

components : OrderedDict, optional
components : dict, optional
Dict of arrays of whether or not the given time window is clear
for each condition. Only provided if ``return_components`` is True.

Expand Down Expand Up @@ -905,7 +904,7 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
clear_samples = pd.Series(clear_samples, index=times)

if return_components:
components = OrderedDict()
components = {}
components['mean_diff_flag'] = c1
components['max_diff_flag'] = c2
components['line_length_flag'] = c3
Expand Down Expand Up @@ -971,8 +970,8 @@ def bird(zenith, airmass_relative, aod380, aod500, precipitable_water,

Returns
-------
clearsky : DataFrame (if Series input) or OrderedDict of arrays
DataFrame/OrderedDict contains the columns/keys
clearsky : DataFrame (if Series input) or dict of arrays
DataFrame/dict contains the columns/keys
``'dhi', 'dni', 'ghi', 'direct_horizontal'`` in [W/m^2].

See also
Expand Down Expand Up @@ -1039,8 +1038,8 @@ def bird(zenith, airmass_relative, aod380, aod500, precipitable_water,
gh = (id_nh + ias) / (1.0 - albedo * rs)
diffuse_horiz = gh - id_nh
# TODO: be DRY, use decorator to wrap methods that need to return either
# OrderedDict or DataFrame instead of repeating this boilerplate code
irrads = OrderedDict()
# dict or DataFrame instead of repeating this boilerplate code
irrads = {}
irrads['direct_horizontal'] = id_nh
irrads['ghi'] = gh
irrads['dni'] = id_
Expand Down
33 changes: 16 additions & 17 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import datetime
from collections import OrderedDict
from functools import partial

import numpy as np
Expand Down Expand Up @@ -1958,7 +1957,7 @@ def disc(ghi, solar_zenith, datetime_or_doy, pressure=101325,

Returns
-------
output : OrderedDict or DataFrame
output : dict or DataFrame
Contains the following keys:

* ``dni``: The modeled direct normal irradiance
Expand Down Expand Up @@ -2000,7 +1999,7 @@ def disc(ghi, solar_zenith, datetime_or_doy, pressure=101325,
bad_values = (solar_zenith > max_zenith) | (ghi < 0) | (dni < 0)
dni = np.where(bad_values, 0, dni)

output = OrderedDict()
output = {}
output['dni'] = dni
output['kt'] = kt
output['airmass'] = am
Expand Down Expand Up @@ -2479,7 +2478,7 @@ def gti_dirint(poa_global, aoi, solar_zenith, solar_azimuth, times,

Returns
-------
data : DataFrame
data : dict or DataFrame
Contains the following keys/columns:

* ``ghi``: the modeled global horizontal irradiance. [Wm⁻²]
Expand Down Expand Up @@ -2517,7 +2516,7 @@ def gti_dirint(poa_global, aoi, solar_zenith, solar_azimuth, times,
ghi_gte_90, dni_gte_90, dhi_gte_90 = np.nan, np.nan, np.nan

# put the AOI < 90 and AOI >= 90 conditions together
output = OrderedDict()
output = {}
output['ghi'] = ghi.where(aoi_lt_90, ghi_gte_90)
output['dni'] = dni.where(aoi_lt_90, dni_gte_90)
output['dhi'] = dhi.where(aoi_lt_90, dhi_gte_90)
Expand Down Expand Up @@ -2776,7 +2775,7 @@ def erbs(ghi, zenith, datetime_or_doy, min_cos_zenith=0.065, max_zenith=87):

Returns
-------
data : OrderedDict or DataFrame
data : dict or DataFrame
Contains the following keys/columns:

* ``dni``: the modeled direct normal irradiance. [Wm⁻²]
Expand Down Expand Up @@ -2823,7 +2822,7 @@ def erbs(ghi, zenith, datetime_or_doy, min_cos_zenith=0.065, max_zenith=87):
# ensure that closure relationship remains valid
dhi = np.where(bad_values, ghi, dhi)

data = OrderedDict()
data = {}
data['dni'] = dni
data['dhi'] = dhi
data['kt'] = kt
Expand Down Expand Up @@ -2885,7 +2884,7 @@ def erbs_driesse(ghi, zenith, datetime_or_doy=None, dni_extra=None,

Returns
-------
data : OrderedDict or DataFrame
data : dict or DataFrame
Contains the following keys/columns:

* ``dni``: the modeled direct normal irradiance. [Wm⁻²]
Expand Down Expand Up @@ -2960,7 +2959,7 @@ def erbs_driesse(ghi, zenith, datetime_or_doy=None, dni_extra=None,
# ensure that closure relationship remains valid
dhi = np.where(bad_values, ghi, dhi)

data = OrderedDict()
data = {}
data['dni'] = dni
data['dhi'] = dhi
data['kt'] = kt
Expand Down Expand Up @@ -3012,7 +3011,7 @@ def orgill_hollands(ghi, zenith, datetime_or_doy, dni_extra=None,

Returns
-------
data : OrderedDict or DataFrame
data : dict or DataFrame
Contains the following keys/columns:

* ``dni``: the modeled direct normal irradiance. [Wm⁻²]
Expand Down Expand Up @@ -3058,7 +3057,7 @@ def orgill_hollands(ghi, zenith, datetime_or_doy, dni_extra=None,
# ensure that closure relationship remains valid
dhi = np.where(bad_values, ghi, dhi)

data = OrderedDict()
data = {}
data['dni'] = dni
data['dhi'] = dhi
data['kt'] = kt
Expand Down Expand Up @@ -3113,7 +3112,7 @@ def boland(ghi, solar_zenith, datetime_or_doy, a_coeff=8.645, b_coeff=0.613,

Returns
-------
data : OrderedDict or DataFrame
data : dict or DataFrame
Contains the following keys/columns:

* ``dni``: the modeled direct normal irradiance. [Wm⁻²]
Expand Down Expand Up @@ -3169,7 +3168,7 @@ def boland(ghi, solar_zenith, datetime_or_doy, a_coeff=8.645, b_coeff=0.613,
# ensure that closure relationship remains valid
dhi = np.where(bad_values, ghi, dhi)

data = OrderedDict()
data = {}
data['dni'] = dni
data['dhi'] = dhi
data['kt'] = kt
Expand Down Expand Up @@ -3204,7 +3203,7 @@ def campbell_norman(zenith, transmittance, pressure=101325.0,

Returns
-------
irradiance: DataFrame
irradiance: dict or DataFrame
Modeled direct normal irradiance, direct horizontal irradiance,
and global horizontal irradiance. [Wm⁻²]

Expand All @@ -3223,7 +3222,7 @@ def campbell_norman(zenith, transmittance, pressure=101325.0,
dhi = 0.3 * (1.0 - tau**airmass) * dni_extra * cos_zen
ghi = dhi + dni * cos_zen

irrads = OrderedDict()
irrads = {}
irrads['ghi'] = ghi
irrads['dni'] = dni
irrads['dhi'] = dhi
Expand Down Expand Up @@ -3902,7 +3901,7 @@ def louche(ghi, solar_zenith, datetime_or_doy, max_zenith=90):

Returns
-------
data: OrderedDict or DataFrame
data: dict or DataFrame
Contains the following keys/columns:

* ``dni``: the modeled direct normal irradiance, see :term:`dni`.
Expand Down Expand Up @@ -3934,7 +3933,7 @@ def louche(ghi, solar_zenith, datetime_or_doy, max_zenith=90):
# ensure that closure relationship remains valid
dhi = np.where(bad_values, ghi, dhi)

data = OrderedDict()
data = {}
data['dni'] = dni
data['dhi'] = dhi
data['kt'] = Kt
Expand Down
9 changes: 4 additions & 5 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
performance of PV modules and inverters.
"""

from collections import OrderedDict
import functools
import io
import itertools
Expand Down Expand Up @@ -2262,7 +2261,7 @@ def sapm(effective_irradiance, temp_cell, module, *, temperature_ref=25,

Returns
-------
A DataFrame with the columns:
A dict or DataFrame with the columns:

* i_sc : Short-circuit current (A)
* i_mp : Current at the maximum-power point (A)
Expand Down Expand Up @@ -2369,7 +2368,7 @@ def sapm(effective_irradiance, temp_cell, module, *, temperature_ref=25,
# avoid repeated __getitem__
cells_in_series = module['Cells_in_Series']

out = OrderedDict()
out = {}

out['i_sc'] = (
module['Isco'] * Ee * (1 + module['Aisc']*(temp_cell -
Expand Down Expand Up @@ -2684,7 +2683,7 @@ def max_power_point(photocurrent, saturation_current, resistance_series,

Returns
-------
OrderedDict or pandas.DataFrame
dict or pandas.DataFrame
``(i_mp, v_mp, p_mp)``

Notes
Expand All @@ -2702,7 +2701,7 @@ def max_power_point(photocurrent, saturation_current, resistance_series,
ivp = {'i_mp': i_mp, 'v_mp': v_mp, 'p_mp': p_mp}
out = pd.DataFrame(ivp, index=photocurrent.index)
else:
out = OrderedDict()
out = {}
out['i_mp'] = i_mp
out['v_mp'] = v_mp
out['p_mp'] = p_mp
Expand Down
Loading
Loading