8000 change MC to apply pvwatts_losses to mc.dc instead of mc.ac (#704) · FlorentHaffner/pvlib-python@6946ef1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6946ef1

Browse files
authored
change MC to apply pvwatts_losses to mc.dc instead of mc.ac (pvlib#704)
* change MC to apply pvwatts_losses to mc.dc instead of mc.ac * move losses call to before ac call
1 parent 2e1c245 commit 6946ef1

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Bug fixes
4747
near horizon. (:issue:`656`)
4848
* Fixed numpy warnings in :py:func:`~pvlib.tracking.singleaxis` when
4949
comparing NaN values to limits. (:issue:`622`)
50+
* Change ModelChain to apply ``pvwatts_losses`` to ``mc.dc`` instead of
51+
``mc.ac``. (:issue:`696`)
5052
* Fixed a bug in the day angle equation for the ASCE
5153
extraterrestrial irradiance model. (:issue:`211`)
5254
* Silenced divide by 0 irradiance warnings in
@@ -70,5 +72,6 @@ Contributors
7072
* Todd Hendricks (:ghuser:`tahentx`)
7173
* Kevin Anderson (:ghuser:`kevinsa5`)
7274
* :ghuser:`bentomlinson`
75+
* :ghuser:`yxh289`
7376
* Jonathan Gaffiot (:ghuser:`jgaffiot`)
7477
* Leland Boeman (:ghuser: `lboeman`)

pvlib/modelchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ def infer_losses_model(self):
709709

710710
def pvwatts_losses(self):
711711
self.losses = (100 - self.system.pvwatts_losses()) / 100.
712-
self.ac *= self.losses
712+
self.dc *= self.losses
713713
return self
714714

715715
def no_extra_losses(self):
@@ -925,7 +925,7 @@ def run_model(self, times=None, weather=None):
925925
self.effective_irradiance_model()
926926
self.temp_model()
927927
self.dc_model()
928-
self.ac_model()
929928
self.losses_model()
929+
self.ac_model()
930930

931931
return self

pvlib/test/test_modelchain.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def test_spectral_models(system, location, spectral_model):
388388

389389
def constant_losses(mc):
390390
mc.losses = 0.9
391-
mc.ac *= mc.losses
391+
mc.dc *= mc.losses
392392

393393

394394
def test_losses_models_pvwatts(pvwatts_dc_pvwatts_ac_system, location, weather,
@@ -404,6 +404,14 @@ def test_losses_models_pvwatts(pvwatts_dc_pvwatts_ac_system, location, weather,
404404
m.assert_called_with(age=age)
405405
assert isinstance(mc.ac, (pd.Series, pd.DataFrame))
406406
assert not mc.ac.empty
407+
# check that we're applying correction to dc
408+
# GH 696
409+
dc_with_loss = mc.dc
410+
mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, dc_model='pvwatts',
411+
aoi_model='no_loss', spectral_model='no_loss',
412+
losses_model='no_loss')
413+
mc.run_model(weather.index, weather=weather)
414+
assert not np.allclose(mc.dc, dc_with_loss, equal_nan=True)
407415

408416

409417
def test_losses_models_ext_def(pvwatts_dc_pvwatts_ac_system, location, weather,

0 commit comments

Comments
 (0)
0