Skip to content

Commit 6af3473

Browse files
committed
Adding hsu soiling model example. Closes pvlib#989
1 parent 05b3209 commit 6af3473

File tree

3 files changed

+8823
-0
lines changed

3 files changed

+8823
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 Velocity case.
19+
# Rainfall data comes from Imperial County, CA TMY3 file
20+
# PM2.5 and PM10 data come from the EPA.
21+
22+
23+
import pathlib
24+
from matplotlib import pyplot as plt
25+
from pvlib.soiling import hsu
26+
import pvlib
27+
import pandas as pd
28+
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', index_col=0, parse_dates=True)
35+
rainfall = imperial_county['rain']
36+
depo_veloc = {'2_5': 0.0009, '10': 0.004} # defaults
37+
rain_accum_period = pd.Timedelta('1h') # default
38+
cleaning_threshold = 0.5
39+
tilt = 30
40+
pm2_5 = imperial_county['PM2_5'].values
41+
pm10 = imperial_county['PM10'].values
42+
# run the hsu soiling model
43+
soiling_ratio = hsu(rainfall,cleaning_threshold, tilt, pm2_5, pm10,
44+
depo_veloc=None, rain_accum_period=rain_accum_period)
45+
46+
# plot daily soiling ratios and compare with Coello and Boyle Fig 3A.
47+
daily_soiling_ratio = soiling_ratio.resample('d').mean()
48+
fig, ax1 = plt.subplots(figsize=(12,3))
49+
ax1.plot(daily_soiling_ratio.index,daily_soiling_ratio, marker='.', c='r', label='hsu function output')
50+
ax1.set_ylabel('Daily Soiling Ratio')
51+
ax1.set_ylim(0.79,1.01)
52+
ax1.set_title('Imperial County TMY')
53+
ax1.legend(loc='center left')
54+
55+
daily_rain = rainfall.resample('d').sum()
56+
ax2=ax1.twinx()
57+
ax2.plot(daily_rain.index,daily_rain,marker='.', c='c',label='daily rainfall')
58+
ax1.set_ylabel('Daily Rain (mm)')
59+
ax2.set_ylim(-10,210)
60+
ax2.legend(loc='center right')
61+
fig.tight_layout()
62+
fig.show()

pvlib/data/Coello_Boyle_2019_Fig3.png

282 KB
Loading

0 commit comments

Comments
 (0)