def test_hsu_defaults(rainfall_input, expected_output_1): """ Test Soiling HSU function with default deposition velocity and default rain accumulation period. """ result = hsu(rainfall=rainfall_input, cleaning_threshold=0.5, tilt=0.0, pm2_5=1.0e-2, pm10=2.0e-2) assert np.allclose(result.values, expected_output_1)
def test_hsu_no_cleaning(rainfall_input, expected_output): """Test Soiling HSU function""" rainfall = rainfall_input pm2_5 = 1.0 pm10 = 2.0 depo_veloc = {'2_5': 1.0e-5, '10': 1.0e-4} tilt = 0. expected_no_cleaning = expected_output result = hsu(rainfall=rainfall, cleaning_threshold=10., tilt=tilt, pm2_5=pm2_5, pm10=pm10, depo_veloc=depo_veloc, rain_accum_period=pd.Timedelta('1h')) assert_series_equal(result, expected_no_cleaning)
def test_hsu(rainfall_input, expected_output_2): """Test Soiling HSU function with cleanings""" rainfall = rainfall_input pm2_5 = 1.0 pm10 = 2.0 depo_veloc = {'2_5': 1.0e-4, '10': 1.0e-4} tilt = 0. # three cleaning events at 4:00-6:00, 8:00-11:00, and 17:00-20:00 result = hsu(rainfall=rainfall, cleaning_threshold=0.5, tilt=tilt, pm2_5=pm2_5, pm10=pm10, depo_veloc=depo_veloc, rain_accum_period=pd.Timedelta('3h')) assert_series_equal(result, expected_output_2)
def test_hsu_variable_time_intervals(rainfall_input, expected_output_3): """ Test Soiling HSU function with variable time intervals. """ depo_veloc = {'2_5': 1.0e-4, '10': 1.0e-4} rain = pd.DataFrame(data=rainfall_input) # define time deltas in minutes timedelta = [0, 0, 0, 0, 0, 30, 0, 30, 0, 30, 0, -30, -30, -30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] rain['mins_added'] = pd.to_timedelta(timedelta, 'm') rain['new_time'] = rain.index + rain['mins_added'] rain_var_times = rain.set_index('new_time').iloc[:, 0] result = hsu( rainfall=rain_var_times, cleaning_threshold=0.5, tilt=50.0, pm2_5=1, pm10=2, depo_veloc=depo_veloc, rain_accum_period=pd.Timedelta('2h')) assert np.allclose(result, expected_output_3)
# get full path to the data directory DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' # read rainfall, PM2.5, and PM10 data from file imperial_county = pd.read_csv(DATA_DIR / 'soiling_hsu_example_inputs.csv', index_col=0, parse_dates=True) rainfall = imperial_county['rain'] depo_veloc = {'2_5': 0.0009, '10': 0.004} # default values from [1] (m/s) rain_accum_period = pd.Timedelta('1h') # default cleaning_threshold = 0.5 tilt = 30 pm2_5 = imperial_county['PM2_5'].values pm10 = imperial_county['PM10'].values # run the hsu soiling model soiling_ratio = soiling.hsu(rainfall, cleaning_threshold, tilt, pm2_5, pm10, depo_veloc=depo_veloc, rain_accum_period=rain_accum_period) # %% # And now we'll plot the modeled daily soiling ratios and compare # with Coello and Boyle Fig 3A: daily_soiling_ratio = soiling_ratio.resample('d').mean() fig, ax1 = plt.subplots(figsize=(8, 2)) ax1.plot(daily_soiling_ratio.index, daily_soiling_ratio, marker='.', c='r', label='hsu function output') ax1.set_ylabel('Daily Soiling Ratio') ax1.set_ylim(0.79, 1.01) ax1.set_title('Imperial County TMY') ax1.legend(loc='center left')