Skip to content

Commit

Permalink
Merge pull request #1462 from karsenau/fix/s2s_lis7.5.14_patch
Browse files Browse the repository at this point in the history
Update to S2S forecast processing script
  • Loading branch information
emkemp authored Nov 30, 2023
2 parents 36bfccc + 9b013af commit 9616600
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ def _driver():
ens_num = int(args['ens_num'])
print(f"[INFO] {fcst_init['monthday']} {year}")

fcst_init["year"] = year
if fcst_init['monthday'] == "jan01":
fcst_init["year"] = year - 1
fcst_init["year_cfsv2"] = year - 1
else:
fcst_init["year"] = year
fcst_init["year_cfsv2"] = year

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

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

cfsv2 = []
cfsv2 = []
for varname in ["prate", "pressfc", "tmp2m", "dlwsfc", "dswsfc",
"q2m", "wnd10m"]:
print(f"[INFO] {varname}")
subdir, file_pfx, file_sfx = \
_set_input_file_info(fcst_init['year'],
_set_input_file_info(fcst_init['year_cfsv2'],
fcst_init['month'],
varname)
indir = f"{args['forcedir']}/{subdir}/"
if subdir == "Oper_TS" and not os.path.exists(indir):
indir = f"{args['forcedir']}/"

indir += f"{fcst_init['year']}/{fcst_init['date']}"
indir += f"{fcst_init['year_cfsv2']}/{fcst_init['date']}"

# Convert GRIB file to netCDF and handle missing/corrupted data
cfsv2.append(read_wgrib (indir, file_pfx, fcst_init['timestring'], file_sfx, outdirs['outdir_6hourly'], temp_name, varname, args['patchdir']))

cfsv2 = xr.merge (cfsv2, compat='override')
reg_precip = _regrid_precip(cfsv2, args)
_migrate_to_monthly_files(cfsv2.sel (step = (cfsv2['valid_time'] >= dt1) &
Expand Down
4 changes: 3 additions & 1 deletion lis/utils/usaf/s2s/s2s_modules/s2splots/plot_anom_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def compute_median (anom, lead):
''' compute median anomaly of the specified lad '''
da_slice=[]
for da in anom:
da_slice.append(da.isel(lead=lead))
da_slice.append(da.isel(time=lead))
da_conc = xr.concat(da_slice, dim = 'ens')
return da_conc.median(dim = 'ens')

Expand Down Expand Up @@ -349,6 +349,8 @@ def write_clim(config_file, month, flabel):

nc_med = compute_median (anoms, lead)
plot_arr[0,:] = nc_med.values *convf
if var == 'Precip':
plot_arr[0,:] = plot_arr[0,:]/ndays

# plotting
style_color = plot_utils.load_table(load_table)
Expand Down

0 comments on commit 9616600

Please sign in to comment.