From 662ff2ae4679e09305140deadaf84f30d036597d Mon Sep 17 00:00:00 2001 From: danielabdi-noaa <52012304+danielabdi-noaa@users.noreply.github.com> Date: Fri, 14 Apr 2023 13:30:42 -0600 Subject: [PATCH] [develop] Add radar reflectivity task. (#638) Add process_radarref task from RRFS_dev1. --------- Co-authored-by: Edward Snyder --- jobs/JREGIONAL_PROCESS_RADARREF | 118 +++++++++ scripts/exregional_process_radarref.sh | 325 +++++++++++++++++++++++++ ush/config_defaults.yaml | 39 ++- ush/machine/wcoss2.yaml | 2 + ush/wrappers/run_process_radarref.sh | 13 + 5 files changed, 496 insertions(+), 1 deletion(-) create mode 100755 jobs/JREGIONAL_PROCESS_RADARREF create mode 100755 scripts/exregional_process_radarref.sh create mode 100755 ush/wrappers/run_process_radarref.sh diff --git a/jobs/JREGIONAL_PROCESS_RADARREF b/jobs/JREGIONAL_PROCESS_RADARREF new file mode 100755 index 0000000000..2aaefa66eb --- /dev/null +++ b/jobs/JREGIONAL_PROCESS_RADARREF @@ -0,0 +1,118 @@ +#!/bin/bash + + +# +#----------------------------------------------------------------------- +# +# This J-JOB script runs the radar reflectivity preprocess +# for the FV3-LAM model +# +# Description: +# +# RRFS runs a pre-processing task on MRMS radar reflectivity files. +# Specifically the process_radarref task executes process_NSSL_mosaic.exe +# from rrfs-utl on files +# like MergedReflectivityQC_00.50_${YYYY}${MM}${DD}-${HH}${min}${ss}.grib2. +# +# Arguments needed for the corresponding ex-script +# +# FIXgsi +# OBSPATH_NSSLMOSIAC +# DO_SPINUP +# CYCLE_TYPE +# CYCL_HRS_SPINSTART +# CYCL_HRS_PRODSTART +# IO_LAYOUT_Y +# RADARREF_TIMELEVEL +# RADARREF_MINS +# RADAR_REF_THINNING +# OBS_SUFFIX +# +#----------------------------------------------------------------------- +# + +# +#----------------------------------------------------------------------- +# +# Source the variable definitions file and the bash utility functions. +# +#----------------------------------------------------------------------- +# +. $USHdir/source_util_funcs.sh +source_config_for_task "task_process_radarref" ${GLOBAL_VAR_DEFNS_FP} +. $USHdir/job_preamble.sh "TRUE" +# +#----------------------------------------------------------------------- +# +# Save current shell options (in a global array). Then set new options +# for this script/function. +# +#----------------------------------------------------------------------- +# +{ save_shell_opts; . $USHdir/preamble.sh; } > /dev/null 2>&1 +# +#----------------------------------------------------------------------- +# +# Get the full path to the file in which this script/function is located +# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in +# which the file is located (scrfunc_dir). +# +#----------------------------------------------------------------------- +# +scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fn=$( basename "${scrfunc_fp}" ) +scrfunc_dir=$( dirname "${scrfunc_fp}" ) +# +#----------------------------------------------------------------------- +# +# Print message indicating entry into script. +# +#----------------------------------------------------------------------- +# +print_info_msg " +======================================================================== +Entering script: \"${scrfunc_fn}\" +In directory: \"${scrfunc_dir}\" +This is the J-job script for the task that runs a radar reflectivity +preprocess with FV3 for the specified cycle. +========================================================================" +# +#----------------------------------------------------------------------- +# +# Create the working directory under the cycle directory. +# +#----------------------------------------------------------------------- +# +if [ ${CYCLE_TYPE} == "spinup" ]; then + DATA="${DATA:-${COMIN}/process_radarref_spinup}" +else + DATA="${DATA:-${COMIN}/process_radarref}" +fi +mkdir_vrfy -p ${DATA} +# +#----------------------------------------------------------------------- +# +# Call the ex-script for this J-job and pass to it the necessary varia- +# bles. +# +#----------------------------------------------------------------------- +# +$SCRIPTSdir/exregional_process_radarref.sh || print_err_msg_exit "\ +Call to ex-script corresponding to J-job \"${scrfunc_fn}\" failed." +# +#----------------------------------------------------------------------- +# +# Run job postamble. +# +#----------------------------------------------------------------------- +# +job_postamble +# +#----------------------------------------------------------------------- +# +# Restore the shell options saved at the beginning of this script/func- +# tion. +# +#----------------------------------------------------------------------- +# +{ restore_shell_opts; } > /dev/null 2>&1 diff --git a/scripts/exregional_process_radarref.sh b/scripts/exregional_process_radarref.sh new file mode 100755 index 0000000000..5fef67c0f3 --- /dev/null +++ b/scripts/exregional_process_radarref.sh @@ -0,0 +1,325 @@ +#!/bin/bash + +# +#----------------------------------------------------------------------- +# +# Source the variable definitions file and the bash utility functions. +# +#----------------------------------------------------------------------- +# +. $USHdir/source_util_funcs.sh +source_config_for_task "task_process_radarref|task_run_fcst" ${GLOBAL_VAR_DEFNS_FP} +# +#----------------------------------------------------------------------- +# +# Save current shell options (in a global array). Then set new options +# for this script/function. +# +#----------------------------------------------------------------------- +# +{ save_shell_opts; . $USHdir/preamble.sh; } > /dev/null 2>&1 +# +#----------------------------------------------------------------------- +# +# Get the full path to the file in which this script/function is located +# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in +# which the file is located (scrfunc_dir). +# +#----------------------------------------------------------------------- +# +scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fn=$( basename "${scrfunc_fp}" ) +scrfunc_dir=$( dirname "${scrfunc_fp}" ) +# +#----------------------------------------------------------------------- +# +# Print message indicating entry into script. +# +#----------------------------------------------------------------------- +# +print_info_msg " +======================================================================== +Entering script: \"${scrfunc_fn}\" +In directory: \"${scrfunc_dir}\" +This is the ex-script for the task that runs radar reflectivity preprocess +with FV3 for the specified cycle. +========================================================================" +# +#----------------------------------------------------------------------- +# +# Load modules. +# +#----------------------------------------------------------------------- +# +eval ${PRE_TASK_CMDS} + +nprocs=$(( NNODES_PROCESS_RADARREF*PPN_PROCESS_RADARREF)) + +# +#----------------------------------------------------------------------- +# +# Extract from CDATE the starting year, month, day, and hour of the +# forecast. These are needed below for various operations. +# +#----------------------------------------------------------------------- +# +START_DATE=$(echo "${PDY} ${cyc}") +YYYYMMDDHH=$(date +%Y%m%d%H -d "${START_DATE}") + +YYYY=${YYYYMMDDHH:0:4} +MM=${YYYYMMDDHH:4:2} +DD=${YYYYMMDDHH:6:2} +HH=${YYYYMMDDHH:8:2} + +# +#----------------------------------------------------------------------- +# +# Find cycle type: cold or warm +# BKTYPE=0: warm start +# BKTYPE=1: cold start +# +#----------------------------------------------------------------------- +# +BKTYPE=0 +if [ ${DO_SPINUP} == "TRUE" ]; then + if [ ${CYCLE_TYPE} == "spinup" ]; then + if [[ ${CYCL_HRS_SPINSTART[@]} =~ "$HH" ]] ; then + BKTYPE=1 + fi + fi +else + if [[ ${CYCL_HRS_PRODSTART[@]} =~ "$HH" ]] ; then + BKTYPE=1 + fi +fi + +n_iolayouty=$(($IO_LAYOUT_Y-1)) + +# +#----------------------------------------------------------------------- +# +# Loop through different time levels +# Get into working directory +# +#----------------------------------------------------------------------- +# +print_info_msg "$VERBOSE" " +Getting into working directory for radar reflectivity process ..." + +for timelevel in ${RADARREFL_TIMELEVEL[@]}; do + timelevel=$( printf %2.2i $timelevel ) + mkdir_vrfy ${DATA}/${timelevel} + cd ${DATA}/${timelevel} + + pregen_grid_dir=$DOMAIN_PREGEN_BASEDIR/${PREDEF_GRID_NAME} + + print_info_msg "$VERBOSE" "pregen_grid_dir is $pregen_grid_dir" + +# +#----------------------------------------------------------------------- +# +# link or copy background files +# +#----------------------------------------------------------------------- + + if [ ${BKTYPE} -eq 1 ]; then + cp_vrfy ${pregen_grid_dir}/fv3_grid_spec fv3sar_grid_spec.nc + else + if [ "${IO_LAYOUT_Y}" == "1" ]; then + cp_vrfy ${pregen_grid_dir}/fv3_grid_spec fv3sar_grid_spec.nc + else + for iii in $(seq -w 0 $(printf %4.4i $n_iolayouty)) + do + cp_vrfy ${pregen_grid_dir}/fv3_grid_spec.${iii} fv3sar_grid_spec.nc.${iii} + done + fi + fi + +# +#----------------------------------------------------------------------- +# +# link/copy observation files to working directory +# +#----------------------------------------------------------------------- + + NSSL=${OBSPATH_NSSLMOSIAC} + + mrms="MergedReflectivityQC" + +# Link to the MRMS operational data + echo "timelevel = ${timelevel}" + echo "RADARREFL_MINS = ${RADARREFL_MINS[@]}" + +# Link to the MRMS operational data +# This loop finds files closest to the given "timelevel" + for min in ${RADARREFL_MINS[@]} + do + min=$( printf %2.2i $((timelevel+min)) ) + echo "Looking for data valid:"${YYYY}"-"${MM}"-"${DD}" "${HH}":"${min} + sec=0 + while [[ $sec -le 59 ]]; do + ss=$(printf %2.2i ${sec}) + nsslfile=${NSSL}/*${mrms}_00.50_${YYYY}${MM}${DD}-${HH}${min}${ss}.${OBS_SUFFIX} + if [ -s $nsslfile ]; then + echo 'Found '${nsslfile} + nsslfile1=*${mrms}_*_${YYYY}${MM}${DD}-${HH}${min}*.${OBS_SUFFIX} + numgrib2=$(ls ${NSSL}/${nsslfile1} | wc -l) + echo 'Number of GRIB-2 files: '${numgrib2} + if [ ${numgrib2} -ge 10 ] && [ ! -e filelist_mrms ]; then + cp ${NSSL}/${nsslfile1} . + ls ${nsslfile1} > filelist_mrms + echo 'Creating links for ${YYYY}${MM}${DD}-${HH}${min}' + fi + fi + ((sec+=1)) + done + done + + if [ -s filelist_mrms ]; then + + if [ ${OBS_SUFFIX} == "grib2.gz" ]; then + gzip -d *.gz + mv filelist_mrms filelist_mrms_org + ls MergedReflectivityQC_*_${YYYY}${MM}${DD}-${HH}????.grib2 > filelist_mrms + fi + + numgrib2=$(more filelist_mrms | wc -l) + print_info_msg "$VERBOSE" "Using radar data from: `head -1 filelist_mrms | cut -c10-15`" + print_info_msg "$VERBOSE" "NSSL grib2 file levels = $numgrib2" + else + # remove filelist_mrms if zero bytes + rm -f filelist_mrms + + echo "WARNING: Not enough radar reflectivity files available for loop ${timelevel}." + continue + fi + + +#----------------------------------------------------------------------- +# +# copy bufr table from fix directory +# +#----------------------------------------------------------------------- + BUFR_TABLE=${FIXgsi}/prepobs_prep_RAP.bufrtable + + cp_vrfy $BUFR_TABLE prepobs_prep.bufrtable + +#----------------------------------------------------------------------- +# +# Build namelist and run executable +# +# tversion : data source version +# = 1 NSSL 1 tile grib2 for single level +# = 4 NSSL 4 tiles binary +# = 8 NSSL 8 tiles netcdf +# fv3_io_layout_y : subdomain of restart files +# analysis_time : process obs used for this analysis date (YYYYMMDDHH) +# dataPath : path of the radar reflectivity mosaic files. +# +#----------------------------------------------------------------------- + +if [ ${BKTYPE} -eq 1 ]; then + n_iolayouty=1 +else + n_iolayouty=$(($IO_LAYOUT_Y)) +fi + +cat << EOF > namelist.mosaic + &setup + tversion=1, + analysis_time = ${YYYYMMDDHH}, + dataPath = './', + fv3_io_layout_y=${n_iolayouty}, + / +EOF + +if [ ${RADAR_REF_THINNING} -eq 2 ]; then + # heavy data thinning, typically used for EnKF + precipdbzhorizskip=1 + precipdbzvertskip=2 + clearairdbzhorizskip=5 + clearairdbzvertskip=-1 +else + if [ ${RADAR_REF_THINNING} -eq 1 ]; then + # light data thinning, typically used for hybrid EnVar + precipdbzhorizskip=0 + precipdbzvertskip=0 + clearairdbzhorizskip=1 + clearairdbzvertskip=1 + else + # no data thinning + precipdbzhorizskip=0 + precipdbzvertskip=0 + clearairdbzhorizskip=0 + clearairdbzvertskip=0 + fi +fi + +cat << EOF > namelist.mosaic_netcdf + &setup_netcdf + output_netcdf = .true., + max_height = 11001.0, + use_clear_air_type = .true., + precip_dbz_thresh = 10.0, + clear_air_dbz_thresh = 5.0, + clear_air_dbz_value = 0.0, + precip_dbz_horiz_skip = ${precipdbzhorizskip}, + precip_dbz_vert_skip = ${precipdbzvertskip}, + clear_air_dbz_horiz_skip = ${clearairdbzhorizskip}, + clear_air_dbz_vert_skip = ${clearairdbzvertskip}, + / +EOF + +# +#----------------------------------------------------------------------- +# +# Copy the executable to the run directory. +# +#----------------------------------------------------------------------- +# + exec_fn="process_NSSL_mosaic.exe" + exec_fp="$EXECdir/${exec_fn}" + + if [ ! -f "${exec_fp}" ]; then + print_err_msg_exit "\ + The executable specified in exec_fp does not exist: + exec_fp = \"$exec_fp\" + Build lightning process and rerun." + fi + +# +# +#----------------------------------------------------------------------- +# +# Run the process. +# +#----------------------------------------------------------------------- +# + PREP_STEP + eval $RUN_CMD_UTILS ${exec_fp} ${REDIRECT_OUT_ERR} || print_info_msg "\ + Call to executable to run radar refl process returned with nonzero exit code." + POST_STEP + +done # done with the timelevel for-loop +# +#----------------------------------------------------------------------- +# +# Print message indicating successful completion of script. +# +#----------------------------------------------------------------------- +# +print_info_msg " +======================================================================== +RADAR REFL PROCESS completed successfully!!! +Exiting script: \"${scrfunc_fn}\" +In directory: \"${scrfunc_dir}\" +========================================================================" +# +#----------------------------------------------------------------------- +# +# Restore the shell options saved at the beginning of this script/func- +# tion. +# +#----------------------------------------------------------------------- +# +{ restore_shell_opts; } > /dev/null 2>&1 diff --git a/ush/config_defaults.yaml b/ush/config_defaults.yaml index 3afefa3b72..fdc4ec3586 100644 --- a/ush/config_defaults.yaml +++ b/ush/config_defaults.yaml @@ -445,10 +445,13 @@ platform: # # Setup default observation locations for data assimilation: # - # LIGHTNING_ROOT: location of lightning observations + # OBSPATH_NSSLMOSIAC: location of NSSL radar reflectivity + # + # LIGHTNING_ROOT: location of lightning observations # #----------------------------------------------------------------------- # + OBSPATH_NSSLMOSIAC: "" LIGHTNING_ROOT: "" #----------------------------- @@ -864,6 +867,13 @@ workflow: # run. By default, set it to a 1-item list containing the standard # fcst length. # + # CYCL_HRS_SPINSTART: + # An array containing the hours of the day at which the spin up cycle starts. + # + # CYCL_HRS_PRODSTART: + # An array containing the hours of the day at which the product cycle starts, + # from cold start input or from spin-up cycle forcast + # #----------------------------------------------------------------------- # DATE_FIRST_CYCL: "YYYYMMDDHH" @@ -874,6 +884,8 @@ workflow: - '{{ FCST_LEN_HRS }}' LONG_FCST_LEN: '{% if FCST_LEN_HRS < 0 %}{{ FCST_LEN_CYCL|max }}{% else %}{{ FCST_LEN_HRS }}{% endif %}' + CYCL_HRS_SPINSTART: [] + CYCL_HRS_PRODSTART: [] # #----------------------------------------------------------------------- # @@ -1584,6 +1596,7 @@ task_run_fcst: NNODES_RUN_FCST: '{{ (PE_MEMBER01 + PPN_RUN_FCST - 1) // PPN_RUN_FCST }}' PPN_RUN_FCST: '{{ platform.NCORES_PER_NODE // OMP_NUM_THREADS_RUN_FCST }}' FV3_EXEC_FP: '{{ [user.EXECdir, workflow.FV3_EXEC_FN]|path_join }}' + IO_LAYOUT_Y: 1 # #----------------------------------------------------------------------- # @@ -1977,6 +1990,30 @@ task_plot_allvars: #------------------------------------------------------------------------------- PLOT_DOMAINS: ["conus"] +#---------------------------- +# PROCESS RADARREF config parameters +#----------------------------- +task_process_radarref: + RADAR_REF_THINNING: 1 + # + #----------------------------------------------------------------------- + # + # Parameters for observation preprocess. + # RADARREFL_MINS: + # minute from the hour that the NSSL mosaic files will be searched for + # data preprocess + # RADARREFL_TIMELEVEL: + # time level (minute) from the hour that the NSSL mosaic files will be generated + # + # OBS_SUFFIX + # machine specific grib2 file name extension (grib2 or grib2.gz) + # + #----------------------------------------------------------------------- + # + RADARREFL_MINS: [0, 1, 2, 3] + RADARREFL_TIMELEVEL: [0] + OBS_SUFFIX: grib2 + #---------------------------- # PROCESS BUFR config parameters #----------------------------- diff --git a/ush/machine/wcoss2.yaml b/ush/machine/wcoss2.yaml index e78f972d23..9f8393bb23 100644 --- a/ush/machine/wcoss2.yaml +++ b/ush/machine/wcoss2.yaml @@ -33,6 +33,8 @@ platform: COMINgfs: /lfs/h1/ops/prod/com/gfs/v16.3 COMINgefs: /lfs/h1/ops/prod/com/gefs/v12.3 COMINairnow: /lfs/h1/ops/prod/dcom +task_process_radarref: + OBS_SUFFIX: grib2.gz task_process_bufr: OBSPATH_TEMPLATE: '${OBSPATH}/${obs_source}.${YYYYMMDD}/${obs_source}' data: diff --git a/ush/wrappers/run_process_radarref.sh b/ush/wrappers/run_process_radarref.sh new file mode 100755 index 0000000000..694b79b4f8 --- /dev/null +++ b/ush/wrappers/run_process_radarref.sh @@ -0,0 +1,13 @@ +#!/bin/sh +export GLOBAL_VAR_DEFNS_FP="${EXPTDIR}/var_defns.sh" +set -xa +source ${GLOBAL_VAR_DEFNS_FP} +export CDATE=${DATE_FIRST_CYCL} +export CYCLE_DIR=${EXPTDIR}/${CDATE} +export cyc=${DATE_FIRST_CYCL:8:2} +export PDY=${DATE_FIRST_CYCL:0:8} +export SLASH_ENSMEM_SUBDIR="" +export CYCLE_TYPE="" + +${JOBSdir}/JREGIONAL_PROCESS_RADARREF +