Skip to content

Commit dafaa85

Browse files
wholmgrencwhanse
authored andcommitted
add get_[relative_airmass,sky_diffuse,ground_diffuse,extra_radiation,total_irradiance] and pvlibDeprecationWarning (#427)
* initial refactor * remove new fields from globalinplane wrapper * update test * update whatsnew * add DeprecationWarning * update api.rst * add _deprecation.py module * extraradiation to get_extra_radiation * grounddiffuse to get_ground_diffuse * remove deprecated klutcher (misspelling) from get_sky_diffuse * total_irrad to get_total_poa_irradiance * update api.rst * change airmass function names * forgot to change get_extra_radiation in api.rst * remove poa from new function names * no PVLIBDeprecationWarnings in tests * update deprecation versions * fix bad merge of whatsnew * add fail_on_pvlib_version decorator * pep8 * rename warning, add test_conftest * remove extra comments * fix broken test * update get_total_irradiance arg names * add test values, fix botched merges * update to latest mpl code with minor mods * remove missed kwarg only syntax * absolute_airmass becomes get_absolute_airmass for consistency and future proofing * update extraradiation call in forecast.py * update docs to use new api * update tutorials * appveyor config * sprinkle plt.close to reduce memory on rtd * fix fail_on_pvlib_version * allow xpass on python2 and windows
1 parent dc6bdbf commit dafaa85

29 files changed

+7234
-6101
lines changed

appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ install:
2929
- cmd: conda info -a
3030

3131
# install depenencies
32-
- cmd: conda create -n test_env --yes --quiet python=%PYTHON_VERSION% pip numpy scipy pytables pandas nose pytest pytz ephem numba siphon pytest-mock -c conda-forge
32+
- cmd: conda create -n test_env --yes --quiet python=%PYTHON_VERSION% numpy scipy pytables pandas nose pytest pytz ephem numba siphon pytest-mock -c conda-forge
3333
- cmd: activate test_env
3434
- cmd: python --version
3535
- cmd: conda list
@@ -40,4 +40,4 @@ install:
4040
build: false
4141

4242
test_script:
43-
- cmd: py.test -v pvlib
43+
- cmd: pytest -v pvlib

docs/sphinx/source/api.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ Airmass and atmospheric models
102102
:toctree: generated/
103103

104104
location.Location.get_airmass
105-
atmosphere.absoluteairmass
106-
atmosphere.relativeairmass
105+
atmosphere.get_absolute_airmass
106+
atmosphere.get_relative_airmass
107107
atmosphere.pres2alt
108108
atmosphere.alt2pres
109109
atmosphere.gueymard94_pw
@@ -133,21 +133,22 @@ Decomposing and combining irradiance
133133
.. autosummary::
134134
:toctree: generated/
135135

136-
irradiance.extraradiation
136+
irradiance.get_extra_radiation
137137
irradiance.aoi
138138
irradiance.aoi_projection
139139
irradiance.poa_horizontal_ratio
140140
irradiance.beam_component
141-
irradiance.globalinplane
142-
irradiance.grounddiffuse
141+
irradiance.poa_components
142+
irradiance.get_ground_diffuse
143143

144144
Transposition models
145145
--------------------
146146

147147
.. autosummary::
148148
:toctree: generated/
149149

150-
irradiance.total_irrad
150+
irradiance.get_total_irradiance
151+
irradiance.get_sky_diffuse
151152
irradiance.isotropic
152153
irradiance.perez
153154
irradiance.haydavies

docs/sphinx/source/clearsky.rst

+35-8
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ A clear sky time series using only basic pvlib functions.
213213

214214
In [1]: apparent_zenith = solpos['apparent_zenith']
215215

216-
In [1]: airmass = pvlib.atmosphere.relativeairmass(apparent_zenith)
216+
In [1]: airmass = pvlib.atmosphere.get_relative_airmass(apparent_zenith)
217217

218218
In [1]: pressure = pvlib.atmosphere.alt2pres(altitude)
219219

220-
In [1]: airmass = pvlib.atmosphere.absoluteairmass(airmass, pressure)
220+
In [1]: airmass = pvlib.atmosphere.get_absolute_airmass(airmass, pressure)
221221

222222
In [1]: linke_turbidity = pvlib.clearsky.lookup_linke_turbidity(times, latitude, longitude)
223223

224-
In [1]: dni_extra = pvlib.irradiance.extraradiation(times)
224+
In [1]: dni_extra = pvlib.irradiance.get_extra_radiation(times)
225225

226226
# an input is a pandas Series, so solis is a DataFrame
227227
In [1]: ineichen = clearsky.ineichen(apparent_zenith, airmass, linke_turbidity, altitude, dni_extra)
@@ -253,17 +253,17 @@ Grid with a clear sky irradiance for a few turbidity values.
253253

254254
In [1]: apparent_zenith = solpos['apparent_zenith']
255255

256-
In [1]: airmass = pvlib.atmosphere.relativeairmass(apparent_zenith)
256+
In [1]: airmass = pvlib.atmosphere.get_relative_airmass(apparent_zenith)
257257

258258
In [1]: pressure = pvlib.atmosphere.alt2pres(altitude)
259259

260-
In [1]: airmass = pvlib.atmosphere.absoluteairmass(airmass, pressure)
260+
In [1]: airmass = pvlib.atmosphere.get_absolute_airmass(airmass, pressure)
261261

262262
In [1]: linke_turbidity = pvlib.clearsky.lookup_linke_turbidity(times, latitude, longitude)
263263

264264
In [1]: print('climatological linke_turbidity = {}'.format(linke_turbidity.mean()))
265265

266-
In [1]: dni_extra = pvlib.irradiance.extraradiation(times)
266+
In [1]: dni_extra = pvlib.irradiance.get_extra_radiation(times)
267267

268268
In [1]: linke_turbidities = [linke_turbidity.mean(), 2, 4]
269269

@@ -280,6 +280,9 @@ Grid with a clear sky irradiance for a few turbidity values.
280280
@savefig ineichen-grid.png width=10in
281281
In [1]: plt.show();
282282

283+
@suppress
284+
In [1]: plt.close();
285+
283286

284287

285288
Validation
@@ -350,7 +353,7 @@ A clear sky time series using only basic pvlib functions.
350353

351354
In [1]: pressure = pvlib.atmosphere.alt2pres(altitude)
352355

353-
In [1]: dni_extra = pvlib.irradiance.extraradiation(times)
356+
In [1]: dni_extra = pvlib.irradiance.get_extra_radiation(times)
354357

355358
# an input is a Series, so solis is a DataFrame
356359
In [1]: solis = clearsky.simplified_solis(apparent_elevation, aod700, precipitable_water,
@@ -367,6 +370,9 @@ A clear sky time series using only basic pvlib functions.
367370
@savefig solis-vs-time-0.1-1.png width=6in
368371
In [1]: plt.show();
369372

373+
@suppress
374+
In [1]: plt.close();
375+
370376
The input data types determine the returned output type. Array input
371377
results in an OrderedDict of array output, and Series input results in a
372378
DataFrame output. The keys are 'ghi', 'dni', and 'dhi'.
@@ -399,6 +405,9 @@ Irradiance as a function of solar elevation.
399405
@savefig solis-vs-elevation.png width=6in
400406
In [1]: ax.legend(loc=2);
401407

408+
@suppress
409+
In [1]: plt.close();
410+
402411

403412
Grid with a clear sky irradiance for a few PW and AOD values.
404413

@@ -412,7 +421,7 @@ Grid with a clear sky irradiance for a few PW and AOD values.
412421

413422
In [1]: pressure = pvlib.atmosphere.alt2pres(altitude)
414423

415-
In [1]: dni_extra = pvlib.irradiance.extraradiation(times)
424+
In [1]: dni_extra = pvlib.irradiance.get_extra_radiation(times)
416425

417426
In [1]: aod700 = [0.01, 0.1]
418427

@@ -429,6 +438,9 @@ Grid with a clear sky irradiance for a few PW and AOD values.
429438
@savefig solis-grid.png width=10in
430439
In [1]: plt.show();
431440

441+
@suppress
442+
In [1]: plt.close();
443+
432444
Contour plots of irradiance as a function of both PW and AOD.
433445

434446
.. ipython::
@@ -474,16 +486,25 @@ Contour plots of irradiance as a function of both PW and AOD.
474486
@savefig solis-ghi.png width=10in
475487
In [1]: plt.show()
476488

489+
@suppress
490+
In [1]: plt.close();
491+
477492
In [1]: plot_solis('dni')
478493

479494
@savefig solis-dni.png width=10in
480495
In [1]: plt.show()
481496

497+
@suppress
498+
In [1]: plt.close();
499+
482500
In [1]: plot_solis('dhi')
483501

484502
@savefig solis-dhi.png width=10in
485503
In [1]: plt.show()
486504

505+
@suppress
506+
In [1]: plt.close();
507+
487508

488509
Validation
489510
^^^^^^^^^^
@@ -548,6 +569,9 @@ GHI data. We first generate and plot the clear sky and measured data.
548569
@savefig detect-clear-ghi.png width=10in
549570
plt.show();
550571
572+
@suppress
573+
plt.close();
574+
551575
Now we run the synthetic data and clear sky estimate through the
552576
:py:func:`~pvlib.clearsky.detect_clearsky` function.
553577

@@ -562,6 +586,9 @@ Now we run the synthetic data and clear sky estimate through the
562586
@savefig detect-clear-detected.png width=10in
563587
ax.set_ylabel('Clear (1) or Cloudy (0)');
564588
589+
@suppress
590+
plt.close();
591+
565592
The algorithm detected the cloud event and the overirradiance event.
566593

567594

docs/sphinx/source/forecasts.rst

+22
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ cover forecasts.
195195
.format(latitude, longitude));
196196
@savefig gfs_cloud_cover.png width=6in
197197
plt.legend();
198+
@suppress
199+
plt.close();
198200
199201
However, many of forecast models do not include radiation components in
200202
their output fields, or if they do then the radiation fields suffer from
@@ -245,6 +247,8 @@ irradiance conversion using the clear sky scaling algorithm.
245247
.format(latitude, longitude));
246248
@savefig gfs_irrad_cs.png width=6in
247249
plt.legend();
250+
@suppress
251+
plt.close();
248252
249253
250254
The essential parts of the Liu-Jordan cloud cover to irradiance algorithm
@@ -271,6 +275,8 @@ irradiance conversion.
271275
.format(latitude, longitude));
272276
@savefig gfs_irrad_lj.png width=6in
273277
plt.legend();
278+
@suppress
279+
plt.close();
274280
275281
276282
Most weather model output has a fairly coarse time resolution, at least
@@ -290,6 +296,8 @@ recalculate the irradiance.
290296
.format(latitude, longitude));
291297
@savefig gfs_irrad_high_res.png width=6in
292298
plt.legend();
299+
@suppress
300+
plt.close();
293301
294302
Users may then recombine resampled_irrads and resampled_data using
295303
slicing :py:func:`pandas.concat` or :py:meth:`pandas.DataFrame.join`.
@@ -345,6 +353,8 @@ The HRRR model covers the continental United States.
345353
.format(latitude, longitude));
346354
@savefig hrrr_irrad.png width=6in
347355
plt.legend();
356+
@suppress
357+
plt.close();
348358
349359
350360
RAP
@@ -369,6 +379,8 @@ The RAP model covers most of North America.
369379
.format(latitude, longitude));
370380
@savefig rap_irrad.png width=6in
371381
plt.legend();
382+
@suppress
383+
plt.close();
372384
373385
374386
NAM
@@ -389,6 +401,8 @@ resolution NAM data with a time horizon of up to 4 days.
389401
.format(latitude, longitude));
390402
@savefig nam_irrad.png width=6in
391403
plt.legend();
404+
@suppress
405+
plt.close();
392406
393407
394408
NDFD
@@ -411,6 +425,8 @@ The NDFD is available for the United States.
411425
.format(latitude, longitude));
412426
@savefig ndfd_irrad.png width=6in
413427
plt.legend();
428+
@suppress
429+
plt.close();
414430
415431
416432
PV Power Forecast
@@ -456,6 +472,8 @@ Here's the forecast plane of array irradiance...
456472
@savefig poa_irrad.png width=6in
457473
plt.ylabel('Plane of array irradiance ($W/m^2$)');
458474
plt.legend(loc='best');
475+
@suppress
476+
plt.close();
459477
460478
...the cell and module temperature...
461479

@@ -464,6 +482,8 @@ Here's the forecast plane of array irradiance...
464482
mc.temps.plot();
465483
@savefig pv_temps.png width=6in
466484
plt.ylabel('Temperature (C)');
485+
@suppress
486+
plt.close();
467487
468488
...and finally AC power...
469489

@@ -473,4 +493,6 @@ Here's the forecast plane of array irradiance...
473493
plt.ylim(0, None);
474494
@savefig ac_power.png width=6in
475495
plt.ylabel('AC Power (W)');
496+
@suppress
497+
plt.close();
476498

docs/sphinx/source/package_overview.rst

+18-10
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,23 @@ to accomplish our system modeling goal:
8181
times = naive_times.tz_localize(timezone)
8282
system['surface_tilt'] = latitude
8383
solpos = pvlib.solarposition.get_solarposition(times, latitude, longitude)
84-
dni_extra = pvlib.irradiance.extraradiation(times)
84+
dni_extra = pvlib.irradiance.get_extra_radiation(times)
8585
dni_extra = pd.Series(dni_extra, index=times)
86-
airmass = pvlib.atmosphere.relativeairmass(solpos['apparent_zenith'])
86+
airmass = pvlib.atmosphere.get_relative_airmass(solpos['apparent_zenith'])
8787
pressure = pvlib.atmosphere.alt2pres(altitude)
88-
am_abs = pvlib.atmosphere.absoluteairmass(airmass, pressure)
88+
am_abs = pvlib.atmosphere.get_absolute_airmass(airmass, pressure)
8989
tl = pvlib.clearsky.lookup_linke_turbidity(times, latitude, longitude)
9090
cs = pvlib.clearsky.ineichen(solpos['apparent_zenith'], am_abs, tl,
9191
dni_extra=dni_extra, altitude=altitude)
9292
aoi = pvlib.irradiance.aoi(system['surface_tilt'], system['surface_azimuth'],
9393
solpos['apparent_zenith'], solpos['azimuth'])
94-
total_irrad = pvlib.irradiance.total_irrad(system['surface_tilt'],
95-
system['surface_azimuth'],
96-
solpos['apparent_zenith'],
97-
solpos['azimuth'],
98-
cs['dni'], cs['ghi'], cs['dhi'],
99-
dni_extra=dni_extra,
100-
model='haydavies')
94+
total_irrad = pvlib.irradiance.get_total_irradiance(system['surface_tilt'],
95+
system['surface_azimuth'],
96+
solpos['apparent_zenith'],
97+
solpos['azimuth'],
98+
cs['dni'], cs['ghi'], cs['dhi'],
99+
dni_extra=dni_extra,
100+
model='haydavies')
101101
temps = pvlib.pvsystem.sapm_celltemp(total_irrad['poa_global'],
102102
wind_speed, temp_air)
103103
effective_irradiance = pvlib.pvsystem.sapm_effective_irradiance(
@@ -116,6 +116,8 @@ to accomplish our system modeling goal:
116116
energies.plot(kind='bar', rot=0)
117117
@savefig proc-energies.png width=6in
118118
plt.ylabel('Yearly energy yield (W hr)')
119+
@suppress
120+
plt.close();
119121
120122
pvlib-python provides a :py:func:`~pvlib.modelchain.basic_chain`
121123
function that implements much of the code above. Use this function with
@@ -143,6 +145,8 @@ a full understanding of what it is doing internally!
143145
energies.plot(kind='bar', rot=0)
144146
@savefig basic-chain-energies.png width=6in
145147
plt.ylabel('Yearly energy yield (W hr)')
148+
@suppress
149+
plt.close();
146150
147151
148152
.. _object-oriented:
@@ -197,6 +201,8 @@ objects to accomplish our system modeling goal:
197201
energies.plot(kind='bar', rot=0)
198202
@savefig modelchain-energies.png width=6in
199203
plt.ylabel('Yearly energy yield (W hr)')
204+
@suppress
205+
plt.close();
200206
201207
202208
Object oriented (LocalizedPVSystem)
@@ -255,6 +261,8 @@ object to accomplish our modeling goal:
255261
energies.plot(kind='bar', rot=0)
256262
@savefig localized-pvsystem-energies.png width=6in
257263
plt.ylabel('Yearly energy yield (W hr)')
264+
@suppress
265+
plt.close();
258266
259267
260268
User extensions

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

+28
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ v0.6.0 (___, 2018)
55

66
API Changes
77
~~~~~~~~~~~
8+
* pvlib python is changing a handful of function names. In general, functions
9+
that can calculate a quantity using multiple algorithms now start
10+
with the prefix ``get_``. For example, ``relativeairmass`` can calculate
11+
airmass using one of many ``model`` arguments. Its name has been changed
12+
to ``get_relative_airmass``. The old function names remain in this
13+
release, but will emit a ``PVLibDeprecationWarning`` when called. The
14+
old functions will be removed in the 0.7 release. Functions composed
15+
of multiple words jammed together have been renamed with underscores
16+
separating the words (see above).
17+
Each change is detailed below. (:issue:`427`)
18+
* Deprecated relativeairmass. relativeairmass will be removed in 0.7.
19+
Use the new get_relative_airmass instead. (:issue:`427`)
20+
* Deprecated absoluteairmass. absoluteairmass will be removed in 0.7.
21+
Use the new get_absolute_airmass instead. (:issue:`427`)
22+
* Deprecated irradiance.globalinplane. globalinplane will be removed in 0.7.
23+
Use the new irradiance.poa_components instead. (:issue:`427`)
24+
* Added irradiance.poa_components. Function is the same as the now-deprecated
25+
irradiance.globalinplane, but adds 'poa_sky_diffuse' and
26+
'poa_ground_diffuse' to the output. (:issue:`427`)
27+
* Deprecated irradiance.extraradiation. Use irradiance.get_extra_radiation
28+
instead. irradiance.extraradiation will be removed in 0.7. (:issue:`427`)
29+
* Deprecated irradiance.grounddiffuse. Use irradiance.get_ground_diffuse
30+
instead. irradiance.grounddiffuse will be removed in 0.7. (:issue:`427`)
31+
* Added irradiance.get_poa_sky_diffuse. (:issue:`427`)
32+
* Deprecated irradiance.total_irrad. Use irradiance.get_total_poa_irradiance
33+
instead. irradiance.total_irrad will be removed in 0.7. (:issue:`427`)
34+
* Removed 'klutcher' from get_sky_diffuse/total_irrad. This misspelling was
35+
deprecated long ago but never removed. (:issue:`97`)
836
* pvsystem.calcparams_desoto now requires arguments for each module model
937
parameter. (:issue:`462`)
1038
* Add losses_parameters attribute to PVSystem objects and remove the kwargs

0 commit comments

Comments
 (0)