From 2241a65714f0e6ee853edf175e4aab3beea648e3 Mon Sep 17 00:00:00 2001 From: alinalerner <96520701+alinalerner@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:17:27 +0200 Subject: [PATCH] Domain properties authomatic retrieval + try/except plotting correction (#39) Co-authored-by: Alina Lerner --- README.md | 5 ++--- scripts/plotdiacov.py | 12 +++++++++-- scripts/rundiacov.sh | 48 +++++-------------------------------------- 3 files changed, 17 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index fc0a0d0..b040de9 100644 --- a/README.md +++ b/README.md @@ -98,11 +98,10 @@ dfscomp -p CCMA_2022050112.dat -u CCMA_2022050112_unpert.dat -o dfs2022050112.da ### DIACOV First, you should have Festat output and the DIACOV binary compiled by Harmonie stored somewhere. -Then, create the new directory, copy the DIACOV binary and Jb files there. Example: +Then, create the new directory, Jb files there. Example: ``` mkdir DiacovTest cd DiacovTest -cp /path/to/DIACOV . mkdir dataTest cp /path/to/Jb/data dataTest/. ``` @@ -115,7 +114,7 @@ rundiacov -h Example: ``` -rundiacov -i dataTest -c METCOOP25D_65_2021100300-2021111006_412 -l 65 -g 2.5 -m 539 -n 1080 -d DIACOV +rundiacov -i dataTest -c METCOOP25D_65_2021100300-2021111006_412 -g 2.5 -d /path/to/DIACOV ``` #### Produce diagonal stats diff --git a/scripts/plotdiacov.py b/scripts/plotdiacov.py index 2a40c7f..dae2aec 100644 --- a/scripts/plotdiacov.py +++ b/scripts/plotdiacov.py @@ -63,13 +63,21 @@ def main(argv) : args = parser.parse_args() if args.idata != False and args.indir == False: - plotme(args.idata,args.oplot) + try: + plotme(args.idata,args.oplot) + except: + pass + elif args.indir != False and args.idata == False: datlist=glob.glob(args.indir+'/*.dat') for infile in datlist: output=infile.replace('.dat','.png') print (' ... plotting '+output) - plotme(infile,output) + try: + plotme(infile,output) + except: + print('Cannot produce the plot '+output+'!') + pass else: print ('Cannot do both!') sys.exit(1) diff --git a/scripts/rundiacov.sh b/scripts/rundiacov.sh index 763d273..b51d06e 100755 --- a/scripts/rundiacov.sh +++ b/scripts/rundiacov.sh @@ -17,10 +17,7 @@ ${bold}NAME${normal} ${bold}USAGE${normal} ${PROGNAME} -i -c - -l -g - -m - -n -d [ -h ] @@ -34,18 +31,9 @@ ${bold}OPTIONS${normal} -c ${unline}jb-file-name${normal} Name of *.cv and *.cvt files (without extension) - -l ${unline}level-nr${normal} - Number of domain's vertical levels - -g ${unline}grid-spacing${normal} Grid-spacing in kilometers - -m ${unline}nsmax${normal} - NSMAX parameter specified in domain properties - - -n ${unline}ndgl${normal} - NDGL parameter specified in domain properties - -d ${unline}diacov-binary${normal} PATH to DIACOV binary. @@ -56,10 +44,7 @@ USAGE DATADIR=DUMMY JBFILE=DUMMY -LEVELNUM=DUMMY GRIDSIZE=DUMMY -NSMAX=DUMMY -NDGL=DUMMY BINPATH=DUMMY #wrkdir=/home/eela/EoinDiacovTest/ #need to be changed to be more flexible @@ -74,7 +59,7 @@ if [ ${#} -eq 0 ]; then exit 1 fi -while getopts i:c:l:g:m:n:d:h option +while getopts i:c:g:d:h option do case $option in i) @@ -83,18 +68,9 @@ do c) JBFILE=$OPTARG ;; - l) - LEVELNUM=$OPTARG - ;; g) GRIDSIZE=$OPTARG ;; - m) - NSMAX=$OPTARG - ;; - n) - NDGL=$OPTARG - ;; d) BINPATH=$OPTARG ;; @@ -121,30 +97,12 @@ if [ ${JBFILE} == "DUMMY" ]; then exit 1 fi -if [ ${LEVELNUM} == "DUMMY" ]; then - echo "Please define number of vertical levels using -l" - echo "Try '${PROGNAME} -h' for more information" - exit 1 -fi - if [ ${GRIDSIZE} == "DUMMY" ]; then echo "Please define grid-size using -g" echo "Try '${PROGNAME} -h' for more information" exit 1 fi -if [ ${NSMAX} == "DUMMY" ]; then - echo "Please define NSMAX using -m" - echo "Try '${PROGNAME} -h' for more information" - exit 1 -fi - -if [ ${NDGL} == "DUMMY" ]; then - echo "Please define NDGL using -n" - echo "Try '${PROGNAME} -h' for more information" - exit 1 -fi - if [ ${BINPATH} == "DUMMY" ]; then echo "Please define path to DIACOV using -d" echo "Try '${PROGNAME} -h' for more information" @@ -153,6 +111,10 @@ fi cd $tmpdir +LEVELNUM=$(cv_header_list -i ../${DATADIR}/${JBFILE}.cv | grep "NFLEVG" | awk '{print $3}') +NSMAX=$(cv_header_list -i ../${DATADIR}/${JBFILE}.cv | grep "NSMAX" | awk '{print $3}') +NDGL=$(cv_header_list -i ../${DATADIR}/${JBFILE}.cv | grep "NDGL" | awk '{print $3}') + # prepare namelist for diacov - full variables cat > nam_diag1 <