Skip to content

Commit 35af84e

Browse files
authored
Revert "Accept albedo in weather input to ModelChain.run_model method (#1469)" (#1477)
This reverts commit 577f3b5.
1 parent 577f3b5 commit 35af84e

11 files changed

+64
-254
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ Deprecations
88

99
Enhancements
1010
~~~~~~~~~~~~
11-
* albedo can now be provided as a column in the `weather` DataFrame input to
12-
:py:method:`pvlib.modelchain.ModelChain.run_model`. (:issue:`1387`, :pull:`1469`)
1311

1412
Bug fixes
1513
~~~~~~~~~
1614
* :py:func:`pvlib.irradiance.get_total_irradiance` and
1715
:py:func:`pvlib.solarposition.spa_python` now raise an error instead
18-
of silently ignoring unknown parameters. (:pull:`1437`)
16+
of silently ignoring unknown parameters (:pull:`1437`)
1917
* Fix a bug in :py:func:`pvlib.solarposition.sun_rise_set_transit_ephem`
2018
where passing localized timezones with large UTC offsets could return
21-
rise/set/transit times for the wrong day in recent versions of ``ephem``.
19+
rise/set/transit times for the wrong day in recent versions of ``ephem``
2220
(:issue:`1449`, :pull:`1448`)
2321

2422

@@ -45,5 +43,4 @@ Contributors
4543
* Naman Priyadarshi (:ghuser:`Naman-Priyadarshi`)
4644
* Chencheng Luo (:ghuser:`roger-lcc`)
4745
* Prajwal Borkar (:ghuser:`PrajwalBorkar`)
48-
* Cliff Hansen (:ghuser:`cwhanse`)
4946
* Kevin Anderson (:ghuser:`kanderso-nrel`)

pvlib/clearsky.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,8 @@ def bird(zenith, airmass_relative, aod380, aod500, precipitable_water,
960960
Extraterrestrial radiation [W/m^2], defaults to 1364[W/m^2]
961961
asymmetry : numeric
962962
Asymmetry factor, defaults to 0.85
963-
albedo : numeric, default 0.2
964-
Ground surface albedo. [unitless]
963+
albedo : numeric
964+
Albedo, defaults to 0.2
965965
966966
Returns
967967
-------

pvlib/irradiance.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def beam_component(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
304304
def get_total_irradiance(surface_tilt, surface_azimuth,
305305
solar_zenith, solar_azimuth,
306306
dni, ghi, dhi, dni_extra=None, airmass=None,
307-
albedo=0.25, surface_type=None,
307+
albedo=.25, surface_type=None,
308308
model='isotropic',
309309
model_perez='allsitescomposite1990'):
310310
r"""
@@ -344,7 +344,7 @@ def get_total_irradiance(surface_tilt, surface_azimuth,
344344
airmass : None or numeric, default None
345345
Relative airmass (not adjusted for pressure). [unitless]
346346
albedo : numeric, default 0.25
347-
Ground surface albedo. [unitless]
347+
Surface albedo. [unitless]
348348
surface_type : None or str, default None
349349
Surface type. See :py:func:`~pvlib.irradiance.get_ground_diffuse` for
350350
the list of accepted values.
@@ -1872,7 +1872,7 @@ def gti_dirint(poa_global, aoi, solar_zenith, solar_azimuth, times,
18721872
applied.
18731873
18741874
albedo : numeric, default 0.25
1875-
Ground surface albedo. [unitless]
1875+
Surface albedo
18761876
18771877
model : String, default 'perez'
18781878
Irradiance model. See :py:func:`get_sky_diffuse` for allowed values.

pvlib/modelchain.py

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,16 +1339,6 @@ def _prep_inputs_solar_pos(self, weather):
13391339
**kwargs)
13401340
return self
13411341

1342-
def _prep_inputs_albedo(self, weather):
1343-
"""
1344-
Get albedo from weather
1345-
"""
1346-
try:
1347-
self.results.albedo = _tuple_from_dfs(weather, 'albedo')
1348-
except KeyError:
1349-
self.results.albedo = None
1350-
return self
1351-
13521342
def _prep_inputs_airmass(self):
13531343
"""
13541344
Assign airmass
@@ -1481,17 +1471,11 @@ def prepare_inputs(self, weather):
14811471
14821472
Parameters
14831473
----------
1484-
weather : DataFrame, or tuple or list of DataFrames
1474+
weather : DataFrame, or tuple or list of DataFrame
14851475
Required column names include ``'dni'``, ``'ghi'``, ``'dhi'``.
1486-
Optional column names are ``'wind_speed'``, ``'temp_air'``,
1487-
``'albedo'``.
1488-
1489-
If optional columns ``'wind_speed'``, ``'temp_air'`` are not
1476+
Optional column names are ``'wind_speed'``, ``'temp_air'``; if not
14901477
provided, air temperature of 20 C and wind speed
1491-
of 0 m/s will be added to the `weather` DataFrame.
1492-
1493-
If optional column ``'albedo'`` is provided, albedo values in the
1494-
ModelChain's PVSystem.arrays are ignored.
1478+
of 0 m/s will be added to the DataFrame.
14951479
14961480
If `weather` is a tuple or list, it must be of the same length and
14971481
order as the Arrays of the ModelChain's PVSystem.
@@ -1510,7 +1494,7 @@ def prepare_inputs(self, weather):
15101494
Notes
15111495
-----
15121496
Assigns attributes to ``results``: ``times``, ``weather``,
1513-
``solar_position``, ``airmass``, ``total_irrad``, ``aoi``, ``albedo``.
1497+
``solar_position``, ``airmass``, ``total_irrad``, ``aoi``
15141498
15151499
See also
15161500
--------
@@ -1523,7 +1507,6 @@ def prepare_inputs(self, weather):
15231507

15241508
self._prep_inputs_solar_pos(weather)
15251509
self._prep_inputs_airmass()
1526-
self._prep_inputs_albedo(weather)
15271510

15281511
# PVSystem.get_irradiance and SingleAxisTracker.get_irradiance
15291512
# and PVSystem.get_aoi and SingleAxisTracker.get_aoi
@@ -1548,7 +1531,6 @@ def prepare_inputs(self, weather):
15481531
_tuple_from_dfs(self.results.weather, 'dni'),
15491532
_tuple_from_dfs(self.results.weather, 'ghi'),
15501533
_tuple_from_dfs(self.results.weather, 'dhi'),
1551-
albedo=self.results.albedo,
15521534
airmass=self.results.airmass['airmass_relative'],
15531535
model=self.transposition_model
15541536
)
@@ -1742,32 +1724,16 @@ def run_model(self, weather):
17421724
Parameters
17431725
----------
17441726
weather : DataFrame, or tuple or list of DataFrame
1745-
Column names must include:
1746-
1747-
- ``'dni'``
1748-
- ``'ghi'``
1749-
- ``'dhi'``
1750-
1751-
Optional columns are:
1752-
1753-
- ``'temp_air'``
1754-
- ``'cell_temperature'``
1755-
- ``'module_temperature'``
1756-
- ``'wind_speed'``
1757-
- ``'albedo'``
1758-
1759-
If optional columns ``'temp_air'`` and ``'wind_speed'``
1727+
Irradiance column names must include ``'dni'``, ``'ghi'``, and
1728+
``'dhi'``. If optional columns ``'temp_air'`` and ``'wind_speed'``
17601729
are not provided, air temperature of 20 C and wind speed of 0 m/s
17611730
are added to the DataFrame. If optional column
17621731
``'cell_temperature'`` is provided, these values are used instead
1763-
of `temperature_model`. If optional column ``'module_temperature'``
1732+
of `temperature_model`. If optional column `module_temperature`
17641733
is provided, `temperature_model` must be ``'sapm'``.
17651734
1766-
If optional column ``'albedo'`` is provided, ``'albedo'`` may not
1767-
be present on the ModelChain's PVSystem.Arrays.
1768-
1769-
If weather is a list or tuple, it must be of the same length and
1770-
order as the Arrays of the ModelChain's PVSystem.
1735+
If list or tuple, must be of the same length and order as the
1736+
Arrays of the ModelChain's PVSystem.
17711737
17721738
Returns
17731739
-------

pvlib/pvsystem.py

Lines changed: 37 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class PVSystem:
134134
a single array is created from the other parameters (e.g.
135135
`surface_tilt`, `surface_azimuth`). Must contain at least one Array,
136136
if length of arrays is 0 a ValueError is raised. If `arrays` is
137-
specified the following PVSystem parameters are ignored:
137+
specified the following parameters are ignored:
138138
139139
- `surface_tilt`
140140
- `surface_azimuth`
@@ -157,16 +157,13 @@ class PVSystem:
157157
North=0, East=90, South=180, West=270.
158158
159159
albedo : None or float, default None
160-
Ground surface albedo. If ``None``, then ``surface_type`` is used
161-
to look up a value in ``irradiance.SURFACE_ALBEDOS``.
162-
If ``surface_type`` is also None then a ground surface albedo
163-
of 0.25 is used. For time-dependent albedos, add ``'albedo'`` to
164-
the input ``'weather'`` DataFrame for
165-
:py:class:`pvlib.modelchain.ModelChain` methods.
160+
The ground albedo. If ``None``, will attempt to use
161+
``surface_type`` and ``irradiance.SURFACE_ALBEDOS``
162+
to lookup albedo.
166163
167164
surface_type : None or string, default None
168-
The ground surface type. See ``irradiance.SURFACE_ALBEDOS`` for
169-
valid values.
165+
The ground surface type. See ``irradiance.SURFACE_ALBEDOS``
166+
for valid values.
170167
171168
module : None or string, default None
172169
The model name of the modules.
@@ -336,32 +333,30 @@ def get_aoi(self, solar_zenith, solar_azimuth):
336333

337334
@_unwrap_single_value
338335
def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi,
339-
albedo=None, dni_extra=None, airmass=None,
340-
model='haydavies', **kwargs):
336+
dni_extra=None, airmass=None, model='haydavies',
337+
**kwargs):
341338
"""
342339
Uses the :py:func:`irradiance.get_total_irradiance` function to
343340
calculate the plane of array irradiance components on a tilted
344-
surface defined by ``self.surface_tilt`` and ``self.surface_azimuth```.
341+
surface defined by ``self.surface_tilt``,
342+
``self.surface_azimuth``, and ``self.albedo``.
345343
346344
Parameters
347345
----------
348-
solar_zenith : float or Series
346+
solar_zenith : float or Series.
349347
Solar zenith angle.
350-
solar_azimuth : float or Series
348+
solar_azimuth : float or Series.
351349
Solar azimuth angle.
352350
dni : float or Series or tuple of float or Series
353-
Direct Normal Irradiance. [W/m2]
351+
Direct Normal Irradiance
354352
ghi : float or Series or tuple of float or Series
355-
Global horizontal irradiance. [W/m2]
353+
Global horizontal irradiance
356354
dhi : float or Series or tuple of float or Series
357-
Diffuse horizontal irradiance. [W/m2]
358-
albedo : None, float or Series, default None
359-
Ground surface albedo. [unitless]
360-
dni_extra : None, float, Series or tuple of float or Series,
361-
default None
362-
Extraterrestrial direct normal irradiance. [W/m2]
355+
Diffuse horizontal irradiance
356+
dni_extra : None, float or Series, default None
357+
Extraterrestrial direct normal irradiance
363358
airmass : None, float or Series, default None
364-
Airmass. [unitless]
359+
Airmass
365360
model : String, default 'haydavies'
366361
Irradiance model.
367362
@@ -381,26 +376,17 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi,
381376
poa_irradiance : DataFrame or tuple of DataFrame
382377
Column names are: ``'poa_global', 'poa_direct', 'poa_diffuse',
383378
'poa_sky_diffuse', 'poa_ground_diffuse'``.
384-
385-
See also
386-
--------
387-
:py:func:`pvlib.irradiance.get_total_irradiance`
388379
"""
389380
dni = self._validate_per_array(dni, system_wide=True)
390381
ghi = self._validate_per_array(ghi, system_wide=True)
391382
dhi = self._validate_per_array(dhi, system_wide=True)
392-
393-
albedo = self._validate_per_array(albedo, system_wide=True)
394-
395383
return tuple(
396384
array.get_irradiance(solar_zenith, solar_azimuth,
397385
dni, ghi, dhi,
398-
albedo=albedo,
399-
dni_extra=dni_extra, airmass=airmass,
400-
model=model,
386+
dni_extra, airmass, model,
401387
**kwargs)
402-
for array, dni, ghi, dhi, albedo in zip(
403-
self.arrays, dni, ghi, dhi, albedo
388+
for array, dni, ghi, dhi in zip(
389+
self.arrays, dni, ghi, dhi
404390
)
405391
)
406392

@@ -1272,14 +1258,14 @@ class Array:
12721258
If not provided, a FixedMount with zero tilt is used.
12731259
12741260
albedo : None or float, default None
1275-
Ground surface albedo. If ``None``, then ``surface_type`` is used
1276-
to look up a value in ``irradiance.SURFACE_ALBEDOS``.
1277-
If ``surface_type`` is also None then a ground surface albedo
1278-
of 0.25 is used.
1261+
The ground albedo. If ``None``, will attempt to use
1262+
``surface_type`` to look up an albedo value in
1263+
``irradiance.SURFACE_ALBEDOS``. If a surface albedo
1264+
cannot be found then 0.25 is used.
12791265
12801266
surface_type : None or string, default None
1281-
The ground surface type. See ``irradiance.SURFACE_ALBEDOS`` for valid
1282-
values.
1267+
The ground surface type. See ``irradiance.SURFACE_ALBEDOS``
1268+
for valid values.
12831269
12841270
module : None or string, default None
12851271
The model name of the modules.
@@ -1439,14 +1425,15 @@ def get_aoi(self, solar_zenith, solar_azimuth):
14391425
solar_zenith, solar_azimuth)
14401426

14411427
def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi,
1442-
albedo=None, dni_extra=None, airmass=None,
1443-
model='haydavies', **kwargs):
1428+
dni_extra=None, airmass=None, model='haydavies',
1429+
**kwargs):
14441430
"""
14451431
Get plane of array irradiance components.
14461432
14471433
Uses the :py:func:`pvlib.irradiance.get_total_irradiance` function to
14481434
calculate the plane of array irradiance components for a surface
1449-
defined by ``self.surface_tilt`` and ``self.surface_azimuth``.
1435+
defined by ``self.surface_tilt`` and ``self.surface_azimuth`` with
1436+
albedo ``self.albedo``.
14501437
14511438
Parameters
14521439
----------
@@ -1455,17 +1442,15 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi,
14551442
solar_azimuth : float or Series.
14561443
Solar azimuth angle.
14571444
dni : float or Series
1458-
Direct normal irradiance. [W/m2]
1459-
ghi : float or Series. [W/m2]
1445+
Direct Normal Irradiance
1446+
ghi : float or Series
14601447
Global horizontal irradiance
14611448
dhi : float or Series
1462-
Diffuse horizontal irradiance. [W/m2]
1463-
albedo : None, float or Series, default None
1464-
Ground surface albedo. [unitless]
1449+
Diffuse horizontal irradiance
14651450
dni_extra : None, float or Series, default None
1466-
Extraterrestrial direct normal irradiance. [W/m2]
1451+
Extraterrestrial direct normal irradiance
14671452
airmass : None, float or Series, default None
1468-
Airmass. [unitless]
1453+
Airmass
14691454
model : String, default 'haydavies'
14701455
Irradiance model.
14711456
@@ -1478,14 +1463,7 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi,
14781463
poa_irradiance : DataFrame
14791464
Column names are: ``'poa_global', 'poa_direct', 'poa_diffuse',
14801465
'poa_sky_diffuse', 'poa_ground_diffuse'``.
1481-
1482-
See also
1483-
--------
1484-
:py:func:`pvlib.irradiance.get_total_irradiance`
14851466
"""
1486-
if albedo is None:
1487-
albedo = self.albedo
1488-
14891467
# not needed for all models, but this is easier
14901468
if dni_extra is None:
14911469
dni_extra = irradiance.get_extra_radiation(solar_zenith.index)
@@ -1498,10 +1476,10 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi,
14981476
orientation['surface_azimuth'],
14991477
solar_zenith, solar_azimuth,
15001478
dni, ghi, dhi,
1501-
albedo=albedo,
15021479
dni_extra=dni_extra,
15031480
airmass=airmass,
15041481
model=model,
1482+
albedo=self.albedo,
15051483
**kwargs)
15061484

15071485
def get_iam(self, aoi, iam_model='physical'):

pvlib/tests/test_clearsky.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -756,30 +756,6 @@ def test_bird():
756756
assert np.allclose(
757757
testdata['Dif Hz'].where(dusk, 0.), diffuse_horz[1:48], rtol=1e-3
758758
)
759-
# repeat test with albedo as a Series
760-
alb_series = pd.Series(0.2, index=times)
761-
irrads = clearsky.bird(
762-
zenith, airmass, aod_380nm, aod_500nm, h2o_cm, o3_cm, press_mB * 100.,
763-
etr, b_a, alb_series
764-
)
765-
Eb, Ebh, Gh, Dh = (irrads[_] for _ in field_names)
766-
direct_beam = pd.Series(np.where(dawn, Eb, 0.), index=times).fillna(0.)
767-
assert np.allclose(
768-
testdata['Direct Beam'].where(dusk, 0.), direct_beam[1:48], rtol=1e-3
769-
)
770-
direct_horz = pd.Series(np.where(dawn, Ebh, 0.), index=times).fillna(0.)
771-
assert np.allclose(
772-
testdata['Direct Hz'].where(dusk, 0.), direct_horz[1:48], rtol=1e-3
773-
)
774-
global_horz = pd.Series(np.where(dawn, Gh, 0.), index=times).fillna(0.)
775-
assert np.allclose(
776-
testdata['Global Hz'].where(dusk, 0.), global_horz[1:48], rtol=1e-3
777-
)
778-
diffuse_horz = pd.Series(np.where(dawn, Dh, 0.), index=times).fillna(0.)
779-
assert np.allclose(
780-
testdata['Dif Hz'].where(dusk, 0.), diffuse_horz[1:48], rtol=1e-3
781-
)
782-
783759
# test keyword parameters
784760
irrads2 = clearsky.bird(
785761
zenith, airmass, aod_380nm, aod_500nm, h2o_cm, dni_extra=etr

0 commit comments

Comments
 (0)