Skip to content

Commit 97c6698

Browse files
authored
Create inverter.py (pvlib#886)
* create inverter.py, move code, add adrinverter fixture * stickler, adjust PVSystem methods * update modelchain, test fixes * sticker * docstring improvements * more docstring work * lint, kludge inverter.test_deprecated_09 * lint, kludge test_deprecated_09 x2 * use new conftest capability * correct use of fixture * add test for invalid ac model string * update whatsnew * update api.rst * extend test_ac_models to new key values * more for whatsnew * correct modelchain.ac_model test * test correction * edits from review * more edits from review * fix thedocs, error * fix indents * improvements from review * more improvements from review * improvements from review * improvements from review * last cleanup * last cleanup part 2 * last cleanup part 3 * py:attribute in whatsnew * docstring improvements * one more
1 parent bf21779 commit 97c6698

14 files changed

+656
-514
lines changed

docs/sphinx/source/api.rst

+20-10
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,21 @@ Low-level functions for solving the single diode equation.
265265
singlediode.bishop88_v_from_i
266266
singlediode.bishop88_mpp
267267

268-
SAPM model
269-
----------
268+
Inverter models (DC to AC conversion)
269+
-------------------------------------
270+
271+
.. autosummary::
272+
:toctree: generated/
273+
274+
inverter.sandia
275+
inverter.adr
276+
inverter.pvwatts
270277

271-
Functions relevant for the SAPM model.
278+
PV System Models
279+
----------------
280+
281+
Sandia array performance model (SAPM)
282+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
272283

273284
.. autosummary::
274285
:toctree: generated/
@@ -277,28 +288,27 @@ Functions relevant for the SAPM model.
277288
pvsystem.sapm_effective_irradiance
278289
pvsystem.sapm_spectral_loss
279290
pvsystem.sapm_aoi_loss
280-
pvsystem.snlinverter
281-
pvsystem.adrinverter
291+
inverter.sandia
282292
temperature.sapm_cell
283293

284294
Pvsyst model
285-
-------------
286-
287-
Functions relevant for the Pvsyst model.
295+
^^^^^^^^^^^^
288296

289297
.. autosummary::
290298
:toctree: generated/
291299

292300
temperature.pvsyst_cell
301+
pvsystem.calcparams_pvsyst
302+
pvsystem.singlediode
293303

294304
PVWatts model
295-
-------------
305+
^^^^^^^^^^^^^
296306

297307
.. autosummary::
298308
:toctree: generated/
299309

300310
pvsystem.pvwatts_dc
301-
pvsystem.pvwatts_ac
311+
inverter.pvwatts
302312
pvsystem.pvwatts_losses
303313

304314
Functions for fitting diode models

docs/sphinx/source/introtutorial.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ to accomplish our system modeling goal:
9696
total_irrad['poa_direct'], total_irrad['poa_diffuse'],
9797
am_abs, aoi, module)
9898
dc = pvlib.pvsystem.sapm(effective_irradiance, tcell, module)
99-
ac = pvlib.pvsystem.snlinverter(dc['v_mp'], dc['p_mp'], inverter)
99+
ac = pvlib.inverter.sandia(dc['v_mp'], dc['p_mp'], inverter)
100100
annual_energy = ac.sum()
101101
energies[name] = annual_energy
102102

docs/sphinx/source/whatsnew/v0.8.0.rst

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@
33
v0.8.0 (Month day, year)
44
-------------------------
55

6+
API Changes with Deprecations
7+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8+
* Moved functions related to inverters from ``pvsystem.py`` to ``inverter.py``.
9+
Functions are renamed to follow a more consistent pattern, as follows (:pull:`886`):
10+
- :py:func:`pvlib.pvsystem.snlinverter` is now :py:func:`pvlib.inverter.sandia`
11+
- :py:func:`pvlib.pvsystem.pvwatts_ac` is now :py:func:`pvlib.inverter.pvwatts`
12+
- :py:func:`pvlib.pvsystem.adrinverter` is now :py:func:`pvlib.inverter.adr`
13+
* Argument ``ac_model`` for :py:class:`pvlib.modelchain.ModelChain` now accepts
14+
``'sandia'``, ``'pvwatts'`` and ``'adr'`` for the inverter models. (:pull:`886`)
15+
616
API Changes
717
~~~~~~~~~~~
8-
* Removed ``run_parallel_calculations`` and ``n_workers_for_parallel_calcs``
18+
* Removed ``run_parallel_calculations`` and ``n_workers_for_parallel_calcs``
919
from :py:func:`pvlib.bifacial.pvfactors_timeseries` inputs (:issue:`902`)(:pull:`934`)
1020

1121
Enhancements
1222
~~~~~~~~~~~~
1323
* Update :func:`~pvlib.bifacial.pvfactors_timeseries` to run with ``pvfactors`` v1.4.1 (:issue:`902`)(:pull:`934`)
14-
* Add :py:func:`pvlib.iam.marion_diffuse` and
24+
* Add :py:func:`pvlib.iam.marion_diffuse` and
1525
:py:func:`pvlib.iam.marion_integrate` to calculate IAM values for
1626
diffuse irradiance. (:pull:`984`)
1727

@@ -23,6 +33,8 @@ Testing
2333
~~~~~~~
2434
* Decorator :py:func:`pvlib.conftest.fail_on_pvlib_version` can now be
2535
applied to functions that require args or kwargs. (:pull:`973`)
36+
* Test added for :py:class:`pvlib.modelchain.ModelChain` to confirm ValueError when
37+
``ac_model`` is an invalid string. (:pull:`886`)
2638

2739
Documentation
2840
~~~~~~~~~~~~~
@@ -32,6 +44,8 @@ Documentation
3244
* Clarify units for heat loss factors in
3345
:py:func:`pvlib.temperature.pvsyst_cell` and
3446
:py:func:`pvlib.temperature.faiman`. (:pull:`960`)
47+
* Corrected key names for :py:func:`pvlib.inverter.sandia`. (:issue:`976`,
48+
:pull:`886`)
3549
* Add a transposition gain example to the gallery. (:pull:`979`)
3650
* Add a gallery example of calculating diffuse IAM using
3751
:py:func:`pvlib.iam.marion_diffuse`. (:pull:`984`)

docs/tutorials/forecast.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8159,7 +8159,7 @@
81598159
" solar_position_method: nrel_numpy\n",
81608160
" airmass_model: kastenyoung1989\n",
81618161
" dc_model: sapm\n",
8162-
" ac_model: snlinverter\n",
8162+
" ac_model: sandia\n",
81638163
" aoi_model: sapm_aoi_loss\n",
81648164
" spectral_model: sapm_spectral_loss\n",
81658165
" temp_model: sapm_temp\n",

docs/tutorials/forecast_to_power.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"import matplotlib as mpl\n",
6868
"\n",
6969
"# finally, we import the pvlib library\n",
70-
"from pvlib import solarposition,irradiance,atmosphere,pvsystem\n",
70+
"from pvlib import solarposition, irradiance, atmosphere, pvsystem, inverter\n",
7171
"from pvlib.forecast import GFS, NAM, NDFD, RAP, HRRR"
7272
]
7373
},
@@ -876,7 +876,7 @@
876876
}
877877
],
878878
"source": [
879-
"p_ac = pvsystem.snlinverter(sapm_out.v_mp, sapm_out.p_mp, sapm_inverter)\n",
879+
"p_ac = inverter.sandia(sapm_out.v_mp, sapm_out.p_mp, sapm_inverter)\n",
880880
"\n",
881881
"p_ac.plot()\n",
882882
"plt.ylabel('AC Power (W)')\n",

docs/tutorials/pvsystem.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"1. [systemdef](#systemdef)\n",
1717
"2. [Angle of Incidence Modifiers](#Angle-of-Incidence-Modifiers)\n",
1818
"2. [Sandia Cell Temp correction](#Sandia-Cell-Temp-correction)\n",
19-
"2. [Sandia Inverter Model](#snlinverter)\n",
19+
"2. [Sandia Inverter Model](#Sandia-inverter-model)\n",
2020
"2. [Sandia Array Performance Model](#SAPM)\n",
2121
" 1. [SAPM IV curves](#SAPM-IV-curves)\n",
2222
"2. [DeSoto Model](#desoto)\n",
@@ -78,7 +78,7 @@
7878
"outputs": [],
7979
"source": [
8080
"import pvlib\n",
81-
"from pvlib import pvsystem"
81+
"from pvlib import pvsystem, inverter"
8282
]
8383
},
8484
{
@@ -573,7 +573,7 @@
573573
"cell_type": "markdown",
574574
"metadata": {},
575575
"source": [
576-
"### snlinverter"
576+
"### Sandia-inverter-model"
577577
]
578578
},
579579
{
@@ -1356,7 +1356,7 @@
13561356
"idcs = pd.Series(np.linspace(0,11,110))\n",
13571357
"pdcs = idcs * vdcs\n",
13581358
"\n",
1359-
"pacs = pvsystem.snlinverter(vdcs, pdcs, inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'])\n",
1359+
"pacs = inverter.sandia(vdcs, pdcs, inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'])\n",
13601360
"#pacs.plot()\n",
13611361
"plt.plot(pacs, pdcs)\n",
13621362
"plt.ylabel('ac power')\n",

docs/tutorials/tmy_to_power.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,8 @@
11841184
],
11851185
"source": [
11861186
"p_acs = pd.DataFrame()\n",
1187-
"p_acs['sapm'] = pvlib.pvsystem.snlinverter(sapm_out.v_mp, sapm_out.p_mp, sapm_inverter)\n",
1188-
"p_acs['sd'] = pvlib.pvsystem.snlinverter(single_diode_out.v_mp, single_diode_out.p_mp, sapm_inverter)\n",
1187+
"p_acs['sapm'] = pvlib.inverter.sandia(sapm_out.v_mp, sapm_out.p_mp, sapm_inverter)\n",
1188+
"p_acs['sd'] = pvlib.inverter.sandia(single_diode_out.v_mp, single_diode_out.p_mp, sapm_inverter)\n",
11891189
"\n",
11901190
"p_acs.plot()\n",
11911191
"plt.ylabel('AC Power (W)')"

0 commit comments

Comments
 (0)