Skip to content

Commit 9616600

Browse files
authored
Merge pull request #1462 from karsenau/fix/s2s_lis7.5.14_patch
Update to S2S forecast processing script
2 parents 36bfccc + 9b013af commit 9616600

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

lis/utils/usaf/s2s/s2s_modules/bcsd_fcst/bcsd_library/process_forecast_data.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,11 @@ def _driver():
234234
ens_num = int(args['ens_num'])
235235
print(f"[INFO] {fcst_init['monthday']} {year}")
236236

237+
fcst_init["year"] = year
237238
if fcst_init['monthday'] == "jan01":
238-
fcst_init["year"] = year - 1
239+
fcst_init["year_cfsv2"] = year - 1
239240
else:
240-
fcst_init["year"] = year
241+
fcst_init["year_cfsv2"] = year
241242

242243
mmm = fcst_init['monthday'].split("0")[0].capitalize()
243244
dt1 = datetime.strptime('{} 1 {}'.format(mmm,fcst_init["year"]), '%b %d %Y')
@@ -246,8 +247,8 @@ def _driver():
246247
dt2 = np.datetime64(dt2.strftime('%Y-%m-%d'))
247248

248249
monthday = args['all_monthdays'][ens_num - 1]
249-
temp_name = f"cfsv2.{fcst_init['year']}{monthday}.nc"
250-
fcst_init['date'] = f"{fcst_init['year']}{monthday}"
250+
temp_name = f"cfsv2.{fcst_init['year_cfsv2']}{monthday}.nc"
251+
fcst_init['date'] = f"{fcst_init['year_cfsv2']}{monthday}"
251252
fcst_init['month'] = int(monthday[0:2])
252253
fcst_init['day'] = int(monthday[2:4])
253254
fcst_init['hour'] = args['all_ensmembers'][ens_num - 1]
@@ -272,23 +273,23 @@ def _driver():
272273
if not os.path.exists(outdirs['outdir_monthly']):
273274
os.makedirs(outdirs['outdir_monthly'])
274275

275-
cfsv2 = []
276+
cfsv2 = []
276277
for varname in ["prate", "pressfc", "tmp2m", "dlwsfc", "dswsfc",
277278
"q2m", "wnd10m"]:
278279
print(f"[INFO] {varname}")
279280
subdir, file_pfx, file_sfx = \
280-
_set_input_file_info(fcst_init['year'],
281+
_set_input_file_info(fcst_init['year_cfsv2'],
281282
fcst_init['month'],
282283
varname)
283284
indir = f"{args['forcedir']}/{subdir}/"
284285
if subdir == "Oper_TS" and not os.path.exists(indir):
285286
indir = f"{args['forcedir']}/"
286-
287-
indir += f"{fcst_init['year']}/{fcst_init['date']}"
287+
288+
indir += f"{fcst_init['year_cfsv2']}/{fcst_init['date']}"
288289

289290
# Convert GRIB file to netCDF and handle missing/corrupted data
290291
cfsv2.append(read_wgrib (indir, file_pfx, fcst_init['timestring'], file_sfx, outdirs['outdir_6hourly'], temp_name, varname, args['patchdir']))
291-
292+
292293
cfsv2 = xr.merge (cfsv2, compat='override')
293294
reg_precip = _regrid_precip(cfsv2, args)
294295
_migrate_to_monthly_files(cfsv2.sel (step = (cfsv2['valid_time'] >= dt1) &

lis/utils/usaf/s2s/s2s_modules/s2splots/plot_anom_verify.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def compute_median (anom, lead):
7272
''' compute median anomaly of the specified lad '''
7373
da_slice=[]
7474
for da in anom:
75-
da_slice.append(da.isel(lead=lead))
75+
da_slice.append(da.isel(time=lead))
7676
da_conc = xr.concat(da_slice, dim = 'ens')
7777
return da_conc.median(dim = 'ens')
7878

@@ -349,6 +349,8 @@ def write_clim(config_file, month, flabel):
349349

350350
nc_med = compute_median (anoms, lead)
351351
plot_arr[0,:] = nc_med.values *convf
352+
if var == 'Precip':
353+
plot_arr[0,:] = plot_arr[0,:]/ndays
352354

353355
# plotting
354356
style_color = plot_utils.load_table(load_table)

0 commit comments

Comments
 (0)