Skip to content

Commit

Permalink
Avoid positional arguments in the plotting scripts.
Browse files Browse the repository at this point in the history
Some bug fixes.
  • Loading branch information
danielabdi-noaa committed Nov 16, 2022
1 parent 856df5b commit 886eedb
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 48 deletions.
30 changes: 15 additions & 15 deletions jobs/JREGIONAL_PLOT_ALLVARS
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ fi

# plot all variables
$SCRIPTSdir/exregional_plot_allvars.py \
${CDATE} \
${PLOT_FCST_START} \
${PLOT_FCST_END:-$FCST_LEN_HRS} \
${PLOT_FCST_INC:-1} \
${COMOUT} \
${FIXshp} \
${GRID_NAME} || \
--cycle ${CDATE} \
--start ${PLOT_FCST_START} \
--end ${PLOT_FCST_END:-$FCST_LEN_HRS} \
--inc ${PLOT_FCST_INC:-1} \
--comout ${COMOUT} \
--cartopy ${FIXshp} \
--domain ${GRID_NAME} || \
print_err_msg_exit "\
Call to ex-script corresponding to J-job \"${scrfunc_fn}\" failed."

# plot all variables diff with baseline
if [ ! -z $COMOUT_REF ]; then
$SCRIPTSdir/exregional_plot_allvars_diff.py \
${CDATE} \
${PLOT_FCST_START} \
${PLOT_FCST_END:-$FCST_LEN_HRS} \
${PLOT_FCST_INC:-1} \
${COMOUT} \
${COMOUT_REF} \
${FIXshp} \
${GRID_NAME} || \
--cycle ${CDATE} \
--start ${PLOT_FCST_START} \
--end ${PLOT_FCST_END:-$FCST_LEN_HRS} \
--inc ${PLOT_FCST_INC:-1} \
--comout-1 ${COMOUT} \
--comout-2 ${COMOUT_REF} \
--cartopy ${FIXshp} \
--domain ${GRID_NAME} || \
print_err_msg_exit "\
Call to ex-script corresponding to J-job \"${scrfunc_fn}\" failed."
fi
Expand Down
2 changes: 2 additions & 0 deletions parm/FV3LAM_wflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ the <task> tag to be identical to the ones above for other output times.
<envar><name>cyc</name><value><cyclestr>@H</cyclestr></value></envar>
<envar><name>subcyc</name><value><cyclestr>@M</cyclestr></value></envar>
<envar><name>LOGDIR</name><value>&LOGDIR;</value></envar>
<envar><name>SLASH_ENSMEM_SUBDIR</name><value><cyclestr>{{ slash_ensmem_subdir }}</cyclestr></value></envar>
<envar><name>ENSMEM_INDX</name><value><cyclestr>#{{ ensmem_indx_name }}#</cyclestr></value></envar>

<dependency>
{%- if write_dopost %}
Expand Down
60 changes: 45 additions & 15 deletions scripts/exregional_plot_allvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,51 @@ def rotate_wind(true_lat, lov_lon, earth_lons, uin, vin, proj, inverse=False):

# -------------Start of script -------------------------#

# Define required positional arguments
parser = argparse.ArgumentParser()
parser.add_argument("Cycle date/time in YYYYMMDDHH format")
parser.add_argument("Starting forecast hour")
parser.add_argument("Ending forecast hour")
parser.add_argument("Forecast hour increment")
parser.add_argument("Path to experiment directory")
parser.add_argument("Path to base directory of cartopy shapefiles")
parser.add_argument(
"Name of native domain used in forecast (and in constructing post file names)"
"--cycle",
"-c",
help="Cycle date/time in YYYYMMDDHH format.",
required=True,
)
parser.add_argument(
"--start",
"-s",
help="Starting forecast hour.",
required=True,
)
parser.add_argument(
"--end",
"-e",
help="Ending forecast hour.",
required=True,
)
parser.add_argument(
"--inc",
"-i",
help="Increment forecast hour.",
required=True,
)
parser.add_argument(
"--comout",
help="Path to directory containing post-processed files.",
required=True,
)
parser.add_argument(
"--cartopy-dir",
help="Path to base directory of cartopy shapefiles.",
required=True,
)
parser.add_argument(
"--domain",
"-d",
help="Name of native domain used in forecast (and in constructing post file names).",
required=True,
)
args = parser.parse_args()

# Read date/time, forecast hour, and directory paths from command line
ymdh = str(sys.argv[1])
ymdh = str(args.cycle)
ymd = ymdh[0:8]
year = int(ymdh[0:4])
month = int(ymdh[4:6])
Expand All @@ -274,19 +304,19 @@ def rotate_wind(true_lat, lov_lon, earth_lons, uin, vin, proj, inverse=False):
print(year, month, day, hour)

# Define the range of forecast hours to create plots for
start_fhr = int(sys.argv[2])
end_fhr = int(sys.argv[3])
increment_fhr = int(sys.argv[4])
start_fhr = int(args.start)
end_fhr = int(args.end)
increment_fhr = int(args.inc)
if (start_fhr == end_fhr) or (increment_fhr == 0):
fhours = [start_fhr]
else:
num = int(((end_fhr - start_fhr) / increment_fhr) + 1)
fhours = np.linspace(start_fhr, end_fhr, num, dtype="int")
print(fhours)

COMOUT = str(sys.argv[5])
CARTOPY_DIR = str(sys.argv[6])
POST_OUTPUT_DOMAIN_NAME = str(sys.argv[7]).lower()
COMOUT = str(args.comout)
CARTOPY_DIR = str(args.cartopy_dir)
POST_OUTPUT_DOMAIN_NAME = str(args.domain).lower()

# Loop over forecast hours
for fhr in fhours:
Expand Down
67 changes: 51 additions & 16 deletions scripts/exregional_plot_allvars_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,55 @@ def rotate_wind(true_lat, lov_lon, earth_lons, uin, vin, proj, inverse=False):

# Define required positional arguments
parser = argparse.ArgumentParser()
parser.add_argument("Cycle date/time in YYYYMMDDHH format")
parser.add_argument("Starting forecast hour")
parser.add_argument("Ending forecast hour")
parser.add_argument("Forecast hour increment")
parser.add_argument("Path to experiment 1 directory")
parser.add_argument("Path to experiment 2 directory")
parser.add_argument("Path to base directory of cartopy shapefiles")
parser.add_argument(
"Name of native domain used in forecasts (and in constructing post file names)"
"--cycle",
"-c",
help="Cycle date/time in YYYYMMDDHH format.",
required=True,
)
parser.add_argument(
"--start",
"-s",
help="Starting forecast hour.",
required=True,
)
parser.add_argument(
"--end",
"-e",
help="Ending forecast hour.",
required=True,
)
parser.add_argument(
"--inc",
"-i",
help="Increment forecast hour.",
required=True,
)
parser.add_argument(
"--comout-1",
help="Path to directory 1 containing post-processed files.",
required=True,
)
parser.add_argument(
"--comout-2",
help="Path to directory 2 containing post-processed files.",
required=True,
)
parser.add_argument(
"--cartopy-dir",
help="Path to base directory of cartopy shapefiles.",
required=True,
)
parser.add_argument(
"--domain",
"-d",
help="Name of native domain used in forecast (and in constructing post file names).",
required=True,
)
args = parser.parse_args()

# Read date/time, forecast hour, and directory paths from command line
ymdh = str(sys.argv[1])
ymdh = str(args.cycle)
ymd = ymdh[0:8]
year = int(ymdh[0:4])
month = int(ymdh[4:6])
Expand All @@ -278,20 +313,20 @@ def rotate_wind(true_lat, lov_lon, earth_lons, uin, vin, proj, inverse=False):
print(year, month, day, hour)

# Define the range of forecast hours to create plots for
start_fhr = int(sys.argv[2])
end_fhr = int(sys.argv[3])
increment_fhr = int(sys.argv[4])
start_fhr = int(args.start)
end_fhr = int(args.end)
increment_fhr = int(args.inc)
if (start_fhr == end_fhr) or (increment_fhr == 0):
fhours = [start_fhr]
else:
num = int(((end_fhr - start_fhr) / increment_fhr) + 1)
fhours = np.linspace(start_fhr, end_fhr, num, dtype="int")
print(fhours)

COMOUT_1 = str(sys.argv[5])
COMOUT_2 = str(sys.argv[6])
CARTOPY_DIR = str(sys.argv[7])
POST_OUTPUT_DOMAIN_NAME = str(sys.argv[8]).lower()
COMOUT_1 = str(args.comout_1)
COMOUT_2 = str(args.comout_2)
CARTOPY_DIR = str(args.cartopy_dir)
POST_OUTPUT_DOMAIN_NAME = str(args.domain).lower()

# Loop over forecast hours
for fhr in fhours:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ workflow:
DATE_LAST_CYCL: '2019070100'
FCST_LEN_HRS: 6
PREEXISTING_DIR_METHOD: rename
workflow_switche:
workflow_switches:
RUN_TASK_PLOT_ALLVARS: true
task_get_extrn_ics:
EXTRN_MDL_NAME_ICS: FV3GFS
Expand Down
3 changes: 2 additions & 1 deletion ush/config_defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,8 @@ task_plot_allvars:
PPN_PLOT_ALLVARS: 24
WTIME_PLOT_ALLVARS: 00:20:00
MAXTRIES_PLOT_ALLVARS: 1
# reference experiment directory
# Reference experiment's COMOUT directory.
# This is where the GRIB2 from post are locatd
COMOUT_REF: ""
# Plot fcts start and increment
PLOT_FCST_START: 0
Expand Down

0 comments on commit 886eedb

Please sign in to comment.