From d9960144817db19fe586f70341e93152573a43d1 Mon Sep 17 00:00:00 2001 From: Will Holmgren Date: Fri, 23 Aug 2019 10:39:01 -0700 Subject: [PATCH 1/2] fix documentation --- docs/sphinx/source/api.rst | 1 - docs/sphinx/source/clearsky.rst | 6 +-- docs/sphinx/source/forecasts.rst | 11 +++-- docs/sphinx/source/introexamples.rst | 20 +++++---- docs/sphinx/source/modelchain.rst | 61 ++++++++++++++++++++------ docs/sphinx/source/whatsnew/v0.7.0.rst | 27 +++++++----- pvlib/temperature.py | 33 ++++++++++---- 7 files changed, 108 insertions(+), 51 deletions(-) diff --git a/docs/sphinx/source/api.rst b/docs/sphinx/source/api.rst index 176e0f6a65..d65992f61f 100644 --- a/docs/sphinx/source/api.rst +++ b/docs/sphinx/source/api.rst @@ -268,7 +268,6 @@ Functions relevant for the SAPM model. pvsystem.sapm pvsystem.sapm_effective_irradiance - pvsystem.sapm_celltemp pvsystem.sapm_spectral_loss pvsystem.sapm_aoi_loss pvsystem.snlinverter diff --git a/docs/sphinx/source/clearsky.rst b/docs/sphinx/source/clearsky.rst index c47212f42b..669ca07ca0 100644 --- a/docs/sphinx/source/clearsky.rst +++ b/docs/sphinx/source/clearsky.rst @@ -68,7 +68,7 @@ returns a :py:class:`pandas.DataFrame`. In [1]: tus = Location(32.2, -111, 'US/Arizona', 700, 'Tucson') - In [1]: times = pd.DatetimeIndex(start='2016-07-01', end='2016-07-04', freq='1min', tz=tus.tz) + In [1]: times = pd.date_range(start='2016-07-01', end='2016-07-04', freq='1min', tz=tus.tz) In [1]: cs = tus.get_clearsky(times) # ineichen with climatology table by default @@ -168,7 +168,7 @@ varies from 300 m to 1500 m. .. ipython:: - In [1]: times = pd.DatetimeIndex(start='2015-01-01', end='2016-01-01', freq='1D') + In [1]: times = pd.date_range(start='2015-01-01', end='2016-01-01', freq='1D') In [1]: sites = [(32, -111, 'Tucson1'), (32.2, -110.9, 'Tucson2'), ...: (33.5, -112.1, 'Phoenix'), (35.1, -106.6, 'Albuquerque')] @@ -608,7 +608,7 @@ GHI data. We first generate and plot the clear sky and measured data. abq = Location(35.04, -106.62, altitude=1619) - times = pd.DatetimeIndex(start='2012-04-01 10:30:00', tz='Etc/GMT+7', periods=30, freq='1min') + times = pd.date_range(start='2012-04-01 10:30:00', tz='Etc/GMT+7', periods=30, freq='1min') cs = abq.get_clearsky(times) diff --git a/docs/sphinx/source/forecasts.rst b/docs/sphinx/source/forecasts.rst index f959982e2c..56e88acf74 100644 --- a/docs/sphinx/source/forecasts.rst +++ b/docs/sphinx/source/forecasts.rst @@ -440,6 +440,7 @@ for details. .. ipython:: python from pvlib.pvsystem import PVSystem, retrieve_sam + from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS from pvlib.tracking import SingleAxisTracker from pvlib.modelchain import ModelChain @@ -447,12 +448,10 @@ for details. cec_inverters = retrieve_sam('cecinverter') module = sandia_modules['Canadian_Solar_CS5P_220M___2009_'] inverter = cec_inverters['SMA_America__SC630CP_US_315V__CEC_2012_'] + temperature_model_parameters = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass'] # model a big tracker for more fun - system = SingleAxisTracker(module_parameters=module, - inverter_parameters=inverter, - modules_per_string=15, - strings_per_inverter=300) + system = SingleAxisTracker(module_parameters=module, inverter_parameters=inverter, temperature_model_parameters=temperature_model_parameters, modules_per_string=15, strings_per_inverter=300) # fx is a common abbreviation for forecast fx_model = GFS() @@ -480,9 +479,9 @@ Here's the forecast plane of array irradiance... .. ipython:: python - mc.temps.plot(); + mc.cell_temperature.plot(); @savefig pv_temps.png width=6in - plt.ylabel('Temperature (C)'); + plt.ylabel('Cell Temperature (C)'); @suppress plt.close(); diff --git a/docs/sphinx/source/introexamples.rst b/docs/sphinx/source/introexamples.rst index 6cd0d54f63..e1b01d94ca 100644 --- a/docs/sphinx/source/introexamples.rst +++ b/docs/sphinx/source/introexamples.rst @@ -30,7 +30,7 @@ configuration at a handful of sites listed below. import pandas as pd import matplotlib.pyplot as plt - naive_times = pd.DatetimeIndex(start='2015', end='2016', freq='1h') + naive_times = pd.date_range(start='2015', end='2016', freq='1h') # very approximate # latitude, longitude, name, altitude, timezone @@ -46,6 +46,7 @@ configuration at a handful of sites listed below. sapm_inverters = pvlib.pvsystem.retrieve_sam('cecinverter') module = sandia_modules['Canadian_Solar_CS5P_220M___2009_'] inverter = sapm_inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'] + temperature_model_parameters = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass'] # specify constant ambient air temp and wind for simplicity temp_air = 20 @@ -88,12 +89,13 @@ to accomplish our system modeling goal: cs['dni'], cs['ghi'], cs['dhi'], dni_extra=dni_extra, model='haydavies') - temps = pvlib.pvsystem.sapm_celltemp(total_irrad['poa_global'], - wind_speed, temp_air) + tcell = pvlib.temperature.sapm_cell(total_irrad['poa_global'], + temp_air, wind_speed, + **temperature_model_parameters) effective_irradiance = pvlib.pvsystem.sapm_effective_irradiance( total_irrad['poa_direct'], total_irrad['poa_diffuse'], am_abs, aoi, module) - dc = pvlib.pvsystem.sapm(effective_irradiance, temps['temp_cell'], module) + dc = pvlib.pvsystem.sapm(effective_irradiance, tcell, module) ac = pvlib.pvsystem.snlinverter(dc['v_mp'], dc['p_mp'], inverter) annual_energy = ac.sum() energies[name] = annual_energy @@ -149,7 +151,8 @@ by examining the parameters defined for the module. from pvlib.modelchain import ModelChain system = PVSystem(module_parameters=module, - inverter_parameters=inverter) + inverter_parameters=inverter, + temperature_model_parameters=temperature_model_parameters) energies = {} for latitude, longitude, name, altitude, timezone in coordinates: @@ -214,6 +217,7 @@ modeling goal: for latitude, longitude, name, altitude, timezone in coordinates: localized_system = LocalizedPVSystem(module_parameters=module, inverter_parameters=inverter, + temperature_model_parameters=temperature_model_parameters, surface_tilt=latitude, surface_azimuth=180, latitude=latitude, @@ -229,15 +233,15 @@ modeling goal: clearsky['dni'], clearsky['ghi'], clearsky['dhi']) - temps = localized_system.sapm_celltemp(total_irrad['poa_global'], - wind_speed, temp_air) + tcell = localized_system.sapm_celltemp(total_irrad['poa_global'], + temp_air, wind_speed) aoi = localized_system.get_aoi(solar_position['apparent_zenith'], solar_position['azimuth']) airmass = localized_system.get_airmass(solar_position=solar_position) effective_irradiance = localized_system.sapm_effective_irradiance( total_irrad['poa_direct'], total_irrad['poa_diffuse'], airmass['airmass_absolute'], aoi) - dc = localized_system.sapm(effective_irradiance, temps['temp_cell']) + dc = localized_system.sapm(effective_irradiance, tcell) ac = localized_system.snlinverter(dc['v_mp'], dc['p_mp']) annual_energy = ac.sum() energies[name] = annual_energy diff --git a/docs/sphinx/source/modelchain.rst b/docs/sphinx/source/modelchain.rst index 1b324801b3..9501dff1d4 100644 --- a/docs/sphinx/source/modelchain.rst +++ b/docs/sphinx/source/modelchain.rst @@ -45,6 +45,8 @@ objects, module data, and inverter data. from pvlib.pvsystem import PVSystem from pvlib.location import Location from pvlib.modelchain import ModelChain + from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS + temperature_model_parameters = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass'] # load some module and inverter specifications sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod') @@ -61,7 +63,8 @@ object. location = Location(latitude=32.2, longitude=-110.9) system = PVSystem(surface_tilt=20, surface_azimuth=200, module_parameters=sandia_module, - inverter_parameters=cec_inverter) + inverter_parameters=cec_inverter, + temperature_model_parameters=temperature_model_parameters) mc = ModelChain(system, location) Printing a ModelChain object will display its models. @@ -87,6 +90,10 @@ examples are shown below. mc.aoi +.. ipython:: python + + mc.cell_temperature + .. ipython:: python mc.dc @@ -141,8 +148,11 @@ model, AC model, AOI loss model, and spectral loss model. .. ipython:: python - sapm_system = PVSystem(module_parameters=sandia_module, inverter_parameters=cec_inverter) - mc = ModelChain(system, location) + sapm_system = PVSystem( + module_parameters=sandia_module, + inverter_parameters=cec_inverter, + temperature_model_parameters=temperature_model_parameters) + mc = ModelChain(sapm_system, location) print(mc) .. ipython:: python @@ -160,7 +170,10 @@ information to determine which of those models to choose. .. ipython:: python - pvwatts_system = PVSystem(module_parameters={'pdc0': 240, 'gamma_pdc': -0.004}) + pvwatts_system = PVSystem( + module_parameters={'pdc0': 240, 'gamma_pdc': -0.004}, + inverter_parameters={'pdc0': 240}, + temperature_model_parameters=temperature_model_parameters) mc = ModelChain(pvwatts_system, location, aoi_model='physical', spectral_model='no_loss') print(mc) @@ -176,8 +189,11 @@ functions for a PVSystem that contains SAPM-specific parameters. .. ipython:: python - sapm_system = PVSystem(module_parameters=sandia_module, inverter_parameters=cec_inverter) - mc = ModelChain(system, location, aoi_model='physical', spectral_model='no_loss') + sapm_system = PVSystem( + module_parameters=sandia_module, + inverter_parameters=cec_inverter, + temperature_model_parameters=temperature_model_parameters) + mc = ModelChain(sapm_system, location, aoi_model='physical', spectral_model='no_loss') print(mc) .. ipython:: python @@ -264,21 +280,24 @@ the ModelChain.pvwatts_dc method is shown below. Its only argument is The ModelChain.pvwatts_dc method calls the pvwatts_dc method of the PVSystem object that we supplied using data that is stored in its own -``effective_irradiance`` and ``temps`` attributes. Then it assigns the +``effective_irradiance`` and ``cell_temperature`` attributes. Then it assigns the result to the ``dc`` attribute of the ModelChain object. The code below shows a simple example of this. .. ipython:: python # make the objects - pvwatts_system = PVSystem(module_parameters={'pdc0': 240, 'gamma_pdc': -0.004}) + pvwatts_system = PVSystem( + module_parameters={'pdc0': 240, 'gamma_pdc': -0.004}, + inverter_parameters={'pdc0': 240}, + temperature_model_parameters=temperature_model_parameters) mc = ModelChain(pvwatts_system, location, aoi_model='no_loss', spectral_model='no_loss') # manually assign data to the attributes that ModelChain.pvwatts_dc will need. # for standard workflows, run_model would assign these attributes. mc.effective_irradiance = pd.Series(1000, index=[pd.Timestamp('20170401 1200-0700')]) - mc.temps = pd.DataFrame({'temp_cell': 50, 'temp_module': 50}, index=[pd.Timestamp('20170401 1200-0700')]) + mc.cell_temperature = pd.Series(50, index=[pd.Timestamp('20170401 1200-0700')]) # run ModelChain.pvwatts_dc and look at the result mc.pvwatts_dc(); @@ -304,13 +323,16 @@ PVSystem.scale_voltage_current_power method. .. ipython:: python # make the objects - sapm_system = PVSystem(module_parameters=sandia_module, inverter_parameters=cec_inverter) + sapm_system = PVSystem( + module_parameters=sandia_module, + inverter_parameters=cec_inverter, + temperature_model_parameters=temperature_model_parameters) mc = ModelChain(sapm_system, location) # manually assign data to the attributes that ModelChain.sapm will need. # for standard workflows, run_model would assign these attributes. mc.effective_irradiance = pd.Series(1000, index=[pd.Timestamp('20170401 1200-0700')]) - mc.temps = pd.DataFrame({'temp_cell': 50, 'temp_module': 50}, index=[pd.Timestamp('20170401 1200-0700')]) + mc.cell_temperature = pd.Series(50, index=[pd.Timestamp('20170401 1200-0700')]) # run ModelChain.sapm and look at the result mc.sapm(); @@ -333,7 +355,10 @@ section. .. ipython:: python - pvwatts_system = PVSystem(module_parameters={'pdc0': 240, 'gamma_pdc': -0.004}) + pvwatts_system = PVSystem( + module_parameters={'pdc0': 240, 'gamma_pdc': -0.004}, + inverter_parameters={'pdc0': 240}, + temperature_model_parameters=temperature_model_parameters) mc = ModelChain(pvwatts_system, location, aoi_model='no_loss', spectral_model='no_loss') mc.dc_model.__func__ @@ -403,18 +428,26 @@ function if you wanted to. return mc - def pvusa_ac_mc_wrapper(mc): + def pvusa_ac_mc(mc): # keep it simple mc.ac = mc.dc return mc + + def no_loss_temperature(mc): + # keep it simple + mc.cell_temperature = mc.weather['temp_air'] + return mc + + .. ipython:: python module_parameters = {'a': 0.2, 'b': 0.00001, 'c': 0.001, 'd': -0.00005} pvusa_system = PVSystem(module_parameters=module_parameters) mc = ModelChain(pvusa_system, location, - dc_model=pvusa_mc_wrapper, ac_model=pvusa_ac_mc_wrapper, + dc_model=pvusa_mc_wrapper, ac_model=pvusa_ac_mc, + temp_model=no_loss_temperature, aoi_model='no_loss', spectral_model='no_loss') A ModelChain object uses Python’s functools.partial function to assign diff --git a/docs/sphinx/source/whatsnew/v0.7.0.rst b/docs/sphinx/source/whatsnew/v0.7.0.rst index 30b9294cf5..21edb22246 100644 --- a/docs/sphinx/source/whatsnew/v0.7.0.rst +++ b/docs/sphinx/source/whatsnew/v0.7.0.rst @@ -1,7 +1,7 @@ .. _whatsnew_0700: v0.7.0 (MONTH DAY, YEAR) ---------------------- +------------------------ This is a major release that drops support for Python 2 and Python 3.4. We recommend all users of v0.6.3 upgrade to this release after checking API @@ -12,9 +12,8 @@ compatibility notes. API Changes ~~~~~~~~~~~ -* Changes to functions and methods for cell temperature models: - (:issue:`678') - - Moved functions for cell temperature and constant +* Changes to functions and methods for cell temperature models (:issue:`678`): + - Moved functions for cell temperature and constant `TEMP_MODEL_PARAMS` from `pvsystem.py` to `temperature.py`. - Renamed `pvsystem.sapm_celltemp` and `pvsystem.pvsyst_celltemp` to `temperature.sapm_cell` and `temperature.pvsyst_cell`. @@ -27,20 +26,28 @@ API Changes `temperature.pvsyst_cell`. These functions now require model-specific parameters as kwargs. - Renamed `pvsystem.TEMP_MODEL_PARAMS` to `temperature.TEMPERATURE_MODEL_PARAMETERS`. - - `temperature.TEMPERATURE_MODEL_PARAMETERS` uses dict rather than tuple for a parameter set. dict keys for `temperature.TEMPERATURE_MODEL_PARAMETERS` have changed. - - Parameter sets for the SAPM cell temperature model named 'open_rack_polymer_thinfilm_steel' and '22x_concentrator_tracker' are considered obsolete and have been removed. + - `temperature.TEMPERATURE_MODEL_PARAMETERS` uses dict rather than + tuple for a parameter set. dict keys for + `temperature.TEMPERATURE_MODEL_PARAMETERS` have changed. + - Parameter sets for the SAPM cell temperature model named + 'open_rack_polymer_thinfilm_steel' and '22x_concentrator_tracker' + are considered obsolete and have been removed. - Added attribute `PVSystem.module_type` (str) to record module front and back materials, default is `glass_polymer`. - Added attribute `PVSystem.temperature_model_parameters` (dict) to contain temperature model parameters. - Changed meaning of `PVSystem.racking_model` to describe racking only, e.g., default is `open_rack`. - - In `PVSystem.sapm_celltemp` and `PVSystem.pvsyst_celltemp`, changed kwarg `model` to `parameter_set`. `parameter_set` expects a str which is a valid key for `temperature.TEMPERATURE_MODEL_PARAMETERS` for the corresponding temperature model. + - In `PVSystem.sapm_celltemp` and `PVSystem.pvsyst_celltemp`, + changed kwarg `model` to `parameter_set`. `parameter_set` expects + a str which is a valid key for + `temperature.TEMPERATURE_MODEL_PARAMETERS` for the corresponding + temperature model. - Implemented `pvsyst` as an option for `ModelChain.temp_model`. - `ModelChain.temp_model` now defaults to `None`. The temperature - model can be inferred from - `PVSystem.temperature_model_parameters`. - - `modelchain.basic_chain` has a new required argument `temperature_model_parameters`. + model can be inferred from `PVSystem.temperature_model_parameters`. + - `modelchain.basic_chain` has a new required argument + `temperature_model_parameters`. Enhancements ~~~~~~~~~~~~ diff --git a/pvlib/temperature.py b/pvlib/temperature.py index 6db0b15a0e..ac77850dc6 100644 --- a/pvlib/temperature.py +++ b/pvlib/temperature.py @@ -56,7 +56,8 @@ def sapm_cell(poa_global, temp_air, wind_speed, a, b, deltaT, Parameter :math:`\Delta T` in :eq:`sapm2` [C]. irrad_ref : float, default 1000 - Reference irradiance, parameter :math:`E_{0}` in :eq:`sapm2` [W/m^2]. + Reference irradiance, parameter :math:`E_{0}` in + :eq:`sapm2` [W/m^2]. Returns ------- @@ -70,21 +71,21 @@ def sapm_cell(poa_global, temp_air, wind_speed, a, b, deltaT, .. math:: :label: sapm1 - T_{m} = E \times \exp (a + b \times WS) + T_{a} + T_{m} = E \times \exp (a + b \times WS) + T_{a} .. math:: :label: sapm2 - T_{C} = T_{m} + \frac{E}{E_{0}} \Delta T + T_{C} = T_{m} + \frac{E}{E_{0}} \Delta T The module back surface temperature :math:`T_{m}` is implemented in - ``cell_temperature.sapm_module``. + :py:func:`~pvlib.temperature.sapm_module`. Inputs to the model are plane-of-array irradiance :math:`E` (W/m2) and ambient air temperature :math:`T_{a}` (C). Model parameters depend both on the module construction and its mounting. Parameter sets are provided in [1] for representative modules and mounting, and are coded for convenience - in ``cell_temperature.TEMPERATURE_MODEL_PARAMETERS``. + in ``pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS``. +---------------+----------------+-------+---------+---------------------+ | Module | Mounting | a | b | :math:`\Delta T [C]`| @@ -104,6 +105,12 @@ def sapm_cell(poa_global, temp_air, wind_speed, a, b, deltaT, Model", SAND Report 3535, Sandia National Laboratories, Albuquerque, NM. + Examples + -------- + >>> from pvlib.temperature import sapm_cell, TEMPERATURE_MODEL_PARAMETERS + >>> params = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass'] + >>> sapm_cell(1000, 10, 0, **params) + 44.11703066106086 ''' module_temperature = sapm_module(poa_global, temp_air, wind_speed, a, b) @@ -127,10 +134,10 @@ def sapm_module(poa_global, temp_air, wind_speed, a, b): Wind speed at a height of 10 meters [m/s]. a : float - Parameter :math:`a` in :eq:`sapm1`. + Parameter :math:`a` in :eq:`sapm1mod`. b : float - Parameter :math:`b` in :eq:`sapm1`. + Parameter :math:`b` in :eq:`sapm1mod`. Returns ------- @@ -141,8 +148,9 @@ def sapm_module(poa_global, temp_air, wind_speed, a, b): The model for module temperature :math:`T_{m}` is given by Eq. 11 in [1]. .. math:: - :label: sapm1 - T_{m} = E \times \exp (a + b \times WS) + T_{a} + :label: sapm1mod + + T_{m} = E \times \exp (a + b \times WS) + T_{a} Inputs to the model are plane-of-array irradiance :math:`E` (W/m2) and ambient air temperature :math:`T_{a}` (C). Model outputs are surface @@ -245,6 +253,13 @@ def pvsyst_cell(poa_global, temp_air, wind_speed=1.0, u_c=29.0, u_v=0.0, [2] Faiman, D. (2008). "Assessing the outdoor operating temperature of photovoltaic modules." Progress in Photovoltaics 16(4): 307-315. + + Examples + -------- + >>> from pvlib.temperature import pvsyst_cell, TEMPERATURE_MODEL_PARAMETERS + >>> params = TEMPERATURE_MODEL_PARAMETERS['pvsyst']['freestanding'] + >>> pvsyst_cell(1000, 10, **params) + 37.93103448275862 """ total_loss_factor = u_c + u_v * wind_speed From 4d58361319b0d2a1687e3c06cc37e41516bd1908 Mon Sep 17 00:00:00 2001 From: Will Holmgren Date: Fri, 23 Aug 2019 11:02:39 -0700 Subject: [PATCH 2/2] fix infer_temp_model naming, whatsnew --- docs/sphinx/source/api.rst | 4 ++-- docs/sphinx/source/modelchain.rst | 2 +- docs/sphinx/source/whatsnew/v0.7.0.rst | 19 ++++++------------- pvlib/modelchain.py | 8 ++++---- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/docs/sphinx/source/api.rst b/docs/sphinx/source/api.rst index d65992f61f..8af2bf0f40 100644 --- a/docs/sphinx/source/api.rst +++ b/docs/sphinx/source/api.rst @@ -484,7 +484,7 @@ ModelChain properties that are aliases for your specific modeling functions. modelchain.ModelChain.ac_model modelchain.ModelChain.aoi_model modelchain.ModelChain.spectral_model - modelchain.ModelChain.temp_model + modelchain.ModelChain.temperature_model modelchain.ModelChain.losses_model modelchain.ModelChain.effective_irradiance_model @@ -529,7 +529,7 @@ on the information in the associated :py:class:`~pvsystem.PVSystem` object. modelchain.ModelChain.infer_ac_model modelchain.ModelChain.infer_aoi_model modelchain.ModelChain.infer_spectral_model - modelchain.ModelChain.infer_temp_model + modelchain.ModelChain.infer_temperature_model modelchain.ModelChain.infer_losses_model Functions diff --git a/docs/sphinx/source/modelchain.rst b/docs/sphinx/source/modelchain.rst index 9501dff1d4..4025451cda 100644 --- a/docs/sphinx/source/modelchain.rst +++ b/docs/sphinx/source/modelchain.rst @@ -447,7 +447,7 @@ function if you wanted to. mc = ModelChain(pvusa_system, location, dc_model=pvusa_mc_wrapper, ac_model=pvusa_ac_mc, - temp_model=no_loss_temperature, + temperature_model=no_loss_temperature, aoi_model='no_loss', spectral_model='no_loss') A ModelChain object uses Python’s functools.partial function to assign diff --git a/docs/sphinx/source/whatsnew/v0.7.0.rst b/docs/sphinx/source/whatsnew/v0.7.0.rst index 6226fa1603..48ceaf6d4d 100644 --- a/docs/sphinx/source/whatsnew/v0.7.0.rst +++ b/docs/sphinx/source/whatsnew/v0.7.0.rst @@ -27,14 +27,12 @@ API Changes - Added the argument `irrad_ref`, default value 1000, to `temperature.sapm_cell`. - Renamed `pvsystem.TEMP_MODEL_PARAMS` to `temperature.TEMPERATURE_MODEL_PARAMETERS`. - `temperature.TEMPERATURE_MODEL_PARAMETERS` uses dict rather than - tuple for a parameter set. dict keys for - `temperature.TEMPERATURE_MODEL_PARAMETERS` have changed. + tuple for a parameter set. + - Parameter set names for `temperature.TEMPERATURE_MODEL_PARAMETERS` have changed. - Parameter sets for the SAPM cell temperature model named 'open_rack_polymer_thinfilm_steel' and '22x_concentrator_tracker' are considered obsolete and have been removed. - `temperature.TEMPERATURE_MODEL_PARAMETERS` uses dict rather than tuple for a parameter set. - - Parameter set names for `temperature.TEMPERATURE_MODEL_PARAMETERS` have changed. - - Parameter sets for the SAPM cell temperature model named 'open_rack_polymer_thinfilm_steel' and '22x_concentrator_tracker' are considered obsolete and have been removed. - Added attribute `PVSystem.module_type` (str) to record module front and back materials, default is `glass_polymer`. - Added attribute `PVSystem.temperature_model_parameters` (dict) @@ -46,18 +44,13 @@ API Changes a str which is a valid key for `temperature.TEMPERATURE_MODEL_PARAMETERS` for the corresponding temperature model. - - Implemented `pvsyst` as an option for `ModelChain.temp_model`. - - `ModelChain.temp_model` now defaults to `None`. The temperature + - `ModelChain.temp_model` renamed to `ModelChain.temperature_model`. + - `ModelChain.temperature_model` now defaults to `None`. The temperature model can be inferred from `PVSystem.temperature_model_parameters`. + - Implemented `pvsyst` as an option for `ModelChain.temperature_model`. - `modelchain.basic_chain` has a new required argument `temperature_model_parameters`. - - In `PVSystem.sapm_celltemp` and `PVSystem.pvsyst_celltemp`, changed kwarg `model` to `parameter_set`. `parameter_set` expects a str which is a valid key for `temperature.TEMPERATURE_MODEL_PARAMETERS` for the corresponding temperature model. - - `ModelChain.temp_model` renamed to `ModelChain.temperature_model`. - - Implemented `pvsyst` as an option for `ModelChain.temperature_model`. - - `ModelChain.temperature_model` now defaults to `None`. The temperature - model can be inferred from - `PVSystem.temperature_model_parameters`. - - `modelchain.basic_chain` has a new required argument `temperature_model_parameters`. + Enhancements ~~~~~~~~~~~~ diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index 3da8b3aa35..f11884fc1b 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -304,8 +304,7 @@ def __init__(self, system, location, solar_position_method='nrel_numpy', airmass_model='kastenyoung1989', dc_model=None, ac_model=None, aoi_model=None, - spectral_model=None, temp_model=None, - temperature_model=None, + spectral_model=None, temperature_model=None, losses_model='no_loss', name=None, **kwargs): self.name = name @@ -323,6 +322,7 @@ def __init__(self, system, location, self.spectral_model = spectral_model # TODO: deprecated kwarg temp_model. Remove in v0.8 + temp_model = kwargs.pop('temp_model', None) if temp_model is not None: warnings.warn('The temp_model keyword argument is deprecated. Use ' 'temperature_model instead', pvlibDeprecationWarning) @@ -690,7 +690,7 @@ def temperature_model(self): @temperature_model.setter def temperature_model(self, model): if model is None: - self._temperature_model = self.infer_temp_model() + self._temperature_model = self.infer_temperature_model() elif isinstance(model, str): model = model.lower() if model == 'sapm': @@ -702,7 +702,7 @@ def temperature_model(self, model): else: self._temperature_model = partial(model, self) - def infer_temp_model(self): + def infer_temperature_model(self): params = set(self.system.temperature_model_parameters.keys()) if set(['a', 'b', 'deltaT']) <= params: return self.sapm_temp