Skip to content

Commit

Permalink
Update wrapper interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinswales committed Jun 7, 2024
1 parent 3c080b7 commit f9e75d0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 61 deletions.
83 changes: 41 additions & 42 deletions scm/etc/scripts/UFS_case_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import fv3_remap
import xesmf
from datetime import datetime, timedelta
from pylab import plot, ylim, xlim, show, xlabel, ylabel, grid

#from matplotlib import plot, ylim, xlim, show, xlabel, ylabel, grid

###############################################################################
# Global settings #
Expand Down Expand Up @@ -2073,46 +2072,46 @@ def get_UFS_forcing_data_advective_tendency(dir, i, j, tile, neighbors, dx, dy,
# show()


if (False):
plot(h_advec_T[t,:]*86400.0,pres[t,:],"r")
# #y_av = movingaverage(y, 10)
plot(v_advec_T[t,:]*86400.0,pres[t,:],"b")
# #plot(w_wind_smoothed_sf, pres[t,:],"b")
xlim(86400.0*np.min(h_advec_T[t,:] + v_advec_T[t,:]),86400.0*np.max(h_advec_T[t,:] + v_advec_T[t,:]))
xlabel("K day-1")
ylabel("p")
grid(True)
show()

plot(h_advec_qv[t,:]*86400.0*1.0E3,pres[t,:],"r")
# #y_av = movingaverage(y, 10)
plot(v_advec_qv[t,:]*86400.0*1.0E3,pres[t,:],"b")
# #plot(w_wind_smoothed_sf, pres[t,:],"b")
xlim(86400.0*1.0E3*np.min(h_advec_qv[t,:] + v_advec_qv[t,:]),86400.0*1.0E3*np.max(h_advec_qv[t,:] + v_advec_qv[t,:]))
xlabel("g kg-1 day-1")
ylabel("p")
grid(True)
show()

plot(h_advec_u[t,:]*86400.0,pres[t,:],"r")
# #y_av = movingaverage(y, 10)
plot(v_advec_u[t,:]*86400.0,pres[t,:],"b")
# #plot(w_wind_smoothed_sf, pres[t,:],"b")
xlim(86400.0*np.min(h_advec_u[t,:] + v_advec_u[t,:]),86400.0*np.max(h_advec_u[t,:] + v_advec_u[t,:]))
xlabel("u: m s-1 day-1")
ylabel("p")
grid(True)
show()

plot(h_advec_v[t,:]*86400.0,pres[t,:],"r")
# #y_av = movingaverage(y, 10)
plot(v_advec_v[t,:]*86400.0,pres[t,:],"b")
# #plot(w_wind_smoothed_sf, pres[t,:],"b")
xlim(86400.0*np.min(h_advec_v[t,:] + v_advec_v[t,:]),86400.0*np.max(h_advec_v[t,:] + v_advec_v[t,:]))
xlabel("v: m s-1 day-1")
ylabel("p")
grid(True)
show()
# if (False):
# plot(h_advec_T[t,:]*86400.0,pres[t,:],"r")
# # #y_av = movingaverage(y, 10)
# plot(v_advec_T[t,:]*86400.0,pres[t,:],"b")
# # #plot(w_wind_smoothed_sf, pres[t,:],"b")
# xlim(86400.0*np.min(h_advec_T[t,:] + v_advec_T[t,:]),86400.0*np.max(h_advec_T[t,:] + v_advec_T[t,:]))
# xlabel("K day-1")
# ylabel("p")
# grid(True)
# show()
#
# plot(h_advec_qv[t,:]*86400.0*1.0E3,pres[t,:],"r")
# # #y_av = movingaverage(y, 10)
# plot(v_advec_qv[t,:]*86400.0*1.0E3,pres[t,:],"b")
# # #plot(w_wind_smoothed_sf, pres[t,:],"b")
# xlim(86400.0*1.0E3*np.min(h_advec_qv[t,:] + v_advec_qv[t,:]),86400.0*1.0E3*np.max(h_advec_qv[t,:] + v_advec_qv[t,:]))
# xlabel("g kg-1 day-1")
# ylabel("p")
# grid(True)
# show()
#
# plot(h_advec_u[t,:]*86400.0,pres[t,:],"r")
# # #y_av = movingaverage(y, 10)
# plot(v_advec_u[t,:]*86400.0,pres[t,:],"b")
# # #plot(w_wind_smoothed_sf, pres[t,:],"b")
# xlim(86400.0*np.min(h_advec_u[t,:] + v_advec_u[t,:]),86400.0*np.max(h_advec_u[t,:] + v_advec_u[t,:]))
# xlabel("u: m s-1 day-1")
# ylabel("p")
# grid(True)
# show()
#
# plot(h_advec_v[t,:]*86400.0,pres[t,:],"r")
# # #y_av = movingaverage(y, 10)
# plot(v_advec_v[t,:]*86400.0,pres[t,:],"b")
# # #plot(w_wind_smoothed_sf, pres[t,:],"b")
# xlim(86400.0*np.min(h_advec_v[t,:] + v_advec_v[t,:]),86400.0*np.max(h_advec_v[t,:] + v_advec_v[t,:]))
# xlabel("v: m s-1 day-1")
# ylabel("p")
# grid(True)
# show()


# grad_t = np.gradient(temp[t,:,:,:]) #grad_t output is list of components (z, y, x); each axis array has dimensions of (levs,2*n_forcing_halo_points+1,2*n_forcing_halo_points+1); we're interested in middle point for each level
Expand Down
36 changes: 17 additions & 19 deletions scm/etc/scripts/UFS_forcing_ensemble_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@
# Argument list
###############################################################################
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--dir', help='path to UFS Regression Test output', required=True)
parser.add_argument('-n', '--case_name', help='name of case', required=True)
parser.add_argument('-lonl', '--lon_limits', help='longitude range, separated by a space', nargs=2, type=float, required=False)
parser.add_argument('-latl', '--lat_limits', help='latitude range, separated by a space', nargs=2, type=float, required=False)
parser.add_argument('-lons', '--lon_list', help='longitudes, separated by a space', nargs='*', type=float, required=False)
parser.add_argument('-lats', '--lat_list', help='latitudes, separated by a space', nargs='*', type=float, required=False)
parser.add_argument('-fxy', '--lonlat_file', help='file containing longitudes and latitude',nargs=1, required=False)
parser.add_argument('-nens', '--nensmembers', help='number of SCM UFS ensemble memebers to create', type=int, required=False)
parser.add_argument('-dt', '--timestep', help='SCM timestep, in seconds', type=int, default = 3600)
parser.add_argument('-cres', '--C_RES', help='UFS spatial resolution', type=int, default = 96)
parser.add_argument('-sdf', '--suite', help='CCPP suite definition file to use for ensemble', default = 'SCM_GFS_v16')
parser.add_argument('-sc', '--save_comp', help='flag to save a file with UFS data for comparisons', action='store_true')
parser.add_argument('-near', '--use_nearest', help='flag to indicate using the nearest UFS history file gridpoint, no regridding',action='store_true')
parser.add_argument('-ext', '--exact_mode', help='flag to indicate using dynamic tendencies from UFS history files', action='store_true')
parser.add_argument('-tott', '--total_tend', help='flag to indicate forcing to derive', action='store_true')
parser.add_argument('-d', '--dir', help='path to UFS Regression Test output', required=True)
parser.add_argument('-n', '--case_name', help='name of case', required=True)
parser.add_argument('-lonl', '--lon_limits', help='longitude range, separated by a space', nargs=2, type=float, required=False)
parser.add_argument('-latl', '--lat_limits', help='latitude range, separated by a space', nargs=2, type=float, required=False)
parser.add_argument('-lons', '--lon_list', help='longitudes, separated by a space', nargs='*', type=float, required=False)
parser.add_argument('-lats', '--lat_list', help='latitudes, separated by a space', nargs='*', type=float, required=False)
parser.add_argument('-fxy', '--lonlat_file', help='file containing longitudes and latitude',nargs=1, required=False)
parser.add_argument('-nens', '--nensmembers', help='number of SCM UFS ensemble memebers to create', type=int, required=False)
parser.add_argument('-dt', '--timestep', help='SCM timestep, in seconds', type=int, default = 3600)
parser.add_argument('-cres', '--C_RES', help='UFS spatial resolution', type=int, default = 96)
parser.add_argument('-sdf', '--suite', help='CCPP suite definition file to use for ensemble', default = 'SCM_GFS_v16')
parser.add_argument('-sc', '--save_comp', help='flag to save a file with UFS data for comparisons', action='store_true')
parser.add_argument('-near', '--use_nearest', help='flag to indicate using the nearest UFS history file gridpoint, no regridding',action='store_true')
parser.add_argument('-fm', '--forcing_method', help='method used to calculate forcing (1=total tendencies from UFS dycore, 2=advective terms calculated from UFS history files, 3=total time tendency terms calculated)', type=int, choices=range(1,4), default=2)

###############################################################################
# Main program
Expand Down Expand Up @@ -138,10 +137,9 @@ def main():

# What, if any, options neeed to be passsed to UFS_case_gen.py?
com_config = ''
if args.save_comp: com_config = com_config + ' -sc'
if args.use_nearest: com_config = com_config + ' -near'
if args.exact_mode: com_config = com_config + ' -ext'
if args.total_tend: com_config = com_config + ' -tott'
if args.save_comp: com_config = com_config + ' -sc'
if args.use_nearest: com_config = com_config + ' -near'
if args.forcing_method: com_config = com_config + ' -fm ' + str(args.forcing_method)

# Create inputs to SCM
case_list = ""
Expand Down

0 comments on commit f9e75d0

Please sign in to comment.