Skip to content

Commit bc85443

Browse files
authored
[release/public-v2] Bugfix: Pass domain name to python plotting scripts (#788)
## DESCRIPTION OF CHANGES: This is the counterpart of PR #[783](#783) but to be merged into the `release/public-v2` branch instead of `develop`. See that PR for details. ## DEPENDENCIES: PR #[298](ufs-community/ufs-srweather-app#298) in `ufs-srweather-app`.
1 parent 4ad491d commit bc85443

8 files changed

+94
-45
lines changed

ush/Python/plot_allvars.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# David Wright Org: University of Michigan
1010
#
1111
# Instructions: Make sure all the necessary modules can be imported.
12-
# Six command line arguments are needed:
12+
# The following command line arguments are needed:
1313
# 1. Cycle date/time in YYYYMMDDHH format
1414
# 2. Starting forecast hour
1515
# 3. Ending forecast hour
@@ -26,12 +26,16 @@
2626
# CARTOPY_DIR/shapefiles/natural_earth/cultural/*.shp
2727
# -More information regarding files needed to setup
2828
# display maps in Cartopy, see SRW App Users' Guide
29+
# 7. POST_OUTPUT_DOMAIN_NAME: Name of native domain
30+
# used in forecast and in constructing the names
31+
# of the post output files.
2932
#
30-
# To create plots for forecast hours 20-24 from 5/7 00Z
31-
# cycle with hourly output:
33+
# To create plots for a forecast on the RRFS_CONUS_25km
34+
# grid for hours 20-24 from the 5/7 00Z cycle with
35+
# hourly output:
3236
# python plot_allvars.py 2020050700 20 24 1 \
3337
# /path/to/expt_dirs/experiment/name \
34-
# /path/to/base/cartopy/maps
38+
# /path/to/base/cartopy/maps RRFS_CONUS_25km
3539
#
3640
# The variable domains in this script can be set to either
3741
# 'conus' for a CONUS map or 'regional' where the map
@@ -227,6 +231,7 @@ def rotate_wind(true_lat,lov_lon,earth_lons,uin,vin,proj,inverse=False):
227231
parser.add_argument("Forecast hour increment")
228232
parser.add_argument("Path to experiment directory")
229233
parser.add_argument("Path to base directory of cartopy shapefiles")
234+
parser.add_argument("Name of native domain used in forecast (and in constructing post file names)")
230235
args = parser.parse_args()
231236

232237
# Read date/time, forecast hour, and directory paths from command line
@@ -252,6 +257,7 @@ def rotate_wind(true_lat,lov_lon,earth_lons,uin,vin,proj,inverse=False):
252257

253258
EXPT_DIR = str(sys.argv[5])
254259
CARTOPY_DIR = str(sys.argv[6])
260+
POST_OUTPUT_DOMAIN_NAME = str(sys.argv[7]).lower()
255261

256262
# Loop over forecast hours
257263
for fhr in fhours:
@@ -261,7 +267,7 @@ def rotate_wind(true_lat,lov_lon,earth_lons,uin,vin,proj,inverse=False):
261267
vtime = ndate(itime,int(fhr))
262268

263269
# Define the location of the input file
264-
data1 = pygrib.open(EXPT_DIR+'/'+ymdh+'/postprd/rrfs.t'+cyc+'z.prslevf'+fhour+'.tm00.grib2')
270+
data1 = pygrib.open(EXPT_DIR+'/'+ymdh+'/postprd/rrfs.t'+cyc+'z.prslev.f'+fhour+'.'+POST_OUTPUT_DOMAIN_NAME+'.grib2')
265271

266272
# Get the lats and lons
267273
grids = [data1]

ush/Python/plot_allvars_diff.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# David Wright Org: University of Michigan
1010
#
1111
# Instructions: Make sure all the necessary modules can be imported.
12-
# Seven command line arguments are needed:
12+
# The following command line arguments are needed:
1313
# 1. Cycle date/time in YYYYMMDDHH format
1414
# 2. Starting forecast hour
1515
# 3. Ending forecast hour
@@ -29,12 +29,17 @@
2929
# CARTOPY_DIR/shapefiles/natural_earth/cultural/*.shp
3030
# -More information regarding files needed to setup
3131
# display maps in Cartopy, see SRW App Users' Guide
32+
# 8. POST_OUTPUT_DOMAIN_NAME: Name of native domain
33+
# used in forecasts and in constructing the names
34+
# of the post output files. This must be the same
35+
# for both forecasts.
3236
#
33-
# To create plots for forecast hours 20-24 from 5/7 00Z
34-
# cycle with hourly output:
37+
# To create difference plots for two forecasts on the
38+
# RRFS_CONUS_25km grid for hours 20-24 from the 5/7
39+
# 00Z cycle with hourly output:
3540
# python plot_allvars_diff.py 2020050700 20 24 1 \
3641
# /path/to/expt_dir_1 /path/to/expt_dir_2 \
37-
# /path/to/base/cartopy/maps
42+
# /path/to/base/cartopy/maps RRFS_CONUS_25km
3843
#
3944
# The variable domains in this script can be set to either
4045
# 'conus' for a CONUS map or 'regional' where the map
@@ -231,6 +236,7 @@ def rotate_wind(true_lat,lov_lon,earth_lons,uin,vin,proj,inverse=False):
231236
parser.add_argument("Path to experiment 1 directory")
232237
parser.add_argument("Path to experiment 2 directory")
233238
parser.add_argument("Path to base directory of cartopy shapefiles")
239+
parser.add_argument("Name of native domain used in forecasts (and in constructing post file names)")
234240
args = parser.parse_args()
235241

236242
# Read date/time, forecast hour, and directory paths from command line
@@ -257,6 +263,7 @@ def rotate_wind(true_lat,lov_lon,earth_lons,uin,vin,proj,inverse=False):
257263
EXPT_DIR_1 = str(sys.argv[5])
258264
EXPT_DIR_2 = str(sys.argv[6])
259265
CARTOPY_DIR = str(sys.argv[7])
266+
POST_OUTPUT_DOMAIN_NAME = str(sys.argv[8]).lower()
260267

261268
# Loop over forecast hours
262269
for fhr in fhours:
@@ -267,8 +274,8 @@ def rotate_wind(true_lat,lov_lon,earth_lons,uin,vin,proj,inverse=False):
267274

268275

269276
# Define the location of the input files
270-
data1 = pygrib.open(EXPT_DIR_1+'/'+ymdh+'/postprd/rrfs.t'+cyc+'z.prslevf'+fhour+'.tm00.grib2')
271-
data2 = pygrib.open(EXPT_DIR_2+'/'+ymdh+'/postprd/rrfs.t'+cyc+'z.prslevf'+fhour+'.tm00.grib2')
277+
data1 = pygrib.open(EXPT_DIR_1+'/'+ymdh+'/postprd/rrfs.t'+cyc+'z.prslev.f'+fhour+'.'+POST_OUTPUT_DOMAIN_NAME+'.grib2')
278+
data2 = pygrib.open(EXPT_DIR_2+'/'+ymdh+'/postprd/rrfs.t'+cyc+'z.prslev.f'+fhour+'.'+POST_OUTPUT_DOMAIN_NAME+'.grib2')
272279

273280
# Get the lats and lons
274281
grids = [data1, data2]

ush/Python/qsub_job.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export FCST_END=${FCST_LEN_HRS}
3535
export FCST_INC=3
3636

3737
# Usage statement: Make sure all the necessary modules can be imported.
38-
# Five command line arguments are needed:
38+
# The following command line arguments are needed:
3939
# 1. Cycle date/time in YYYYMMDDHH format
4040
# 2. Starting forecast hour in HHH format
4141
# 3. Ending forecast hour in HHH format
@@ -46,5 +46,10 @@ export FCST_INC=3
4646
# 6. CARTOPY_DIR: Base directory of cartopy shapefiles
4747
# -File structure should be:
4848
# CARTOPY_DIR/shapefiles/natural_earth/cultural/*.shp
49+
# 7. POST_OUTPUT_DOMAIN_NAME: Name of native domain
50+
# used in forecast and in constructing the names
51+
# of the post output files.
4952

50-
python plot_allvars.py ${CDATE} ${FCST_START} ${FCST_END} ${FCST_INC} ${EXPTDIR} ${SHAPE_FILES}
53+
54+
python plot_allvars.py ${CDATE} ${FCST_START} ${FCST_END} ${FCST_INC} \
55+
${EXPTDIR} ${SHAPE_FILES} ${POST_OUTPUT_DOMAIN_NAME}

ush/Python/qsub_job_diff.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ ncar_pylib /glade/p/ral/jntp/UFS_SRW_app/ncar_pylib/python_graphics
2828
#Cheyenne:
2929
SHAPE_FILES=/glade/p/ral/jntp/UFS_SRW_app/tools/NaturalEarth
3030

31-
export GLOBAL_VAR_DEFNS_FP="${EXPTDIR}/var_defns.sh"
31+
export GLOBAL_VAR_DEFNS_FP="${EXPTDIR1}/var_defns.sh"
3232
source ${GLOBAL_VAR_DEFNS_FP}
3333
export CDATE=${DATE_FIRST_CYCL}${CYCL_HRS}
3434
export FCST_START=3
3535
export FCST_END=${FCST_LEN_HRS}
3636
export FCST_INC=3
3737

3838
# Usage statement: Make sure all the necessary modules can be imported.
39-
# Seven command line arguments are needed:
39+
# The following command line arguments are needed:
4040
# 1. Cycle date/time in YYYYMMDDHH format
4141
# 2. Starting forecast hour in HHH format
4242
# 3. Ending forecast hour in HHH format
@@ -50,5 +50,12 @@ export FCST_INC=3
5050
# 7. CARTOPY_DIR: Base directory of cartopy shapefiles
5151
# -File structure should be:
5252
# CARTOPY_DIR/shapefiles/natural_earth/cultural/*.shp
53-
54-
python plot_allvars_diff.py ${CDATE} ${FCST_START} ${FCST_END} ${FCST_INC} ${EXPTDIR1} ${EXPTDIR2} ${SHAPE_FILES}
53+
# 8. POST_OUTPUT_DOMAIN_NAME: Name of native domain
54+
# used in forecasts and in constructing the names
55+
# of the post output files. This must be the same
56+
# for both forecasts.
57+
58+
python plot_allvars_diff.py ${CDATE} ${FCST_START} ${FCST_END} ${FCST_INC} \
59+
${EXPTDIR1} ${EXPTDIR2} \
60+
${SHAPE_FILES} \
61+
${POST_OUTPUT_DOMAIN_NAME}

ush/Python/sq_job.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export FCST_START=6
5757
export FCST_END=${FCST_LEN_HRS}
5858
export FCST_INC=6
5959

60-
# Usage statement: Make sure all the necessary modules can be imported.
61-
# Six command line arguments are needed:
60+
# Usage statement: Make sure all the necessary modules can be imported.
61+
# The following command line arguments are needed:
6262
# 1. Cycle date/time in YYYYMMDDHH format
6363
# 2. Starting forecast hour in HHH format
6464
# 3. Ending forecast hour in HHH format
@@ -69,5 +69,10 @@ export FCST_INC=6
6969
# 6. CARTOPY_DIR: Base directory of cartopy shapefiles
7070
# -File structure should be:
7171
# CARTOPY_DIR/shapefiles/natural_earth/cultural/*.shp
72+
# 7. POST_OUTPUT_DOMAIN_NAME: Name of native domain
73+
# used in forecast and in constructing the names
74+
# of the post output files.
7275

73-
python plot_allvars.py ${CDATE} ${FCST_START} ${FCST_END} ${FCST_INC} ${EXPTDIR} ${SHAPE_FILES}
76+
77+
python plot_allvars.py ${CDATE} ${FCST_START} ${FCST_END} ${FCST_INC} \
78+
${EXPTDIR} ${SHAPE_FILES} ${POST_OUTPUT_DOMAIN_NAME}

ush/Python/sq_job_diff.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ SHAPE_FILES=/scratch2/BMC/det/UFS_SRW_app/v1p0/fix_files/NaturalEarth
5252
#Gaea:
5353
#SHAPE_FILES=/lustre/f2/pdata/esrl/gsd/ufs/NaturalEarth
5454

55-
export GLOBAL_VAR_DEFNS_FP="${EXPTDIR}/var_defns.sh"
55+
export GLOBAL_VAR_DEFNS_FP="${EXPTDIR1}/var_defns.sh"
5656
source ${GLOBAL_VAR_DEFNS_FP}
5757
export CDATE=${DATE_FIRST_CYCL}${CYCL_HRS}
5858
export FCST_START=6
5959
export FCST_END=${FCST_LEN_HRS}
6060
export FCST_INC=3
6161

62-
# Usage statement: Make sure all the necessary modules can be imported.
63-
# Seven command line arguments are needed:
62+
# Usage statement: Make sure all the necessary modules can be imported.
63+
# The following command line arguments are needed:
6464
# 1. Cycle date/time in YYYYMMDDHH format
6565
# 2. Starting forecast hour
6666
# 3. Ending forecast hour
@@ -74,5 +74,12 @@ export FCST_INC=3
7474
# 7. CARTOPY_DIR: Base directory of cartopy shapefiles
7575
# -File structure should be:
7676
# CARTOPY_DIR/shapefiles/natural_earth/cultural/*.shp
77+
# 8. POST_OUTPUT_DOMAIN_NAME: Name of native domain
78+
# used in forecasts and in constructing the names
79+
# of the post output files. This must be the same
80+
# for both forecasts.
7781

78-
python plot_allvars_diff.py ${CDATE} ${FCST_START} ${FCST_END} ${FCST_INC} ${EXPTDIR1} ${EXPTDIR2} ${SHAPE_FILES}
82+
python plot_allvars_diff.py ${CDATE} ${FCST_START} ${FCST_END} ${FCST_INC} \
83+
${EXPTDIR1} ${EXPTDIR2} \
84+
${SHAPE_FILES} \
85+
${POST_OUTPUT_DOMAIN_NAME}

ush/config_defaults.sh

+20-16
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,6 @@ WFLOW_LAUNCH_LOG_FN="log.launch_FV3LAM_wflow"
411411
#
412412
#-----------------------------------------------------------------------
413413
#
414-
# Set output file name. Definitions:
415-
#
416-
# POST_OUTPUT_DOMAIN_NAME:
417-
# Domain name used in naming the output files of run_post by UPP or inline post.
418-
# Output file name: $NET.tHHz.[var_name].f###.$POST_OUTPUT_DOMAIN_NAME.grib2
419-
#
420-
#-----------------------------------------------------------------------
421-
#
422-
POST_OUTPUT_DOMAIN_NAME=""
423-
#
424-
#-----------------------------------------------------------------------
425-
#
426414
# Set forecast parameters. Definitions:
427415
#
428416
# DATE_FIRST_CYCL:
@@ -476,8 +464,11 @@ FCST_LEN_HRS="24"
476464
# with the prefix "YYYYMMDD.HHmmSS." in the RESTART directory
477465
#
478466
# WRITE_DOPOST:
479-
# Flag that determines whether or not to use the INLINE POST option
480-
# When TRUE, force to turn off run_post (RUN_TASK_RUN_POST=FALSE) in setup.sh
467+
# Flag that determines whether or not to use the inline post feature
468+
# [i.e. calling the Unified Post Processor (UPP) from within the weather
469+
# model]. If this is set to "TRUE", the RUN_POST_TN task is deactivated
470+
# (i.e. RUN_TASK_RUN_POST is set to "FALSE") to avoid unnecessary
471+
# computations.
481472
#
482473
#-----------------------------------------------------------------------
483474
#
@@ -1749,8 +1740,7 @@ DT_SUBHOURLY_POST_MNTS="00"
17491740
#
17501741
#-----------------------------------------------------------------------
17511742
#
1752-
# Set parameters associated with defining a customized post configuration
1753-
# file.
1743+
# Set parameters for customizing the post-processor (UPP). Definitions:
17541744
#
17551745
# USE_CUSTOM_POST_CONFIG_FILE:
17561746
# Flag that determines whether a user-provided custom configuration file
@@ -1765,10 +1755,24 @@ DT_SUBHOURLY_POST_MNTS="00"
17651755
# used for post-processing. This is only used if CUSTOM_POST_CONFIG_FILE
17661756
# is set to "TRUE".
17671757
#
1758+
# POST_OUTPUT_DOMAIN_NAME:
1759+
# Domain name (in lowercase) used in constructing the names of the output
1760+
# files generated by UPP [which is called either by running the RUN_POST_TN
1761+
# task or by activating the inline post feature (WRITE_DOPOST set to "TRUE")].
1762+
# The post output files are named as follows:
1763+
#
1764+
# $NET.tHHz.[var_name].f###.${POST_OUTPUT_DOMAIN_NAME}.grib2
1765+
#
1766+
# If using a custom grid, POST_OUTPUT_DOMAIN_NAME must be specified by
1767+
# the user. If using a predefined grid, POST_OUTPUT_DOMAIN_NAME defaults
1768+
# to PREDEF_GRID_NAME. Note that this variable is first changed to lower
1769+
# case before being used to construct the file names.
1770+
#
17681771
#-----------------------------------------------------------------------
17691772
#
17701773
USE_CUSTOM_POST_CONFIG_FILE="FALSE"
17711774
CUSTOM_POST_CONFIG_FP=""
1775+
POST_OUTPUT_DOMAIN_NAME=""
17721776
#
17731777
#-----------------------------------------------------------------------
17741778
#

ush/setup.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -1155,9 +1155,6 @@ check_for_preexist_dir_file "$EXPTDIR" "${PREEXISTING_DIR_METHOD}"
11551155
#
11561156
# COMOUT_BASEDIR is not used by the workflow in community mode.
11571157
#
1158-
# POST_OUTPUT_DOMAIN_NAME:
1159-
# The PREDEF_GRID_NAME is set by default.
1160-
#
11611158
#-----------------------------------------------------------------------
11621159
#
11631160
LOGDIR="${EXPTDIR}/log"
@@ -1177,8 +1174,20 @@ else
11771174
COMROOT=""
11781175
COMOUT_BASEDIR=""
11791176
fi
1180-
1177+
#
1178+
#-----------------------------------------------------------------------
1179+
#
1180+
#
1181+
# If POST_OUTPUT_DOMAIN_NAME has not been specified by the user, set it
1182+
# to PREDEF_GRID_NAME (which won't be empty if using a predefined grid).
1183+
# Then change it to lowercase. Finally, ensure that it does not end up
1184+
# getting set to an empty string.
1185+
#
1186+
#-----------------------------------------------------------------------
1187+
#
11811188
POST_OUTPUT_DOMAIN_NAME="${POST_OUTPUT_DOMAIN_NAME:-${PREDEF_GRID_NAME}}"
1189+
POST_OUTPUT_DOMAIN_NAME=$(echo_lowercase ${POST_OUTPUT_DOMAIN_NAME})
1190+
11821191
if [ -z "${POST_OUTPUT_DOMAIN_NAME}" ]; then
11831192
print_err_msg_exit "\
11841193
The domain name used in naming the run_post output files (POST_OUTPUT_DOMAIN_NAME)
@@ -1188,7 +1197,6 @@ If this experiment is not using a predefined grid (i.e. if PREDEF_GRID_NAME
11881197
is set to a null string), POST_OUTPUT_DOMAIN_NAME must be set in the SRW
11891198
App's configuration file (\"${EXPT_CONFIG_FN}\")."
11901199
fi
1191-
POST_OUTPUT_DOMAIN_NAME=$(echo_lowercase ${POST_OUTPUT_DOMAIN_NAME})
11921200
#
11931201
#-----------------------------------------------------------------------
11941202
#

0 commit comments

Comments
 (0)