Skip to content

Commit 559c872

Browse files
authored
Merge pull request #256 from benb0228/master
Fixed Disaggregate.py for Passthrough of Daily Mean Shortwave Calculated from Entire Day
2 parents a47f941 + 9f1da97 commit 559c872

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

metsim/disaggregate.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def disaggregate(df_daily: pd.DataFrame, params: dict,
7676
n_days = len(df_daily)
7777
n_disagg = len(df_disagg)
7878
ts = int(params['time_step'])
79+
### assume passthrough implies shortwave was computed using entire day not just daylight like mtclim uses to derive its shortwave
80+
if (params['method'] == 'passthrough') & (params.get('sw_averaging', '') != 'daylight'):
81+
df_daily['daylength'] = 86400.0
7982
df_disagg['shortwave'] = shortwave(df_daily['shortwave'].values,
8083
df_daily['daylength'].values,
8184
df_daily.index.dayofyear,
@@ -642,7 +645,8 @@ def shortwave(sw_rad: np.array, daylength: np.array, day_of_year: np.array,
642645
if params['method'] == 'mtclim' or params.get('sw_averaging', '') == 'daylight':
643646
tmp_rad = (sw_rad * daylength) / (cnst.SEC_PER_HOUR * ts_hourly)
644647
else:
645-
tmp_rad = sw_rad * 24
648+
### if passthrough, still want to do this...but rather than using dailylight daylength uses entire day
649+
tmp_rad = (sw_rad * daylength) / (cnst.SEC_PER_HOUR * ts_hourly) #tmp_rad = sw_rad * 24
646650
n_days = len(tmp_rad)
647651
ts_per_day = int(cnst.HOURS_PER_DAY * cnst.MIN_PER_HOUR / ts)
648652
disaggrad = np.zeros(int(n_days * ts_per_day))

0 commit comments

Comments
 (0)