From 2b7d91042e00966a7e4f1e9bea640fa84104eefc Mon Sep 17 00:00:00 2001 From: bluefinweiwei Date: Fri, 15 Dec 2023 19:35:38 +0000 Subject: [PATCH] Add more wildcard character to filenames and soil color to LSM IC 1) Add wildcard character * for various output filenames, e.g., gfs.t00z.atmf0000.nc, gfs.t00z.sfcf0000.nc, oro_C96.mx100.tile1.nc. 2) Add soil color (a new soil property in Noah-MP) to get LSM IC set correctly, otherwise, forcing is not generated due to a crash modified: UFS_IC_generator.py modified: extract_FV3GFS_column_ic.py --- scm/etc/scripts/UFS_IC_generator.py | 13 ++++++++----- scm/etc/scripts/extract_FV3GFS_column_ic.py | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/scm/etc/scripts/UFS_IC_generator.py b/scm/etc/scripts/UFS_IC_generator.py index 6fdbd13fd..ae91f6399 100755 --- a/scm/etc/scripts/UFS_IC_generator.py +++ b/scm/etc/scripts/UFS_IC_generator.py @@ -1044,6 +1044,7 @@ def get_UFS_surface_data(dir, tile, i, j, old_chgres, lam): facsf_in = read_NetCDF_surface_var(nc_file, 'facsf', i, j, old_chgres, 0) facwf_in = read_NetCDF_surface_var(nc_file, 'facwf', i, j, old_chgres, 0) styp_in = read_NetCDF_surface_var(nc_file, 'stype', i, j, old_chgres, 0) + scol_in = read_NetCDF_surface_var(nc_file, 'scolor', i, j, old_chgres, 0) slope_in = read_NetCDF_surface_var(nc_file, 'slope', i, j, old_chgres, 0) vtyp_in = read_NetCDF_surface_var(nc_file, 'vtype', i, j, old_chgres, 0) vfrac_in = read_NetCDF_surface_var(nc_file, 'vfrac', i, j, old_chgres, 0) @@ -1187,6 +1188,7 @@ def get_UFS_surface_data(dir, tile, i, j, old_chgres, lam): "facsf": facsf_in, "facwf": facwf_in, "soiltyp": styp_in, + "scolor": scol_in, "slopetyp": slope_in, "vegtyp": vtyp_in, "vegfrac": vfrac_in, @@ -1313,7 +1315,7 @@ def get_UFS_oro_data(dir, tile, i, j, lam): if lam: nc_file = Dataset('{0}/{1}'.format(dir,'oro_data.nc')) else: - filename_pattern = 'oro_data.tile{0}.nc'.format(tile) + filename_pattern = 'oro*.tile{0}.nc'.format(tile) for f_name in os.listdir(dir): if fnmatch.fnmatch(f_name, filename_pattern): filename = f_name @@ -1462,8 +1464,8 @@ def get_UFS_forcing_data(nlevs, state_IC, location, use_nearest, forcing_dir, gr atm_ftag = 'atmf*.tile{0}.nc'.format(tile) sfc_ftag = 'sfcf*.tile{0}.nc'.format(tile) else: - atm_ftag = 'atmf*.nc' - sfc_ftag = 'sfcf*.nc' + atm_ftag = '*atmf*.nc' + sfc_ftag = '*sfcf*.nc' # Get list of UFS history files with 3D ATMospheric state variables. atm_filenames = [] @@ -2450,6 +2452,7 @@ def write_SCM_case_file(state, surface, oro, forcing, case, date, stateREGRID): {"name": "q2m", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "2-meter specific humidity"}, \ {"name": "vegtyp", "type":wi, "dimd": ('t0'), "units": "none", "desc": "vegetation type (1-12)"}, \ {"name": "soiltyp", "type":wi, "dimd": ('t0'), "units": "none", "desc": "soil type (1-12)"}, \ + {"name": "scolor", "type":wi, "dimd": ('t0'), "units": "none", "desc": "soil color (1-20)"}, \ {"name": "ffmm", "type":wp, "dimd": ('t0'), "units": "none", "desc": "Monin-Obukhov similarity function for momentum"}, \ {"name": "ffhh", "type":wp, "dimd": ('t0'), "units": "none", "desc": "Monin-Obukhov similarity function for heat"}, \ {"name": "hice", "type":wp, "dimd": ('t0'), "units": "m", "desc": "sea ice thickness"}, \ @@ -2638,8 +2641,8 @@ def write_comparison_file(comp_data, case_name, date, surface): ######################################################################################## def find_date(forcing_dir): - atm_ftag = 'atmf*.nc' - + atm_ftag = '*atmf*.nc' + atm_filenames = [] for f_name in os.listdir(forcing_dir): if fnmatch.fnmatch(f_name, atm_ftag): diff --git a/scm/etc/scripts/extract_FV3GFS_column_ic.py b/scm/etc/scripts/extract_FV3GFS_column_ic.py index 6684125c1..88468b889 100755 --- a/scm/etc/scripts/extract_FV3GFS_column_ic.py +++ b/scm/etc/scripts/extract_FV3GFS_column_ic.py @@ -79,6 +79,7 @@ facsf_in=ncin2['facsf'][jpt,ipt] facwf_in=ncin2['facwf'][jpt,ipt] styp_in=ncin2['stype'][jpt,ipt] +scol_in=ncin2['scolor'][jpt,ipt] slope_in=ncin2['slope'][jpt,ipt] vtyp_in=ncin2['vtype'][jpt,ipt] vfrac_in=ncin2['vfrac'][jpt,ipt] @@ -149,6 +150,7 @@ ivegsrc = nc.createVariable('scalars/vegsrc',np.int32) ivegtyp = nc.createVariable('scalars/vegtyp',np.int32) isoiltyp = nc.createVariable('scalars/soiltyp',np.int32) +iscolor = nc.createVariable('scalars/scolor',np.int32) islopetyp = nc.createVariable('scalars/slopetyp',np.int32) ivegfrac = nc.createVariable('scalars/vegfrac',np.float) ishdmin = nc.createVariable('scalars/shdmin',np.float) @@ -180,6 +182,7 @@ ivegsrc.description = "vegetation soure (1-2)" ivegtyp.description = "vegetation type (1-12)" isoiltyp.description = "soil type (1-12)" +iscolor.description = "soil color (1-20)" islopetyp.description = "slope type (1-9)" ivegfrac.description = "vegetation fraction" ishdmin.description = "minimum vegetation fraction" @@ -395,6 +398,7 @@ ivegsrc[:] = 1 ivegtyp[:] = vtyp_in isoiltyp[:] = styp_in +iscolor[:] = scol_in islopetyp[:] = slope_in ishdmin[:] = shdmin_in ishdmax[:] = shdmax_in