Skip to content

Commit ab69f9a

Browse files
committed
run_model now returns self
1 parent 8c9c89d commit ab69f9a

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

docs/sphinx/source/package_overview.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,10 @@ objects to accomplish our system modeling goal:
176176
# very experimental
177177
mc = ModelChain(system, location,
178178
orientation_strategy='south_at_latitude_tilt')
179-
# optional parameters for irradiance and weather data
180-
dc, ac = mc.run_model(times)
181-
annual_energy = ac.sum()
179+
# model results (ac, dc) and intermediates (aoi, temps, etc.)
180+
# assigned as mc object attributes
181+
mc.run_model(times)
182+
annual_energy = mc.ac.sum()
182183
energies[name] = annual_energy
183184
184185
energies = pd.Series(energies)

pvlib/modelchain.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,7 @@ def run_model(self, times, irradiance=None, weather=None):
298298
299299
Returns
300300
-------
301-
output : (dc, ac)
302-
Tuple of DC power (with SAPM parameters) (DataFrame) and AC
303-
power (Series).
301+
self
304302
305303
Assigns attributes: times, solar_position, airmass, irradiance,
306304
total_irrad, weather, temps, aoi, dc, ac
@@ -346,4 +344,4 @@ def run_model(self, times, irradiance=None, weather=None):
346344

347345
self.ac = self.system.snlinverter(self.dc['v_mp'], self.dc['p_mp'])
348346

349-
return self.dc, self.ac
347+
return self

pvlib/test/test_modelchain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_run_model():
6868
system, location = mc_setup()
6969
mc = ModelChain(system, location)
7070
times = pd.date_range('20160101 1200-0700', periods=2, freq='6H')
71-
dc, ac = mc.run_model(times)
71+
ac = mc.run_model(times).ac
7272

7373
expected = pd.Series(np.array([ 1.82033564e+02, -2.00000000e-02]),
7474
index=times)
@@ -81,7 +81,7 @@ def test_run_model_with_irradiance():
8181
times = pd.date_range('20160101 1200-0700', periods=2, freq='6H')
8282
irradiance = pd.DataFrame({'dni':900, 'ghi':600, 'dhi':150},
8383
index=times)
84-
dc, ac = mc.run_model(times, irradiance=irradiance)
84+
ac = mc.run_model(times, irradiance=irradiance).ac
8585

8686
expected = pd.Series(np.array([ 1.90054749e+02, -2.00000000e-02]),
8787
index=times)
@@ -93,7 +93,7 @@ def test_run_model_with_weather():
9393
mc = ModelChain(system, location)
9494
times = pd.date_range('20160101 1200-0700', periods=2, freq='6H')
9595
weather = pd.DataFrame({'wind_speed':5, 'temp_air':10}, index=times)
96-
dc, ac = mc.run_model(times, weather=weather)
96+
ac = mc.run_model(times, weather=weather).ac
9797

9898
expected = pd.Series(np.array([ 1.99952400e+02, -2.00000000e-02]),
9999
index=times)

0 commit comments

Comments
 (0)