Index: trunk/tools/obs-sim_Comparison.bash
===================================================================
--- trunk/tools/obs-sim_Comparison.bash	(revision 2015)
+++ trunk/tools/obs-sim_Comparison.bash	(revision 2016)
@@ -1,3 +1,3 @@
-#!/bin/bash -x
+#!/bin/bash
 # Shell script to compare observations with simulations using PyNCplot
 # 
@@ -362,43 +362,46 @@
       python ${pyHOME}/nc_var.py -o varaddattr -S 'units|rad' -f ${simsfcdiagsf} -v wds
     fi
-  fi
-
-  #Adding non-diagnostic variables
-  if test ! ${nondiagvs} = 'None'; then
-    varsadd=`echo ${nondiagvs} | tr ':' ' '`
-    for vadd in ${varsadd}; do
-      python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd} -f ${simsfcdiagsf}
-      if test $? -ne 0; then
-        echo ${errmsg}
-        echo "  python failed!!"
+
+    #Adding non-diagnostic variables
+    if test ! ${nondiagvs} = 'None'; then
+      varsadd=`echo ${nondiagvs} | tr ':' ' '`
+      for vadd in ${varsadd}; do
+        python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd}                \
+          -f ${simsfcdiagsf}
+        if test $? -ne 0; then
+          echo ${errmsg}
+          echo "  python failed!!"
+          echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'"   \
+            -f ${simsfcdiagsf}
+          exit
+          rm ${simsfcdiagsf}
+        fi
+        echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >>   \
+          ${ofileins}
         echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'"     \
-          -f ${simsfcdiagsf}
-        exit
-        rm ${simsfcdiagsf}
-      fi
-      echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >> ${ofileins}
-      echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'"       \
-        -f ${simsfcdiagsf} >> ${ofileins}
-      echo " " >> ${ofileins}
-      # CF varname
-      CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | tr ':' ' ' |\
-        awk '{print $1}'`
-      if test $? -ne 0; then
-        echo ${errmsg}
-        echo "  python failed!!"
-        echo python $pyHOME/generic.py -o variables_values -S ${vadd}
-        exit
-        rm ${simsfcdiagsf}
-      fi
-      python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} -v ${vadd}
-      if test $? -ne 0; then
-        echo ${errmsg}
-        echo "  python failed!!"
-        echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} \
+          -f ${simsfcdiagsf} >> ${ofileins}
+        echo " " >> ${ofileins}
+        # CF varname
+        CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} |           \
+          tr ':' ' ' | awk '{print $1}'`
+        if test $? -ne 0; then
+          echo ${errmsg}
+          echo "  python failed!!"
+          echo python $pyHOME/generic.py -o variables_values -S ${vadd}
+          exit
+          rm ${simsfcdiagsf}
+        fi
+        python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf}        \
           -v ${vadd}
-        exit
-        rm ${simsfcdiagsf}
-      fi
-    done
+        if test $? -ne 0; then
+          echo ${errmsg}
+          echo "  python failed!!"
+          echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn}                  \
+            -f ${simsfcdiagsf} -v ${vadd}
+          exit
+          rm ${simsfcdiagsf}
+        fi
+      done
+    fi
   fi
 }
@@ -755,4 +758,6 @@
   echo "*** Instruction from all functions _______" > ${ofileins}
   echo " " >> ${ofileins}
+fi
+if ${gscratch}; then 
   echo "*** Instruction from all figures _______" > ${ofilefigs}
   echo " " >> ${ofilefigs}
@@ -885,5 +890,5 @@
     grep NC | awk '{print $2}'`
 
-  if test ${iost} -eq 1; then 
+  if test ! ${wdir}/stations.inf; then 
     oststids=${stid}'@'${ostf}
     echo ${prn}","${stid}","${ostlon}","${ostlat}","${ostheight} > ${wdir}/stations.inf
@@ -951,151 +956,37 @@
 done
 
+###
+##
+# Figures
+##
+###
+
+mkdir -p ${ofigdir}
+
+##
+# Stations maps
+##
+ofig=${ofigdir}/stations.png
+if ${gscratch}; then rm ${ofig} >& /dev/null; fi
+if test ! -f ${ofig}; then
+  fivals=${mapstchar}':'${mapv}':lonlatxtrms:'${figexperimentname}'!stations:'
+  fivals=${fivals}${kfig}':true'
+  python ${pyHOME}/drawing.py -o draw_stations_map -f ${wdir}/stations.inf           \
+    -S ${fivals}
+  if test $? -ne 0; then
+    echo ${errmsg}
+    echo "  python failed!!"
+    echo python ${pyHOME}/drawing.py -o draw_stations_map -f ${wdir}/stations.inf    \
+      -S "'"${fivals}"'"
+    exit
+  fi
+  echo " * Map of the stations: " >> ${ofilefigs}
+  echo python ${pyHOME}/drawing.py -o draw_stations_map -f ${wdir}/stations.inf      \
+    -S "'"${fivals}"'" >> ${ofilefigs}
+  echo " " >> ${ofilefigs}
+  convert -trim stations_map.${kfig} ${ofig}
+fi
+
 exit
-
-diagns=`echo ${wrfsnddiags} | tr ':' ' '`
-snddiagd='time@time,bottom_top@P,south_north@XLAT,west_east@XLONG'
-snddiagvals=''
-idiag=1
-for diagn in ${diagns}; do
-  diagv=`cat $pyHOME/diagnostics.inf | grep ${diagn}',' | tr ',' ' ' |               \
-    awk '{print $2"|"$3}'`
-  if test ${idiag} -eq 1; then
-    snddiagvals=${diagv}
-  else
-    snddiagvals=${snddiagvals}','${diagv}
-  fi
-  idiag=`expr ${idiag} + 1`
-done
-
-if test ${sfcvars} != 'None'; then
-# surface diags
-diagns=`echo ${wrfsfcdiags} | tr ':' ' '`
-sfcdiagd='time@time,south_north@XLAT,west_east@XLONG'
-sfcdiagvals=''
-idiag=1
-iadv=1
-for diagn in ${diagns}; do
-  diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |    \
-    awk '{print $2"|"$3}'`
-  Ldiagv=`expr length $(echo ${diagv} | tr ' ' '@')0`
-  if test ${Ldiagv} -lt 2; then
-    echo ${errmsg}
-    echo "  diagnostic '"${diagn}"' (for WRF) does not exist !!"
-    if test ${iadv} -eq 1; then advs=${diagn}; iadv=`expr ${iadv} + 1`
-    else advs=${adv}','${diagn}; fi
-  else
-    if test ${idiag} -eq 1; then
-      sfcdiagvals=${diagv}
-      idiag=`expr ${idiag} + 1`
-    else
-      sfcdiagvals=${sfcdiagvals}','${diagv}
-    fi
-  fi
-done
-fi
-
-exps=`echo ${sims} | tr ':' ' '`
-
-iexp=1
-for exp in ${exps}; do
-  expf=`echo ${exp} | tr ',' ' ' | awk '{print $1}'`
-  expl=`echo ${exp} | tr ',' ' ' | awk '{print $2}'`
-  expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'`
-  expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'`
-
-  # Joining files
-  simjoinselvars=${odir}'/simout_vars_'${expl}'.nc'
-  if ${fscratch}; then rm ${simjoinselvars}; fi
-  if test ! -f ${simjoinselvars}; then
-    values=${simdir}'/'${expf}','${simtimedimn}','${simtimevarn}
-    HMT=${simHMT}
-    python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}         \
-     -f ${HMT} -v ${simvars}
-    if test $? -ne 0; then
-      echo ${errmsg}
-      echo "  python failed!!"
-      echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S "'"${values}"'"  \
-        -f "'"${HMT}"'" -v "'"${simvars}"'"
-      exit
-    fi
-    mv netcdf_fold_concatenated_HMT.nc ${simjoinselvars}
-  fi
-
-  # Computing sounding diagnostics
-  simdiagsf=${odir}'/simout_snddiags_'${expl}'.nc'
-  if ${fscratch}; then rm ${simdiagsf}; fi
-  if test ! -f ${simdiagsf}; then
-    python ${pyHOME}/diagnostics.py -f ${simjoinselvars} -d ${snddiagd} -v ${snddiagvals}
-    if test $? -ne 0; then
-      echo ${errmsg}
-      echo "  python failed!!"
-      echo python ${pyHOME}/diagnostics.py -f ${simjoinselvars} -d "'"${snddiagd}"'" -v "'"${snddiagvals}"'"
-      exit
-    fi
-    mv diagnostics.nc ${simdiagsf}
-    #To deg
-    python ${pyHOME}/nc_var.py -o valmod -S subc,273.15 -f ${simdiagsf} -v ta
-    #To Pa
-    python ${pyHOME}/nc_var.py -o valmod -S divc,100. -f ${simdiagsf} -v pres
-  fi
-
-  if test ${sfcvars} != 'None'; then
-  # Computing surface diagnostics
-  simsfcdiagf=${odir}'/simout_sfcdiags_'${expl}'.nc'
-  if ${fscratch}; then rm ${simsfcdiagf}; fi
-  if test ! -f ${simsfcdiagf}; then
-    python ${pyHOME}/diagnostics.py -f ${simjoinselvars} -d ${sfcdiagd} -v ${sfcdiagvals}
-    if test $? -ne 0; then
-      echo ${errmsg}
-      echo "  python failed!!"
-      echo python ${pyHOME}/diagnostics.py -f ${simjoinselvars} -d "'"${sfcdiagd}"'" -v ${sfcdiagvals}
-      exit
-    fi
-    mv diagnostics.nc ${simsfcdiagf}
-    #To rad
-    python ${pyHOME}/nc_var.py -o valmod -S mulc,0.0174532925199 -f ${simsfcdiagf} -v wds
-    python ${pyHOME}/nc_var.py -o varaddattr -S 'units|rad' -f ${simsfcdiagf} -v wds
-  fi
-
-  #Adding non-diagnostic variables
-  if test ${iadv} -ne 1; then
-    varsadd=`echo ${advs} | tr ',' ' '`
-    for vadd in ${varsadd}; do
-      python ${pyHOME}/nc_var.py -o fvaradd -S ${simjoinselvars},${vadd} -f ${simsfcdiagf}
-      if test $? -ne 0; then
-        echo ${errmsg}
-        echo "  python failed!!"
-        echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simjoinselvars},${vadd}"'" -f ${simsfcdiagf}
-        exit
-        rm ${simsfcdiagf}
-      fi
-      # CF varname
-      CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} | tr ':' ' ' |  \
-        awk '{print $1}'`
-      if test $? -ne 0; then
-        echo ${errmsg}
-        echo "  python failed!!"
-        echo python $pyHOME/generic.py -o variables_values -S ${vadd}
-        exit
-        rm ${simsfcdiagf}
-      fi
-      python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagf} -v ${vadd}
-      if test $? -ne 0; then
-        echo ${errmsg}
-        echo "  python failed!!"
-        echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagf} -v ${vadd}
-        exit
-        rm ${simsfcdiagf}
-      fi
-    done
-  fi
-  fi
-
-  iexp=`expr ${iexp} + 1`
-
-# End experiments
-done
-
-mkdir -p ${ofigdir}
 
 ###
