From 5f5b15284be47c790bb6936cff077b29a3c08516 Mon Sep 17 00:00:00 2001 From: "Chan-Hoo.Jeon-NOAA" <60152248+chan-hoo@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:59:10 -0400 Subject: [PATCH] Add time-history plots for stats (#151) * add python for plotting time-history * update scripts * fix wrong parms * fix incorrect var names * fix missing env * remove legend from plot * add nobs plot * change we2e_vav to we2e_test * remove templates for plot and set yaml with cat eof --- modulefiles/tasks/hera/task.plot_stats.lua | 1 + parm/land_analysis_hera.yaml | 11 +- parm/land_analysis_hercules.yaml | 11 +- parm/land_analysis_orion.yaml | 11 +- parm/templates/template.plot_hofx.yaml | 8 - parm/templates/template.plot_restart.yaml | 8 - scripts/exlandda_analysis.sh | 4 +- scripts/exlandda_forecast.sh | 4 +- scripts/exlandda_plot_stats.sh | 90 +++++-- scripts/exlandda_post_anal.sh | 4 +- ush/plot_analysis_timehistory.py | 294 +++++++++++++++++++++ versions/run.ver_hera | 1 + versions/run.ver_hercules | 1 + versions/run.ver_orion | 1 + 14 files changed, 388 insertions(+), 61 deletions(-) delete mode 100644 parm/templates/template.plot_hofx.yaml delete mode 100644 parm/templates/template.plot_restart.yaml create mode 100755 ush/plot_analysis_timehistory.py diff --git a/modulefiles/tasks/hera/task.plot_stats.lua b/modulefiles/tasks/hera/task.plot_stats.lua index 1b1dd4e0..612429da 100644 --- a/modulefiles/tasks/hera/task.plot_stats.lua +++ b/modulefiles/tasks/hera/task.plot_stats.lua @@ -9,6 +9,7 @@ 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-scipy", py_scipy_ver)) load(pathJoin("py-xarray", py_xarray_ver)) diff --git a/parm/land_analysis_hera.yaml b/parm/land_analysis_hera.yaml index f9de5635..2abffbb2 100644 --- a/parm/land_analysis_hera.yaml +++ b/parm/land_analysis_hera.yaml @@ -34,7 +34,7 @@ workflow: OBS_TYPES: "GHCN" DAtype: "letkfoi_snow" TSTUB: "oro_C96.mx100" - WE2E_VAV: "YES" + WE2E_TEST: "NO" WE2E_ATOL: "1e-7" WE2E_LOG_FN: "we2e.log" NET: "landda" @@ -137,7 +137,7 @@ workflow: ACCOUNT: "&ACCOUNT;" RES: "&RES;" TSTUB: "&TSTUB;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -172,7 +172,7 @@ workflow: ACCOUNT: "&ACCOUNT;" RES: "&RES;" TSTUB: "&TSTUB;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -208,7 +208,7 @@ workflow: ATMOS_FORC: "&ATMOS_FORC;" RES: "&RES;" WARMSTART_DIR: "&WARMSTART_DIR;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -259,6 +259,9 @@ workflow: KEEPDATA: "&KEEPDATA;" PDY: "&PDY;" cyc: "&cyc;" + LOGDIR: "&LOGDIR;" + NPROCS_ANALYSIS: "&NPROCS_ANALYSIS;" + NPROCS_FORECAST: "&NPROCS_FORECAST;" account: "&ACCOUNT;" command: '&HOMElandda;/parm/task_load_modules_run_jjob.sh "plot_stats" "&HOMElandda;" "&MACHINE;"' jobname: plot_stats diff --git a/parm/land_analysis_hercules.yaml b/parm/land_analysis_hercules.yaml index a39e22ad..27a729cc 100644 --- a/parm/land_analysis_hercules.yaml +++ b/parm/land_analysis_hercules.yaml @@ -34,7 +34,7 @@ workflow: OBS_TYPES: "GHCN" DAtype: "letkfoi_snow" TSTUB: "oro_C96.mx100" - WE2E_VAV: "YES" + WE2E_TEST: "NO" WE2E_ATOL: "1e-7" WE2E_LOG_FN: "we2e.log" NET: "landda" @@ -137,7 +137,7 @@ workflow: ACCOUNT: "&ACCOUNT;" RES: "&RES;" TSTUB: "&TSTUB;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -172,7 +172,7 @@ workflow: ACCOUNT: "&ACCOUNT;" RES: "&RES;" TSTUB: "&TSTUB;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -208,7 +208,7 @@ workflow: ATMOS_FORC: "&ATMOS_FORC;" RES: "&RES;" WARMSTART_DIR: "&WARMSTART_DIR;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -259,6 +259,9 @@ workflow: KEEPDATA: "&KEEPDATA;" PDY: "&PDY;" cyc: "&cyc;" + LOGDIR: "&LOGDIR;" + NPROCS_ANALYSIS: "&NPROCS_ANALYSIS;" + NPROCS_FORECAST: "&NPROCS_FORECAST;" account: "&ACCOUNT;" command: '&HOMElandda;/parm/task_load_modules_run_jjob.sh "plot_stats" "&HOMElandda;" "&MACHINE;"' jobname: plot_stats diff --git a/parm/land_analysis_orion.yaml b/parm/land_analysis_orion.yaml index 1b8b1f61..05d60a1f 100644 --- a/parm/land_analysis_orion.yaml +++ b/parm/land_analysis_orion.yaml @@ -34,7 +34,7 @@ workflow: OBS_TYPES: "GHCN" DAtype: "letkfoi_snow" TSTUB: "oro_C96.mx100" - WE2E_VAV: "YES" + WE2E_TEST: "NO" WE2E_ATOL: "1e-7" WE2E_LOG_FN: "we2e.log" NET: "landda" @@ -137,7 +137,7 @@ workflow: ACCOUNT: "&ACCOUNT;" RES: "&RES;" TSTUB: "&TSTUB;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -172,7 +172,7 @@ workflow: ACCOUNT: "&ACCOUNT;" RES: "&RES;" TSTUB: "&TSTUB;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -208,7 +208,7 @@ workflow: ATMOS_FORC: "&ATMOS_FORC;" RES: "&RES;" WARMSTART_DIR: "&WARMSTART_DIR;" - WE2E_VAV: "&WE2E_VAV;" + WE2E_TEST: "&WE2E_TEST;" WE2E_ATOL: "&WE2E_ATOL;" WE2E_LOG_FN: "&WE2E_LOG_FN;" LOGDIR: "&LOGDIR;" @@ -259,6 +259,9 @@ workflow: KEEPDATA: "&KEEPDATA;" PDY: "&PDY;" cyc: "&cyc;" + LOGDIR: "&LOGDIR;" + NPROCS_ANALYSIS: "&NPROCS_ANALYSIS;" + NPROCS_FORECAST: "&NPROCS_FORECAST;" account: "&ACCOUNT;" command: '&HOMElandda;/parm/task_load_modules_run_jjob.sh "plot_stats" "&HOMElandda;" "&MACHINE;"' jobname: plot_stats diff --git a/parm/templates/template.plot_hofx.yaml b/parm/templates/template.plot_hofx.yaml deleted file mode 100644 index fbf9b0ee..00000000 --- a/parm/templates/template.plot_hofx.yaml +++ /dev/null @@ -1,8 +0,0 @@ -hofx_files: 'INPUTFP' -field_var: 'XXFIELDVAR' -field_range: [XXFRLOW,XXFRHIGH] -nbins: XXNBINS -plottype: 'XXPLOTTYPE' -title_fig: 'XXFIGTITLE' -output_prefix: 'XXPREOUTFN' -machine: 'XXMACHINE' diff --git a/parm/templates/template.plot_restart.yaml b/parm/templates/template.plot_restart.yaml deleted file mode 100644 index d1def18e..00000000 --- a/parm/templates/template.plot_restart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -path_data: 'PATH_DATA' -work_dir: 'WORK_DIR' -fn_data_base: 'XXFN_DATA_BASE' -fn_data_ext: 'XXFN_DATA_EXT' -soil_lvl_number: 'XXSOIL_LEVEL_NUMBER' -out_title_base: 'XXOUT_TITLE_BASE' -out_fn_base: 'XXOUT_FN_BASE' -machine: 'XXMACHINE' diff --git a/scripts/exlandda_analysis.sh b/scripts/exlandda_analysis.sh index 6f76cb98..6967ee7f 100755 --- a/scripts/exlandda_analysis.sh +++ b/scripts/exlandda_analysis.sh @@ -251,8 +251,8 @@ if [[ -d output/DA/hofx ]]; then ln -nsf ${COMOUThofx}/* ${DATA_HOFX} fi -# WE2E V&V -if [[ "${WE2E_VAV}" == "YES" ]]; then +# WE2E test +if [[ "${WE2E_TEST}" == "YES" ]]; then path_fbase="${FIXlandda}/test_base/we2e_com/${RUN}.${PDY}" fn_sfc="${FILEDATE}.sfc_data.tile" fn_inc="${FILEDATE}.xainc.sfc_data.tile" diff --git a/scripts/exlandda_forecast.sh b/scripts/exlandda_forecast.sh index a660d935..78bf4f98 100755 --- a/scripts/exlandda_forecast.sh +++ b/scripts/exlandda_forecast.sh @@ -155,8 +155,8 @@ do ln -nsf ${COMOUT}/ufs_land_restart.${nYYYY}-${nMM}-${nDD}_${nHH}-00-00.tile${itile}.nc ${DATA_RESTART} done -# WE2E V&V -if [[ "${WE2E_VAV}" == "YES" ]]; then +# WE2E test +if [[ "${WE2E_TEST}" == "YES" ]]; then path_fbase="${FIXlandda}/test_base/we2e_com/${RUN}.${PDY}" fn_res="ufs_land_restart.${nYYYY}-${nMM}-${nDD}_${nHH}-00-00.tile" we2e_log_fp="${LOGDIR}/${WE2E_LOG_FN}" diff --git a/scripts/exlandda_plot_stats.sh b/scripts/exlandda_plot_stats.sh index a8203fbc..8a026f27 100755 --- a/scripts/exlandda_plot_stats.sh +++ b/scripts/exlandda_plot_stats.sh @@ -7,12 +7,15 @@ MM=${PDY:4:2} DD=${PDY:6:2} HH=${cyc} +nYYYY=${NTIME:0:4} +nMM=${NTIME:4:2} +nDD=${NTIME:6:2} +nHH=${NTIME:8:2} + ############################################################ # Stats Plot ############################################################ -cp -p ${PARMlandda}/templates/template.plot_hofx.yaml plot_hofx.yaml - # Path to the directory containing the input file INPUTFP="${DATA_HOFX}" # Field variable @@ -29,15 +32,16 @@ FIGTITLE="GHCN Snow Depth (mm)::Obs-Ana::${PDY}" # Prefix of output file name PREOUTFN="hofx_oma_${PDY}" -sed -i "s|INPUTFP|${INPUTFP}|g" plot_hofx.yaml -sed -i -e "s/XXFIELDVAR/${FIELDVAR}/g" plot_hofx.yaml -sed -i -e "s/XXFRLOW/${FRLOW}/g" plot_hofx.yaml -sed -i -e "s/XXFRHIGH/${FRHIGH}/g" plot_hofx.yaml -sed -i -e "s/XXNBINS/${NBINS}/g" plot_hofx.yaml -sed -i -e "s/XXPLOTTYPE/${PLOTTYPE}/g" plot_hofx.yaml -sed -i -e "s/XXFIGTITLE/${FIGTITLE}/g" plot_hofx.yaml -sed -i -e "s/XXPREOUTFN/${PREOUTFN}/g" plot_hofx.yaml -sed -i -e "s/XXMACHINE/${MACHINE}/g" plot_hofx.yaml +cat > plot_hofx.yaml < plot_timehistory.yaml < plot_restart.yaml <