10000 Accept albedo in weather input to ModelChain.run_model method by cwhanse · Pull Request #1469 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Accept albedo in weather input to ModelChain.run_model method #1469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 21, 2022
Merged
Prev Previous commit
Next Next commit
improve coverage
  • Loading branch information
cwhanse committed Jun 13, 2022
commit b3ee1564a2e89ab2c13b2e4f1fa8ffe6203ca20c
20 changes: 11 additions & 9 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,9 +1471,10 @@ def prepare_inputs(self, weather):

Parameters
----------
weather : DataFrame, or tuple or list of DataFrame
weather : tuple or list of DataFrames
Required column names include ``'dni'``, ``'ghi'``, ``'dhi'``.
Optional column names are ``'wind_speed'``, ``'temp_air'``, ``'albedo'``.
Optional column names are ``'wind_speed'``, ``'temp_air'``,
``'albedo'``.

If optional columns ``'wind_speed'``, ``'temp_air'`` are not
provided, air temperature of 20 C and wind speed
Expand Down Expand Up @@ -1506,22 +1507,23 @@ def prepare_inputs(self, weather):
ModelChain.complete_irradiance
"""
# transfer albedo from weather to mc.system.arrays if needed
if isinstance(weather, pd.DataFrame):
if 'albedo' in weather.columns:
if len(weather) == 1: # single weather, multiple arrays
w = weather[0]
if 'albedo' in w.columns:
for array in self.system.arrays:
if hasattr(array, 'albedo'):
raise ValueError('albedo found in both weather and on'
' PVsystem.Array Provide albedo on'
' one or on neither, but not both.')
array.albedo = weather['albedo']
else: # weather is a list or tuple
for w, a in zip(weather, self.system.arrays):
array.albedo = w['albedo']
else: # multiple weather and arrays
for w, array in zip(weather, self.system.arrays):
if 'albedo' in w.columns:
if hasattr(a, 'albedo'):
if hasattr(array, 'albedo'):
raise ValueError('albedo found in both weather and on'
' PVsystem.Array Provide albedo on'
' one or on neither, but not both.')
a.albedo = w['albedo']
array.albedo = w['albedo']

weather = _to_tuple(weather)
self._check_multiple_input(weather, strict=False)
Expand Down
0