Skip to content

Commit 1bff19f

Browse files
Uwe KrienUwe Krien
Uwe Krien
authored and
Uwe Krien
committed
set default self.weather to None instead of empty DataFrame
1 parent 5f8ce92 commit 1bff19f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pvlib/modelchain.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def __init__(self, system, location,
317317
self.losses_model = losses_model
318318
self.orientation_strategy = orientation_strategy
319319

320-
self.weather = pd.DataFrame()
320+
self.weather = None
321321
self.times = None
322322
self.solar_position = None
323323

@@ -687,8 +687,11 @@ def prepare_inputs(self, times=None, irradiance=None, weather=None):
687687
# Add columns that does not exist and overwrite existing columns
688688
# Maybe there is a more elegant way to do this. Any ideas?
689689
if weather is not None:
690-
self.weather = self.weather.combine_first(weather)
691-
self.weather.update(weather)
690+
if self.weather is None:
691+
self.weather = weather
692+
else:
693+
self.weather = self.weather.combine_first(weather)
694+
self.weather.update(weather)
692695

693696
# The following part could be removed together with the irradiance
694697
# parameter at version v0.5 or v0.6.
@@ -713,7 +716,15 @@ def prepare_inputs(self, times=None, irradiance=None, weather=None):
713716
self.aoi = self.system.get_aoi(self.solar_position['apparent_zenith'],
714717
self.solar_position['azimuth'])
715718

716-
if not any([x in ['ghi', 'dni', 'dhi'] for x in self.weather.columns]):
719+
use_clearsky = False
720+
if self.weather is None:
721+
use_clearsky = True
722+
self.weather = pd.DataFrame()
723+
else:
724+
if not any([x in ['ghi', 'dni', 'dhi'] for x in self.weather.columns]):
725+
use_clearsky = True
726+
727+
if use_clearsky:
717728
self.weather[['ghi', 'dni', 'dhi']] = self.location.get_clearsky(
718729
self.solar_position.index, self.clearsky_model,
719730
zenith_data=self.solar_position['apparent_zenith'],

0 commit comments

Comments
 (0)