Skip to content

change MC to apply pvwatts_losses to mc.dc instead of mc.ac #704

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 4 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -47,6 +47,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`)
* Fixed a bug in the day angle equation for the ASCE
extraterrestrial irradiance model. (:issue:`211`)
* Silenced divide by 0 irradiance warnings in
Expand All @@ -70,5 +72,6 @@ Contributors
* Todd Hendricks (:ghuser:`tahentx`)
* Kevin Anderson (:ghuser:`kevinsa5`)
* :ghuser:`bentomlinson`
* :ghuser:`yxh289`
* Jonathan Gaffiot (:ghuser:`jgaffiot`)
* Leland Boeman (:ghuser: `lboeman`)
4 changes: 2 additions & 2 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,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 @@ -925,7 +925,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 @@ -388,7 +388,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 @@ -404,6 +404,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