Skip to content

Commit

Permalink
add obs plot
Browse files Browse the repository at this point in the history
  • Loading branch information
chan-hoo committed Dec 3, 2024
1 parent de0a8d4 commit 6cf57ea
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 51 deletions.
2 changes: 2 additions & 0 deletions jobs/JLANDDA_PREP_OBS
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ fi
mkdir -p ${COMOUT}
export COMOUTobs=${COMOUTobs:-${COMOUT}/obs}
mkdir -p ${COMOUTobs}
export COMOUTplot="${COMOUTplot:-${COMOUT}/plot}"
mkdir -p ${COMOUTplot}

# Create a teomporary share directory
export DATA_SHARE="${DATA_SHARE:-${DATAROOT}/DATA_SHARE/${PDY}}"
Expand Down
2 changes: 0 additions & 2 deletions modulefiles/tasks/hera/task.prep_obs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ load(pathJoin("py-cartopy", py_cartopy_ver))
load(pathJoin("py-matplotlib", py_matplotlib_ver))
load(pathJoin("py-netcdf4", py_netcdf4_ver))
load(pathJoin("py-numpy", py_numpy_ver))
load(pathJoin("py-pandas", py_pandas_ver))
load(pathJoin("py-pyyaml", py_pyyaml_ver))
load(pathJoin("py-xarray", py_xarray_ver))

90 changes: 44 additions & 46 deletions scripts/exlandda_plot_stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,28 @@ nHH=${NTIME:8:2}
# Stats Plot
############################################################

# Path to the directory containing the input file
INPUTFP="${DATA_HOFX}"
# Field variable
FIELDVAR="OMA"
field_var="OMA"
# Field Range for scatter plot: [Low,High]
FRLOW=-300
FRHIGH=300
field_range_low=-300
field_range_high=300
# Number of bins in histogram plot
NBINS=100
nbins=100
# Plot type (scatter/histogram/both)
PLOTTYPE="both"
plottype="both"
# Figure title
FIGTITLE="GHCN Snow Depth (mm)::Obs-Ana::${PDY}"
title_fig="GHCN Snow Depth (mm)::Obs-Ana::${PDY}"
# Prefix of output file name
PREOUTFN="hofx_oma_${PDY}"
output_prefix="hofx_oma_${PDY}"

cat > plot_hofx.yaml <<EOF
hofx_files: '${INPUTFP}'
field_var: '${FIELDVAR}'
field_range: [${FRLOW},${FRHIGH}]
nbins: ${NBINS}
plottype: '${PLOTTYPE}'
title_fig: '${FIGTITLE}'
output_prefix: '${PREOUTFN}'
hofx_files: '${DATA_HOFX}'
field_var: '${field_var}'
field_range: [${field_range_low},${field_range_high}]
nbins: ${nbins}
plottype: '${plottype}'
title_fig: '${title_fig}'
output_prefix: '${output_prefix}'
machine: '${MACHINE}'
EOF

Expand All @@ -52,35 +50,35 @@ if [ $? -ne 0 ]; then
fi

# Copy result files to COMOUT
cp -p ${PREOUTFN}* ${COMOUTplot}
cp -p ${output_prefix}* ${COMOUTplot}


############################################################
# Time-history Plot
############################################################

FN_DATA_ANAL_PREFIX="analysis_"
FN_DATA_ANAL_SUFFIX=".log"
FN_DATA_FCST_PREFIX="forecast_"
FN_DATA_FCST_SUFFIX=".log"
OUT_TITLE_ANAL_BASE="Land-DA::Analysis::QC SnowDepthGHCN::"
OUT_FN_ANAL_BASE="landda_timehistory_"
OUT_TITLE_TIME="Land-DA::Wall-clock time"
OUT_FN_TIME="landda_timehistory_wtime"
fn_data_anal_prefix="analysis_"
fn_data_anal_suffix=".log"
fn_data_fcst_prefix="forecast_"
fn_data_fcst_suffix=".log"
out_title_anal_base="Land-DA::Analysis::QC SnowDepthGHCN::"
out_fn_anal_base="landda_timehistory_"
out_title_time="Land-DA::Wall-clock time"
out_fn_time="landda_timehistory_wtime"

cat > plot_timehistory.yaml <<EOF
path_data: '${LOGDIR}'
work_dir: '${DATA}'
fn_data_anal_prefix: '${FN_DATA_ANAL_PREFIX}'
fn_data_anal_suffix: '${FN_DATA_ANAL_SUFFIX}'
fn_data_fcst_prefix: '${FN_DATA_FCST_PREFIX}'
fn_data_fcst_suffix: '${FN_DATA_FCST_SUFFIX}'
fn_data_anal_prefix: '${fn_data_anal_prefix}'
fn_data_anal_suffix: '${fn_data_anal_suffix}'
fn_data_fcst_prefix: '${fn_data_fcst_prefix}'
fn_data_fcst_suffix: '${fn_data_fcst_suffix}'
nprocs_anal: '${NPROCS_ANALYSIS}'
nprocs_fcst: '${NPROCS_FORECAST}'
out_title_anal_base: '${OUT_TITLE_ANAL_BASE}'
out_fn_anal_base: '${OUT_FN_ANAL_BASE}'
out_title_time: '${OUT_TITLE_TIME}'
out_fn_time: '${OUT_FN_TIME}'
out_title_anal_base: '${out_title_anal_base}'
out_fn_anal_base: '${out_fn_anal_base}'
out_title_time: '${out_title_time}'
out_fn_time: '${out_fn_time}'
EOF

${USHlandda}/plot_analysis_timehistory.py
Expand All @@ -89,28 +87,28 @@ if [ $? -ne 0 ]; then
fi

# Copy result files to COMOUT
cp -p ${OUT_FN_ANAL_BASE}* ${COMOUTplot}
cp -p ${OUT_FN_TIME}* ${COMOUTplot}
cp -p ${out_fn_anal_base}* ${COMOUTplot}
cp -p ${out_fn_time}* ${COMOUTplot}


############################################################
# Restart Plot
############################################################

FN_DATA_BASE="ufs_land_restart.${nYYYY}-${nMM}-${nDD}_${nHH}-00-00.tile"
FN_DATA_EXT=".nc"
SOIL_LEVEL_NUMBER="1"
OUT_TITLE_BASE="Land-DA::restart::${nYYYY}-${nMM}-${nDD}_${nHH}::"
OUT_FN_BASE="landda_out_restart_${nYYYY}-${nMM}-${nDD}_${nHH}_"
fn_data_base="ufs_land_restart.${nYYYY}-${nMM}-${nDD}_${nHH}-00-00.tile"
fn_data_ext=".nc"
soil_level_number="1"
out_title_base="Land-DA::restart::${nYYYY}-${nMM}-${nDD}_${nHH}::"
out_fn_base="landda_out_restart_${nYYYY}-${nMM}-${nDD}_${nHH}_"

cat > plot_restart.yaml <<EOF
path_data: '${COMIN}/RESTART'
work_dir: '${DATA}'
fn_data_base: '${FN_DATA_BASE}'
fn_data_ext: '${FN_DATA_EXT}'
soil_lvl_number: '${SOIL_LEVEL_NUMBER}'
out_title_base: '${OUT_TITLE_BASE}'
out_fn_base: '${OUT_FN_BASE}'
fn_data_base: '${fn_data_base}'
fn_data_ext: '${fn_data_ext}'
soil_lvl_number: '${soil_level_number}'
out_title_base: '${out_title_base}'
out_fn_base: '${out_fn_base}'
machine: '${MACHINE}'
EOF

Expand All @@ -120,5 +118,5 @@ if [ $? -ne 0 ]; then
fi

# Copy result files to COMOUT
cp -p ${OUT_FN_BASE}* ${COMOUTplot}
cp -p ${out_fn_base}* ${COMOUTplot}

29 changes: 26 additions & 3 deletions scripts/exlandda_prep_obs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if [ "${OBS_GHCN}" = "YES" ]; then
# check obs is available
if [ -f "${obs_fp}" ]; then
echo "GHCN observation file: ${obs_fp}"
cp -p "${obs_fp}" .
cp -p "${obs_fp}" "${COMOUTobs}/${out_fn}"
else
input_ghcn_file="${DATA_GHCN_RAW}/${YYYP}.csv"
Expand All @@ -36,14 +37,36 @@ if [ "${OBS_GHCN}" = "YES" ]; then
echo "GHCN raw data file: ${YYYP}.csv"
err_exit "GHCN raw data file does not exist in designated path !!!"
fi
output_ioda_file="${obs_fn}"
ghcn_station_file="${DATA_GHCN_RAW}/ghcnd-stations.txt"

${USHlandda}/ghcn_snod2ioda.py -i ${input_ghcn_file} -o ${output_ioda_file} -f ${ghcn_station_file} -d ${YYYP}${MP}${DP}${HP} -m maskout
${USHlandda}/ghcn_snod2ioda.py -i ${input_ghcn_file} -o ${obs_fn} -f ${ghcn_station_file} -d ${YYYP}${MP}${DP}${HP} -m maskout
if [ $? -ne 0 ]; then
err_exit "Generation of GHCN obs file failed !!!"
fi
cp -p "${output_ioda_file}" "${COMOUTobs}/${out_fn}"
cp -p "${obs_fn}" "${COMOUTobs}/${out_fn}"
fi

############################################################
# Observation File Plot
############################################################

out_title_base="Land-DA::Obs::GHCN::${PDY}::"
out_fn_base="landda_obs_ghcn_${PDY}_"

cat > plot_obs_ghcn.yaml <<EOF
work_dir: '${DATA}'
fn_input: '${obs_fn}'
out_title_base: '${out_title_base}'
out_fn_base: '${out_fn_base}'
machine: '${MACHINE}'
EOF

${USHlandda}/plot_obs_ghcn.py
if [ $? -ne 0 ]; then
err_exit "Observation file plot failed"
fi

# Copy result file to COMOUT
cp -p ${out_fn_base}* ${COMOUTplot}

fi
Loading

0 comments on commit 6cf57ea

Please sign in to comment.