Repository: pvlib/pvlib-python (python)

Issue:
PVSystem.pvwatts_ac method does not pass eta_inv_ref to pvwatts_ac function

Pull request:
fixed bug with eta_inv_ref and temp_ref in PVSystems pvwatts methods
closes #252. 

Patch:
diff --git a/docs/sphinx/source/whatsnew/v0.4.2.txt b/docs/sphinx/source/whatsnew/v0.4.2.txt
index 0b12a56..7f9bbf3 100644
--- a/docs/sphinx/source/whatsnew/v0.4.2.txt
+++ b/docs/sphinx/source/whatsnew/v0.4.2.txt
@@ -10,7 +10,8 @@ Bug fixes
 ~~~~~~~~~
 
 * Fixed typo in __repr__ method of ModelChain and in its regarding test. (commit: b691358b)
-
+* PVSystem.pvwatts_ac could not use the eta_inv_ref kwarg and
+  PVSystem.pvwatts_dc could not use the temp_ref kwarg. Fixed. (:issue:`252`)
 
 API Changes
 ~~~~~~~~~~~
@@ -29,4 +30,5 @@ Code Contributors
 ~~~~~~~~~~~~~~~~~
 
 * Uwe Krien
+* Will Holmgren
 * Volker Beutner
diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py
index 54a053b..3086b08 100644
--- a/pvlib/pvsystem.py
+++ b/pvlib/pvsystem.py
@@ -489,9 +489,12 @@ class PVSystem(object):
 
         See :py:func:`pvwatts_dc` for details.
         """
+        kwargs = _build_kwargs(['temp_ref'], self.module_parameters)
+
         return pvwatts_dc(g_poa_effective, temp_cell,
                           self.module_parameters['pdc0'],
-                          self.module_parameters['gamma_pdc'])
+                          self.module_parameters['gamma_pdc'],
+                          **kwargs)
 
     def pvwatts_losses(self, **kwargs):
         """
@@ -512,8 +515,10 @@ class PVSystem(object):
 
         See :py:func:`pvwatts_ac` for details.
         """
-        return pvwatts_ac(pdc, self.module_parameters['pdc0'],
-                          eta_inv_nom=self.inverter_parameters['eta_inv_nom'])
+        kwargs = _build_kwargs(['eta_inv_nom', 'eta_inv_ref'],
+                               self.inverter_parameters)
+
+        return pvwatts_ac(pdc, self.module_parameters['pdc0'], **kwargs)
 
     def localize(self, location=None, latitude=None, longitude=None,
                  **kwargs):


Test patch:
diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py
index ecd7ec3..c9376d4 100644
--- a/pvlib/test/test_pvsystem.py
+++ b/pvlib/test/test_pvsystem.py
@@ -786,25 +786,38 @@ def test_pvwatts_losses_series():
     assert_series_equal(expected, out)
 
 
-def make_pvwatts_system():
+def make_pvwatts_system_defaults():
     module_parameters = {'pdc0': 100, 'gamma_pdc': -0.003}
-    inverter_parameters = {'eta_inv_nom': 0.95}
+    inverter_parameters = {}
+    system = pvsystem.PVSystem(module_parameters=module_parameters,
+                               inverter_parameters=inverter_parameters)
+    return system
+
+
+def make_pvwatts_system_kwargs():
+    module_parameters = {'pdc0': 100, 'gamma_pdc': -0.003, 'temp_ref': 20}
+    inverter_parameters = {'eta_inv_nom': 0.95, 'eta_inv_ref': 1.0}
     system = pvsystem.PVSystem(module_parameters=module_parameters,
                                inverter_parameters=inverter_parameters)
     return system
 
 
 def test_PVSystem_pvwatts_dc():
-    system = make_pvwatts_system()
+    system = make_pvwatts_system_defaults()
     irrad_trans = pd.Series([np.nan, 900, 900])
     temp_cell = pd.Series([30, np.nan, 30])
     expected = pd.Series(np.array([   nan,    nan,  88.65]))
     out = system.pvwatts_dc(irrad_trans, temp_cell)
     assert_series_equal(expected, out)
 
+    system = make_pvwatts_system_kwargs()
+    expected = pd.Series(np.array([   nan,    nan,  87.3]))
+    out = system.pvwatts_dc(irrad_trans, temp_cell)
+    assert_series_equal(expected, out)
+
 
 def test_PVSystem_pvwatts_losses():
-    system = make_pvwatts_system()
+    system = make_pvwatts_system_defaults()
     expected = pd.Series([nan, 14.934904])
     age = pd.Series([nan, 1])
     out = system.pvwatts_losses(age=age)
@@ -812,8 +825,13 @@ def test_PVSystem_pvwatts_losses():
 
 
 def test_PVSystem_pvwatts_ac():
-    system = make_pvwatts_system()
+    system = make_pvwatts_system_defaults()
     pdc = pd.Series([np.nan, 50, 100])
-    expected = pd.Series(np.array([       nan,  47.608436,  95.      ]))
+    expected = pd.Series(np.array([       nan,  48.1095776694, 96.0]))
+    out = system.pvwatts_ac(pdc)
+    assert_series_equal(expected, out)
+
+    system = make_pvwatts_system_kwargs()
+    expected = pd.Series(np.array([       nan,  45.88025, 91.5515]))
     out = system.pvwatts_ac(pdc)
     assert_series_equal(expected, out)