Skip to content

Commit 8ca32c9

Browse files
jssteinkandersolar
andauthored
Add hsu soiling model gallery example. (#990)
* Adding hsu soiling model example. Closes #989 * Added figure from paper to compare * formatting * formatting * added PR# to .rst file * fixed y-axis label * formatting reference * formatting * move png to _images * gallery example cleanup Co-authored-by: Kevin Anderson <[email protected]>
1 parent 75369dc commit 8ca32c9

File tree

4 files changed

+8841
-0
lines changed

4 files changed

+8841
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""
2+
HSU Soiling Model Example
3+
=========================
4+
5+
Example of soiling using the HSU model.
6+
"""
7+
8+
# %%
9+
# This example shows basic usage of pvlib's HSU Soiling model [1]_ with
10+
# :py:func:`pvlib.soiling.hsu`.
11+
#
12+
# References
13+
# -----------
14+
# .. [1] M. Coello and L. Boyle, "Simple Model For Predicting Time Series
15+
# Soiling of Photovoltaic Panels," in IEEE Journal of Photovoltaics.
16+
# doi: 10.1109/JPHOTOV.2019.2919628
17+
#
18+
# This example recreates figure 3A in [1]_ for the Fixed Settling
19+
# Velocity case.
20+
# Rainfall data comes from Imperial County, CA TMY3 file
21+
# PM2.5 and PM10 data come from the EPA. First, let's read in the
22+
# weather data and run the HSU soiling model:
23+
24+
import pathlib
25+
from matplotlib import pyplot as plt
26+
from pvlib import soiling
27+
import pvlib
28+
import pandas as pd
29+
30+
# get full path to the data directory
31+
DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data'
32+
33+
# read rainfall, PM2.5, and PM10 data from file
34+
imperial_county = pd.read_csv(DATA_DIR / 'soiling_hsu_example_inputs.csv',
35+
index_col=0, parse_dates=True)
36+
rainfall = imperial_county['rain']
37+
depo_veloc = {'2_5': 0.0009, '10': 0.004} # default values from [1] (m/s)
38+
rain_accum_period = pd.Timedelta('1h') # default
39+
cleaning_threshold = 0.5
40+
tilt = 30
41+
pm2_5 = imperial_county['PM2_5'].values
42+
pm10 = imperial_county['PM10'].values
43+
# run the hsu soiling model
44+
soiling_ratio = soiling.hsu(rainfall, cleaning_threshold, tilt, pm2_5, pm10,
45+
depo_veloc=depo_veloc,
46+
rain_accum_period=rain_accum_period)
47+
48+
# %%
49+
# And now we'll plot the modeled daily soiling ratios and compare
50+
# with Coello and Boyle Fig 3A:
51+
52+
daily_soiling_ratio = soiling_ratio.resample('d').mean()
53+
fig, ax1 = plt.subplots(figsize=(8, 2))
54+
ax1.plot(daily_soiling_ratio.index, daily_soiling_ratio, marker='.',
55+
c='r', label='hsu function output')
56+
ax1.set_ylabel('Daily Soiling Ratio')
57+
ax1.set_ylim(0.79, 1.01)
58+
ax1.set_title('Imperial County TMY')
59+
ax1.legend(loc='center left')
60+
61+
daily_rain = rainfall.resample('d').sum()
62+
ax2 = ax1.twinx()
63+
ax2.plot(daily_rain.index, daily_rain, marker='.',
64+
c='c', label='daily rainfall')
65+
ax2.set_ylabel('Daily Rain (mm)')
66+
ax2.set_ylim(-10, 210)
67+
ax2.legend(loc='center right')
68+
fig.tight_layout()
69+
fig.show()
70+
71+
# %%
72+
# Here is the original figure from [1]_ for comparison:
73+
#
74+
# .. image:: ../_images/Coello_Boyle_2019_Fig3.png
75+
# :alt: Figure 3A from the paper showing a simulated soiling signal.
76+
#
77+
# Note that this figure shows additional timeseries not calculated here:
78+
# modeled soiling ratio using the 2015 PRISM rainfall dataset (orange)
79+
# and measured soiling ratio (dashed green).
Loading

docs/sphinx/source/whatsnew/v0.8.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Documentation
107107
* Clarify units for heat loss factors in
108108
:py:func:`pvlib.temperature.pvsyst_cell` and
109109
:py:func:`pvlib.temperature.faiman`. (:pull:`960`)
110+
* Added hsu soiling model example to the gallery. (:pull:`990`)
110111
* Add make.bat so that docs can be built on Windows without ``make`` installed.
111112
(:issue:`978`, :pull:`981`)
112113
* Add instructions to build the documentation. (:pull:`982`)

0 commit comments

Comments
 (0)