Skip to content
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

Comply with pv-terms #185

Merged
merged 24 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cf22340
first pass at pvterms compat
kandersolar Jul 7, 2020
1061de9
changes from discussion with mike
kandersolar Jul 24, 2020
77d729f
missed some docs changes
kandersolar Jul 24, 2020
0fde137
change back to `gamma_pdc`
mdeceglie Jul 29, 2020
aef3ad6
docstring update power->energy
mdeceglie Jul 29, 2020
5e09d86
Capitalize Celsius
mdeceglie Jul 29, 2020
bb0e073
dc_power to power_dc (local variable)
mdeceglie Jul 29, 2020
5d99491
modeled_irrad to irrad_sim
mdeceglie Jul 29, 2020
9fb16d5
1time_series` to `power`
mdeceglie Jul 29, 2020
9a92d92
add simultated to docstring
mdeceglie Jul 29, 2020
63430b1
update test with gamma_pdc
mdeceglie Jul 29, 2020
1dc8e6a
Fix failing tests
mdeceglie Jul 29, 2020
28bb126
Update soiling attributes
mdeceglie Jul 30, 2020
f31ef95
pvwatts kwargs docstring update
mdeceglie Jul 30, 2020
e579f87
Updated example notebooks: 'pdc' = 'P_ref'; 'tempco' = 'gamma_pdc'; '…
cdeline Jul 30, 2020
d8b9c8b
Pandas > 1.0 requires explicit registering of matplotlib converters.
cdeline Jul 30, 2020
8b012ab
update normalize_with_pvwatts keywords. Pref-> power_dc_rated.
cdeline Jul 31, 2020
cbd60d1
power_dc_rated
cdeline Jul 31, 2020
2761a97
clearsky_pvwatts_kws updated
cdeline Jul 31, 2020
d7df0ed
Add sphinx requirements to requirements.txt
cdeline Jul 31, 2020
101ebe6
Update API example in index.rst. Add #185 updates to whatsnew
cdeline Jul 31, 2020
3c9bfeb
Add specific kwarg values that have changed
cdeline Jul 31, 2020
d3c9097
Remove 'new' functions from the list of API changes since they didn't…
cdeline Jul 31, 2020
9a530ad
Minor Sphinx compile warning fix for sub-nested list
cdeline Jul 31, 2020
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
35 changes: 19 additions & 16 deletions docs/degradation_and_soiling_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
" 'figure.figsize': [4.5, 3],\n",
" 'lines.markeredgewidth': 0,\n",
" 'lines.markersize': 2\n",
" })"
" })\n",
"# Register time series plotting in pandas > 1.0\n",
"from pandas.plotting import register_matplotlib_converters\n",
"register_matplotlib_converters()"
]
},
{
Expand Down Expand Up @@ -111,7 +114,7 @@
" pass # Python 3 strings are already unicode literals\n",
"df = df.rename(columns = {\n",
" u'12 BP Solar - Active Power (kW)':'power',\n",
" u'12 BP Solar - Wind Speed (m/s)': 'wind',\n",
" u'12 BP Solar - Wind Speed (m/s)': 'wind_speed',\n",
" u'12 BP Solar - Weather Temperature Celsius (\\xb0C)': 'Tamb',\n",
" u'12 BP Solar - Global Horizontal Radiation (W/m\\xb2)': 'ghi',\n",
" u'12 BP Solar - Diffuse Horizontal Radiation (W/m\\xb2)': 'dhi'\n",
Expand All @@ -121,10 +124,10 @@
"meta = {\"latitude\": -23.762028,\n",
" \"longitude\": 133.874886,\n",
" \"timezone\": 'Australia/North',\n",
" \"tempco\": -0.005,\n",
" \"gamma_pdc\": -0.005,\n",
" \"azimuth\": 0,\n",
" \"tilt\": 20,\n",
" \"pdc\": 5100.0,\n",
" \"power_dc_rated\": 5100.0,\n",
" \"temp_model_params\": pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer']}\n",
"\n",
"df.index = pd.to_datetime(df.Timestamp)\n",
Expand Down Expand Up @@ -162,7 +165,7 @@
"df['poa'] = beam + sky\n",
"\n",
"# Calculate cell temperature\n",
"df['Tcell'] = pvlib.temperature.sapm_cell(df.poa, df.Tamb, df.wind, **meta['temp_model_params'])\n",
"df['Tcell'] = pvlib.temperature.sapm_cell(df.poa, df.Tamb, df.wind_speed, **meta['temp_model_params'])\n",
"\n",
"# plot the AC power time series\n",
"fig, ax = plt.subplots(figsize=(4,3))\n",
Expand Down Expand Up @@ -200,11 +203,11 @@
"source": [
"# Specify the keywords for the pvwatts model\n",
"pvwatts_kws = {\"poa_global\" : df.poa,\n",
" \"P_ref\" : meta['pdc'],\n",
" \"T_cell\" : df.Tcell,\n",
" \"G_ref\" : 1000,\n",
" \"T_ref\": 25,\n",
" \"gamma_pdc\" : meta['tempco']}\n",
" \"power_dc_rated\" : meta['power_dc_rated'],\n",
" \"temperature_cell\" : df.Tcell,\n",
" \"poa_global_ref\" : 1000,\n",
" \"temperature_cell_ref\": 25,\n",
" \"gamma_pdc\" : meta['gamma_pdc']}\n",
"\n",
"# Calculate the normaliztion, the function also returns the relevant insolation for\n",
"# each point in the normalized PV energy timeseries\n",
Expand Down Expand Up @@ -680,11 +683,11 @@
"outputs": [],
"source": [
"clearsky_pvwatts_kws = {\"poa_global\" : df.clearsky_poa,\n",
" \"P_ref\" : meta['pdc'],\n",
" \"T_cell\" :df.clearsky_Tcell,\n",
" \"G_ref\" : 1000,\n",
" \"T_ref\": 25,\n",
" \"gamma_pdc\" : meta['tempco']}\n",
" \"power_dc_rated\" : meta['power_dc_rated'],\n",
" \"temperature_cell\" :df.clearsky_Tcell,\n",
" \"poa_global_ref\" : 1000,\n",
" \"temperature_cell_ref\": 25,\n",
" \"gamma_pdc\" : meta['gamma_pdc']}\n",
"\n",
"clearsky_normalized, clearsky_insolation = rdtools.normalize_with_pvwatts(df.energy, clearsky_pvwatts_kws)\n",
"\n",
Expand Down Expand Up @@ -823,7 +826,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
31 changes: 17 additions & 14 deletions docs/degradation_and_soiling_example_pvdaq_4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
" 'figure.figsize': [4.5, 3],\n",
" 'lines.markeredgewidth': 0,\n",
" 'lines.markersize': 2\n",
" })"
" })\n",
"# Register time series plotting in pandas > 1.0\n",
"from pandas.plotting import register_matplotlib_converters\n",
"register_matplotlib_converters()"
]
},
{
Expand Down Expand Up @@ -111,8 +114,8 @@
" df.to_pickle(cache_file)\n",
"\n",
"df = df.rename(columns = {\n",
" 'ac_power':'power',\n",
" 'wind_speed': 'wind',\n",
" 'ac_power':'power_ac',\n",
" 'wind_speed': 'wind_speed',\n",
" 'ambient_temp': 'Tamb',\n",
" 'poa_irradiance': 'poa',\n",
"})\n",
Expand All @@ -121,10 +124,10 @@
"meta = {\"latitude\": 39.7406,\n",
" \"longitude\": -105.1774,\n",
" \"timezone\": 'Etc/GMT+7',\n",
" \"tempco\": -0.005,\n",
" \"gamma_pdc\": -0.005,\n",
" \"azimuth\": 180,\n",
" \"tilt\": 40,\n",
" \"pdc\": 1000.0,\n",
" \"power_dc_rated\": 1000.0,\n",
" \"temp_model_params\":\n",
" pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer']}\n",
"\n",
Expand All @@ -146,11 +149,11 @@
"\n",
"# Calculate cell temperature\n",
"df['Tcell'] = pvlib.temperature.sapm_cell(df.poa, df.Tamb,\n",
" df.wind, **meta['temp_model_params'])\n",
" df.wind_speed, **meta['temp_model_params'])\n",
"\n",
"# plot the AC power time series\n",
"fig, ax = plt.subplots(figsize=(4,3))\n",
"ax.plot(df.index, df.power, 'o', alpha=0.01)\n",
"ax.plot(df.index, df.power_ac, 'o', alpha=0.01)\n",
"ax.set_ylim(0,1500)\n",
"fig.autofmt_xdate()\n",
"ax.set_ylabel('AC Power (W)');"
Expand Down Expand Up @@ -183,12 +186,12 @@
],
"source": [
"# Calculate the expected power with a simple PVWatts DC model\n",
"modeled_power = pvlib.pvsystem.pvwatts_dc(df['poa'], df['Tcell'], meta['pdc'],\n",
" meta['tempco'], 25.0 )\n",
"modeled_power = pvlib.pvsystem.pvwatts_dc(df['poa'], df['Tcell'], meta['power_dc_rated'],\n",
" meta['gamma_pdc'], 25.0 )\n",
"\n",
"# Calculate the normalization, the function also returns the relevant insolation for\n",
"# each point in the normalized PV energy timeseries\n",
"normalized, insolation = rdtools.normalize_with_expected_power(df['power'],\n",
"normalized, insolation = rdtools.normalize_with_expected_power(df['power_ac'],\n",
" modeled_power,\n",
" df['poa'])\n",
"\n",
Expand Down Expand Up @@ -238,7 +241,7 @@
"tcell_mask = rdtools.tcell_filter(df['Tcell'])\n",
"# Note: This clipping mask may be disabled when you are sure the system is not \n",
"# experiencing clipping due to high DC/AC ratio\n",
"clip_mask = rdtools.clip_filter(df['power'])\n",
"clip_mask = rdtools.clip_filter(df['power_ac'])\n",
"\n",
"# filter the time series and keep only the columns needed for the\n",
"# remaining steps\n",
Expand Down Expand Up @@ -695,12 +698,12 @@
"# Calculate the expected power with a simple PVWatts DC model\n",
"clearsky_modeled_power = pvlib.pvsystem.pvwatts_dc(df['clearsky_poa'],\n",
" df['clearsky_Tcell'],\n",
" meta['pdc'], meta['tempco'], 25.0 )\n",
" meta['power_dc_rated'], meta['gamma_pdc'], 25.0 )\n",
"\n",
"# Calculate the normalization, the function also returns the relevant insolation for\n",
"# each point in the normalized PV energy timeseries\n",
"clearsky_normalized, clearsky_insolation = rdtools.normalize_with_expected_power(\n",
" df['power'],\n",
" df['power_ac'],\n",
" clearsky_modeled_power,\n",
" df['clearsky_poa']\n",
")\n",
Expand Down Expand Up @@ -848,7 +851,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
21 changes: 21 additions & 0 deletions docs/sphinx/source/changelog/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ API Changes
has changed relative to prior versions using ``precip_clean_only=True`` (:pull:`176`).
* Remove ``random_seed`` parameter from soiling module. Functionality can be obtained by running
``numpy.random.seed()`` outside of RdTools functions. (:pull:`176`)
* Many kwargs have changed name (but not input order) to bring nomenclature into
closer alignment with the `DuraMAT pv-terms project <https://duramat.github.io/pv-terms>`_: (:pull:`185`)

* :py:func:`~rdtools.aggregation.aggregation_insol` first kwarg is now ``energy_normalized``.
* :py:func:`~rdtools.degradation.degradation_year_on_year`,
:py:func:`~rdtools.degradation.degradation_ols` and
:py:func:`~rdtools.degradation.degradation_classical_decomposition`
first kwarg is now ``energy_normalized``.
* :py:func:`~rdtools.filtering.normalized_filter` input kwargs are now ``energy_normalized``, ``energy_normalized_low`` and ``energy_normalized_high``.
* :py:func:`~rdtools.filtering.poa_filter` input kwargs are now ``poa_global``, ``poa_global_low`` and ``poa_global_high``.
* :py:func:`~rdtools.filtering.tcell_filter` input kwargs are now ``temperature_cell``, ``temperature_cell_low`` and ``temperature_cell_high``.
* :py:func:`~rdtools.filtering.clip_filter` input kwargs are now ``power_ac`` and ``quantile``.
* :py:func:`~rdtools.filtering.csi_filter` first two kwargs are now ``poa_global_measured``, ``poa_global_clearsky``.
* :py:func:`~rdtools.normalization.normalize_with_pvwatts` pvwatts_kws dictionary keys have been renamed.
* :py:func:`~rdtools.normalization.pvwatts_dc_power` input kwargs are now ``poa_global``, ``power_dc_rated``, ``temperature_cell``, ``poa_global_ref``, ``temperature_cell_ref``, ``gamma_pdc``.

Enhancements
------------
Expand Down Expand Up @@ -67,6 +82,12 @@ Example Updates
variable names (:pull:`139`).
* Add a new example notebook that analyzes data from a PV system located at
NREL's South Table Mountain campus (PVDAQ system #4) (:pull:`171`).
* Explicitly register pandas datetime converters which were `deprecated <https://github.com/pandas-dev/pandas/issues/18301>`_.


Contributors
------------
* Mike Deceglie (:ghuser:`mdeceglie`)
* Kevin Anderson (:ghuser:`kanderso-nrel`)
* Chris Deline (:ghuser:`cdeline`)

15 changes: 8 additions & 7 deletions docs/sphinx/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:width: 600

.. pipe character renders as a blank line, used as spacer after the logo
|
|

RdTools Overview
================
Expand Down Expand Up @@ -146,30 +146,31 @@ The most frequently used functions are:
normalization.normalize_with_pvwatts(energy, pvwatts_kws)
'''
Inputs: Pandas time series of raw energy, PVwatts dict for system analysis
(poa_global, P_ref, T_cell, G_ref, T_ref, gamma_pdc)
(poa_global, power_dc_rated, temperature_cell, poa_global_ref, temperature_cell_ref, gamma_pdc)
Outputs: Pandas time series of normalized energy and POA insolation
'''

.. code:: python

filtering.poa_filter(poa); filtering.tcell_filter(Tcell); filtering.clip_filter(power);
filtering.csi_filter(insolation, clearsky_insolation); filtering.normalized_filter(normalized_power)
filtering.poa_filter(poa_global); filtering.tcell_filter(temperature_cell);
filtering.clip_filter(power_ac); filtering.normalized_filter(energy_normalized);
filtering.csi_filter(poa_global_measured, poa_global_clearsky);
'''
Inputs: Pandas time series of raw data to be filtered.
Output: Boolean mask where `True` indicates acceptable data
'''

.. code:: python

aggregation.aggregation_insol(normalized, insolation, frequency='D')
aggregation.aggregation_insol(energy_normalized, insolation, frequency='D')
'''
Inputs: Normalized energy and insolation
Output: Aggregated data, weighted by the insolation.
'''

.. code:: python

degradation.degradation_year_on_year(aggregated)
degradation.degradation_year_on_year(energy_normalized)
'''
Inputs: Aggregated, normalized, filtered time series data
Outputs: Tuple: `yoy_rd`: Degradation rate
Expand All @@ -178,7 +179,7 @@ The most frequently used functions are:

.. code:: python

soiling.soiling_srr(aggregated, aggregated_insolation)
soiling.soiling_srr(energy_normalized_daily, insolation_daily)
'''
Inputs: Daily aggregated, normalized, filtered time series data for normalized performance and insolation
Outputs: Tuple: `sr`: Insolation-weighted soiling ratio
Expand Down
8 changes: 4 additions & 4 deletions rdtools/aggregation.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'''Functions for calculating weighted aggregates of PV system data.'''


def aggregation_insol(normalized_energy, insolation, frequency='D'):
def aggregation_insol(energy_normalized, insolation, frequency='D'):
'''
Insolation weighted aggregation

Parameters
----------
normalized_energy : pd.Series
energy_normalized : pd.Series
Normalized energy time series
insolation : pd.Series
Time series of insolation associated with each `normalized_energy`
Time series of insolation associated with each `energy_normalized`
point
frequency : Pandas offset string, default 'D'
Target frequency at which to aggregate
Expand All @@ -20,7 +20,7 @@ def aggregation_insol(normalized_energy, insolation, frequency='D'):
aggregated : pd.Series
Insolation weighted average, aggregated at frequency
'''
aggregated = (insolation * normalized_energy).resample(frequency).sum() / \
aggregated = (insolation * energy_normalized).resample(frequency).sum() / \
insolation.resample(frequency).sum()

return aggregated
Loading