Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.6.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Bug fixes
near horizon. (:issue:`656`)
* Fixed numpy warnings in :py:func:`~pvlib.tracking.singleaxis` when
comparing NaN values to limits. (:issue:`622`)
* Change ModelChain to apply ``pvwatts_losses`` to ``mc.dc`` instead of
``mc.ac``. (:issue:`696`)


Testing
Expand All @@ -60,3 +62,4 @@ Contributors
* Todd Hendricks (:ghuser:`tahentx`)
* Kevin Anderson (:ghuser:`kevinsa5`)
* :ghuser:`bentomlinson`
* :ghuser:`yxh289`
4 changes: 2 additions & 2 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def infer_losses_model(self):

def pvwatts_losses(self):
self.losses = (100 - self.system.pvwatts_losses()) / 100.
self.ac *= self.losses
self.dc *= self.losses
return self

def no_extra_losses(self):
Expand Down Expand Up @@ -913,7 +913,7 @@ def run_model(self, times=None, weather=None):
self.effective_irradiance_model()
self.temp_model()
self.dc_model()
self.ac_model()
self.losses_model()
self.ac_model()

return self
10 changes: 9 additions & 1 deletion pvlib/test/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def test_spectral_models(system, location, spectral_model):

def constant_losses(mc):
mc.losses = 0.9
mc.ac *= mc.losses
mc.dc *= mc.losses


def test_losses_models_pvwatts(pvwatts_dc_pvwatts_ac_system, location, weather,
Expand All @@ -405,6 +405,14 @@ def test_losses_models_pvwatts(pvwatts_dc_pvwatts_ac_system, location, weather,
m.assert_called_with(age=age)
assert isinstance(mc.ac, (pd.Series, pd.DataFrame))
assert not mc.ac.empty
# check that we're applying correction to dc
# GH 696
dc_with_loss = mc.dc
mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, dc_model='pvwatts',
aoi_model='no_loss', spectral_model='no_loss',
losses_model='no_loss')
mc.run_model(weather.index, weather=weather)
assert not np.allclose(mc.dc, dc_with_loss, equal_nan=True)


def test_losses_models_ext_def(pvwatts_dc_pvwatts_ac_system, location, weather,
Expand Down