Changeset 2113 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Aug 30, 2018, 3:44:06 PM (6 years ago)
Author:
lfita
Message:

Working on it, but not followed.... no time! GEWEX-CPC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/obs-sim_Comparison_ONLYfigures.bash

    r2107 r2113  
    11#!/bin/bash
    2 # Shell script to compare observations with simulations using PyNCplot
     2# Shell script to compare observations with simulations using PyNCplot figures 'ONLY'
    33#
    44#   observations: different files from create_OBSnetcdf.py and/or UWyoming_snd_nc.py
     
    5252echo "END upload -- end UPLOAD -- END upload -- end UPLOAD"
    5353
    54 # files from scratch
    55 if test ${fscratch} = 'true'; then fscratch=true
    56 else fscratch=false; fi
     54fscratch=false
    5755
    5856# figures from scratch
     
    144142  else
    145143    false
    146   fi
    147 }
    148 
    149 function get_WRFsounding_data(){
    150 # Function to get the data to compute analysis in a sounding point
    151 #   stlon= longitude value of the station
    152 #   stlat= latitude value of the station
    153 #   filen= name of the file
    154 #   lonvarn= name of the longitude variable
    155 #   latvarn= name of the latitude variable
    156 #   snddiagnames= diagnostics to compute (as ':' separated list)
    157 #   snddiagd= name of the dimensions and dimension variables to use for diagnostics
    158 
    159   funcvals=$1
    160 
    161   stlon=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'`
    162   stlat=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'`
    163   filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'`
    164   lonvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'`
    165   latvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $5}'`
    166   snddiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $6}'`
    167   snddiagd=`echo ${funcvals} | tr '#' ' ' | awk '{print $7}'`
    168 
    169   vals=${lonvarn}':'${latvarn}':Time|0'
    170   gridsndv=`python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals}           \
    171     -v ${stlon},${stlat} | tr ' ' '!'`
    172   echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins}
    173   echo python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'"          \
    174     -v ${stlon},${stlat} >> ${ofileins}
    175   echo " " >> ${ofileins}
    176 
    177   xsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' |              \
    178    awk '{print $1}'`
    179   ysnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' |              \
    180   awk '{print $2}'`
    181   dsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $2}'`
    182 
    183   xsnd1=`expr ${xsnd} + 1`
    184   ysnd1=`expr ${ysnd} + 1`
    185 
    186   # Getting values
    187   if ${fscratch}; then rm ${simsndptf} >& /dev/null; fi
    188   if test ! -f ${simsndptf}; then
    189     values='Time,0,-1,1@bottom_top,0,-1,1@south_north,'${ysnd}','${ysnd}',1@'
    190     values=${values}'west_east,'${xsnd}','${xsnd}',1@south_north_stag,'${ysnd}','
    191     values=${values}${ysnd1}',1@west_east_stag,'${xsnd}','${xsnd1}',1:False'
    192     python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}               \
    193       -S ${values} -v all
    194     if test $? -ne 0; then
    195       echo ${errmsg}
    196       echo "  python failed!!"
    197       echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}        \
    198         -S "'"${values}"'" -v all
    199       exit
    200     fi
    201     echo "* get values at snd point: "${stlon}", "${stlat} >> ${ofileins}
    202     echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}          \
    203       -S "'"${values}"'" -v all >> ${ofileins}
    204     echo " " >> ${ofileins}
    205 
    206     yslc='south_north_B'${ysnd}'-E'${ysnd}'-I1'
    207     ystslc='south_north_stag_B'${ysnd}'-E'${ysnd1}'-I1'
    208     xslc='west_east_B'${xsnd}'-E'${xsnd}'-I1'
    209     xstslc='west_east_stag_B'${xsnd}'-E'${xsnd1}'-I1'
    210 
    211     Hfilen=`basename ${filen}`
    212     Dfilen=`dirname ${filen}`
    213     Hhfilen=`echo ${Hfilen} | tr '.' ' ' | awk '{print $1}'`
    214 
    215     ofilen='newfile_multidims.nc'
    216     mv ${ofilen} ${simsndptf}
    217   fi
    218    
    219   # Computing sounding diagnostics
    220   diagns=`echo ${snddiagnames} | tr ':' ' '`
    221 
    222   idiag=1
    223   for diagn in ${diagns}; do
    224     diagv=`cat $pyHOME/diagnostics.inf | grep ${diagn}',' | tr ',' ' ' |             \
    225       awk '{print $2"|"$3}'`
    226     if test ${idiag} -eq 1; then
    227       snddiagvals=${diagv}
    228     else
    229       snddiagvals=${snddiagvals}','${diagv}
    230     fi
    231     idiag=`expr ${idiag} + 1`
    232   done
    233 
    234   if ${fscratch}; then rm ${simsnddiagsf}; fi
    235   if test ! -f ${simsnddiagsf}; then
    236     python ${pyHOME}/diagnostics.py -f ${simsndptf} -d ${snddiagd} -v ${snddiagvals}
    237     if test $? -ne 0; then
    238       echo ${errmsg}
    239       echo "  python failed!!"
    240       echo python ${pyHOME}/diagnostics.py -f ${simsndptf} -d "'"${snddiagd}"'" -v   \
    241         "'"${snddiagvals}"'"
    242       exit
    243     fi
    244     echo "* computing diagnostics at snd point: "${stlon}", "${stlat} >> ${ofileins}
    245     echo python ${pyHOME}/diagnostics.py -f "'"${simsndptf}"'" -d "'"${snddiagd}"'"  \
    246       -v "'"${snddiagvals}"'" >> ${ofileins}
    247     echo " " >> ${ofileins}
    248 
    249     mv diagnostics.nc ${simsnddiagsf}
    250     if $(isin_list ${snddiagnames} WRFt); then
    251       #To deg
    252       python ${pyHOME}/nc_var.py -o valmod -S subc,273.15 -f ${simsnddiagsf} -v ta
    253     fi
    254     if $(isin_list ${snddiagnames} WRFp); then
    255       #To Pa
    256       python ${pyHOME}/nc_var.py -o valmod -S divc,100. -f ${simsnddiagsf} -v pres
    257     fi
    258   fi
    259 }
    260 
    261 function get_WRFsurface_data(){
    262 # Function to get the data to compute analysis in a surface point
    263 #   stlon= longitude value of the station
    264 #   stlat= latitude value of the station
    265 #   filen= name of the file
    266 #   lonvarn= name of the longitude variable
    267 #   latvarn= name of the latitude variable
    268 #   sfcdiagnames= diagnostics to compute (as ':' separated list)
    269 #   nondiagvs= ':' list of variables which are not from a diagnostics ('None' for
    270 #     without)
    271 #   sfcdiagd= name of the dimensions and dimension variables to use for diagnostics
    272 
    273   funcvals=$1
    274 
    275   stlon=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'`
    276   stlat=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'`
    277   filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'`
    278   lonvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'`
    279   latvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $5}'`
    280   sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $6}'`
    281   nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $7}'`
    282   sfcdiagd=`echo ${funcvals} | tr '#' ' ' | awk '{print $8}'`
    283 
    284   vals=${lonvarn}':'${latvarn}':Time|0'
    285   gridsndv=`python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals}           \
    286     -v ${stlon},${stlat} | tr ' ' '!'`
    287   echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins}
    288   echo python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'"          \
    289     -v ${stlon},${stlat} >> ${ofileins}
    290   echo " " >> ${ofileins}
    291   xsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' |              \
    292    awk '{print $1}'`
    293   ysnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' |              \
    294   awk '{print $2}'`
    295   dsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $2}'`
    296 
    297   xsnd1=`expr ${xsnd} + 1`
    298   ysnd1=`expr ${ysnd} + 1`
    299 
    300   # Getting values
    301   if ${fscratch}; then rm ${simsfcptf} >& /dev/null; fi
    302   if test ! -f ${simsfcptf}; then
    303     values='Time,0,-1,1@south_north,'${ysnd}','${ysnd}',1@'
    304     values=${values}'west_east,'${xsnd}','${xsnd}',1@south_north_stag,'${ysnd}','
    305     values=${values}${ysnd1}',1@west_east_stag,'${xsnd}','${xsnd1}',1:False'
    306     python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}               \
    307       -S ${values} -v all
    308     if test $? -ne 0; then
    309       echo ${errmsg}
    310       echo "  python failed!!"
    311       echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}        \
    312         -S "'"${values}"'" -v all
    313       exit
    314     fi
    315   echo "* get values at sfc point: "${stlon}", "${stlat} >> ${ofileins}
    316   echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}            \
    317       -S "'"${values}"'" -v all >> ${ofileins}
    318   echo " " >> ${ofileins}
    319     yslc='south_north_B'${ysnd}'-E'${ysnd}'-I1'
    320     ystslc='south_north_stag_B'${ysnd}'-E'${ysnd1}'-I1'
    321     xslc='west_east_B'${xsnd}'-E'${xsnd}'-I1'
    322     xstslc='west_east_stag_B'${xsnd}'-E'${xsnd1}'-I1'
    323 
    324     ofilen='newfile_multidims.nc'
    325     mv ${ofilen} ${simsfcptf}
    326   fi
    327    
    328   # Computing sfc diagnostics
    329   diagns=`echo ${sfcdiagnames} | tr ':' ' '`
    330 
    331   idiag=1
    332   for diagn in ${diagns}; do
    333     diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |  \
    334       awk '{print $2"|"$3}'`
    335     if test ${idiag} -eq 1; then
    336       sfcdiagvals=${diagv}
    337     else
    338       sfcdiagvals=${sfcdiagvals}','${diagv}
    339     fi
    340     idiag=`expr ${idiag} + 1`
    341   done
    342 
    343   if ${fscratch}; then rm ${simsfcdiagsf}; fi
    344   if test ! -f ${simsfcdiagsf}; then
    345     python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d ${sfcdiagd} -v ${sfcdiagvals}
    346     if test $? -ne 0; then
    347       echo ${errmsg}
    348       echo "  python failed!!"
    349       echo python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'"      \
    350         -v "'"${sfcdiagvals}"'"
    351       exit
    352     fi
    353     echo "* diagnostics at sfc point: "${stlon}", "${stlat} >> ${ofileins}
    354     echo python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'"        \
    355       -v "'"${sfcdiagvals}"'" >> ${ofileins}
    356     echo " " >> ${ofileins}
    357     mv diagnostics.nc ${simsfcdiagsf}
    358     if $(isin_list ${sfcdiagnames} wds); then
    359       #To rad
    360       python ${pyHOME}/nc_var.py -o valmod -S mulc,0.0174532925199 -f ${simsfcdiagsf}\
    361         -v wds
    362       python ${pyHOME}/nc_var.py -o varaddattr -S 'units|rad' -f ${simsfcdiagsf} -v wds
    363     fi
    364 
    365     #Adding non-diagnostic variables
    366     if test ! ${nondiagvs} = 'None'; then
    367       varsadd=`echo ${nondiagvs} | tr ':' ' '`
    368       for vadd in ${varsadd}; do
    369         python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd}                \
    370           -f ${simsfcdiagsf}
    371         if test $? -ne 0; then
    372           echo ${errmsg}
    373           echo "  python failed!!"
    374           echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'"   \
    375             -f ${simsfcdiagsf}
    376           exit
    377           rm ${simsfcdiagsf}
    378         fi
    379         echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >>   \
    380           ${ofileins}
    381         echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'"     \
    382           -f ${simsfcdiagsf} >> ${ofileins}
    383         echo " " >> ${ofileins}
    384         # CF varname
    385         CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} |           \
    386           tr ':' ' ' | awk '{print $1}'`
    387         if test $? -ne 0; then
    388           echo ${errmsg}
    389           echo "  python failed!!"
    390           echo python $pyHOME/generic.py -o variables_values -S ${vadd}
    391           exit
    392           rm ${simsfcdiagsf}
    393         fi
    394         python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf}        \
    395           -v ${vadd}
    396         if test $? -ne 0; then
    397           echo ${errmsg}
    398           echo "  python failed!!"
    399           echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn}                  \
    400             -f ${simsfcdiagsf} -v ${vadd}
    401           exit
    402           rm ${simsfcdiagsf}
    403         fi
    404       done
    405     fi
    406   fi
    407 }
    408 
    409 function get_WRFsfc2D_data(){
    410 # Function to get the data to compute analysis in a surface map
    411 #   filen= name of the file
    412 #   sfcdiagnames= diagnostics to compute (as ':' separated list)
    413 #   nondiagvs= ':' list of variables which are not from a diagnostics ('None' for
    414 #     without)
    415 #   sfcmapdiagd= name of the dimensions and dimension variables to use for diagnostics
    416 
    417   funcvals=$1
    418 
    419   filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'`
    420   sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'`
    421   nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'`
    422   sfcmapdiagd=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'`
    423 
    424   # Computing sfc diagnostics
    425   diagns=`echo ${sfcdiagnames} | tr ':' ' '`
    426 
    427   # getting that variables only required for the diagnostics
    428   vardiags=''
    429   idiag=1
    430   for diagn in ${diagns}; do
    431     diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |  \
    432       awk '{print $2"|"$3}'`
    433     if test ${idiag} -eq 1; then
    434       sfcdiagvals=${diagv}
    435       vardiags=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ':'`
    436     else
    437       sfcdiagvals=${sfcdiagvals}','${diagv}
    438       vardiag=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ' '`
    439       for vd in ${vardiag}; do
    440         if ! $(isin_list ${vardiags} ${vd}); then vardiags=${vardiags}':'${vd}; fi
    441       done
    442     fi
    443     idiag=`expr ${idiag} + 1`
    444   done
    445 
    446   # Inlcuding non-diagnostics
    447   if test ! ${nondiagvs} = 'None'; then
    448     nvns=`echo ${nondiagvs} | tr ':' ' '`
    449     for vn in ${nvns}; do
    450       if ! $(isin_list ${vardiags} ${vn}); then vardiags=${vardiags}':'${vn}; fi
    451     done
    452     if ! $(isin_list ${vardiags} 'time'); then vardiags=${vardiags}':time'; fi
    453   fi
    454   vardiag=`echo ${vardiags} | tr ':' ','`
    455  
    456   # Getting values
    457   if ${fscratch}; then rm ${simsfcmapf} >& /dev/null; fi
    458   if test ! -f ${simsfcmapf}; then
    459     values='Time,0,-1,1@south_north,0,-1,1@west_east,0,-1,1@south_north_stag,0,-1,1@'
    460     values=${values}'west_east_stag,0,-1,1:False'
    461     python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}               \
    462       -S ${values} -v ${vardiag}
    463     if test $? -ne 0; then
    464       echo ${errmsg}
    465       echo "  python failed!!"
    466       echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}        \
    467         -S "'"${values}"'"  -v ${vardiag}
    468       exit
    469     fi
    470     echo "* get values for 2D map diagnostics: " >> ${ofileins}
    471     echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}          \
    472       -S "'"${values}"'" -v ${vardiag} >> ${ofileins}
    473     echo " " >> ${ofileins}
    474 
    475     ofilen='newfile_multidims.nc'
    476     mv ${ofilen} ${simsfcmapf}
    477   fi
    478 
    479   if ${fscratch}; then rm ${simsfcmapdiagsf}; fi
    480   if test ! -f ${simsfcmapdiagsf}; then
    481     python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d ${sfcmapdiagd}               \
    482       -v ${sfcdiagvals}
    483     if test $? -ne 0; then
    484       echo ${errmsg}
    485       echo "  python failed!!"
    486       echo python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'"  \
    487         -v "'"${sfcdiagvals}"'"
    488       exit
    489     fi
    490     echo "* diagnostics for sfc 2D map: " >> ${ofileins}
    491     echo python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'"    \
    492       -v "'"${sfcdiagvals}"'" >> ${ofileins}
    493     echo " " >> ${ofileins}
    494     mv diagnostics.nc ${simsfcmapdiagsf}
    495     if $(isin_list ${sfcdiagnames} wds); then
    496       #To rad
    497       python ${pyHOME}/nc_var.py -o valmod -S mulc,0.0174532925199                   \
    498         -f ${simsfcmapdiagsf} -v wds
    499       python ${pyHOME}/nc_var.py -o varaddattr -S 'units|rad' -f ${simsfcmapdiagsf}  \
    500         -v wds
    501     fi
    502 
    503     #Adding non-diagnostic variables
    504     if test ! ${nondiagvs} = 'None'; then
    505       varsadd=`echo ${nondiagvs} | tr ':' ' '`
    506       for vadd in ${varsadd}; do
    507         python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcmapf},${vadd}               \
    508           -f ${simsfcmapdiagsf}
    509         if test $? -ne 0; then
    510           echo ${errmsg}
    511           echo "  python failed!!"
    512           echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'"  \
    513             -f ${simsfcmapdiagsf}
    514           exit
    515           rm ${simsfcmapdiagsf}
    516         fi
    517         echo "* adding variable '"${vadd}"' at sfc map: " >> ${ofileins}
    518         echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'"    \
    519           -f ${simsfcmapdiagsf} >> ${ofileins}
    520         echo " " >> ${ofileins}
    521         # CF varname
    522         CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} |           \
    523           tr ':' ' ' | awk '{print $1}'`
    524         if test $? -ne 0; then
    525           echo ${errmsg}
    526           echo "  python failed!!"
    527           echo python $pyHOME/generic.py -o variables_values -S ${vadd}
    528           exit
    529           rm ${simsfcmapdiagsf}
    530         fi
    531         python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcmapdiagsf}     \
    532           -v ${vadd}
    533         if test $? -ne 0; then
    534           echo ${errmsg}
    535           echo "  python failed!!"
    536           echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn}                  \
    537             -f ${simsfcmapdiagsf} -v ${vadd}
    538           exit
    539           rm ${simsfcmapdiagsf}
    540         fi
    541       done
    542     fi
    543   fi
    544 }
    545 
    546 function get_WRFCDXsfc2D_data(){
    547 # Function to get the data from WRFCDX to compute analysis in a surface map
    548 #   filen= name of the file
    549 #   sfcdiagnames= diagnostics to compute (as ':' separated list)
    550 #   nondiagvs= ':' list of variables which are not from a diagnostics ('None' for
    551 #     without)
    552 #   sfcmapdiagd= name of the dimensions and dimension variables to use for diagnostics
    553 
    554   funcvals=$1
    555 
    556   filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'`
    557   sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'`
    558   nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'`
    559   sfcmapdiagd=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'`
    560 
    561   # Computing sfc diagnostics
    562   diagns=`echo ${sfcdiagnames} | tr ':' ' '`
    563 
    564   # getting that variables only required for the diagnostics
    565   vardiags=''
    566   idiag=1
    567   for diagn in ${diagns}; do
    568     diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |  \
    569       awk '{print $2"|"$3}'`
    570     if test ${idiag} -eq 1; then
    571       sfcdiagvals=${diagv}
    572       vardiags=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ':'`
    573     else
    574       sfcdiagvals=${sfcdiagvals}','${diagv}
    575       vardiag=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ' '`
    576       for vd in ${vardiag}; do
    577         if ! $(isin_list ${vardiags} ${vd}); then vardiags=${vardiags}':'${vd}; fi
    578       done
    579     fi
    580     idiag=`expr ${idiag} + 1`
    581   done
    582 
    583   # Inlcuding non-diagnostics
    584   if test ! ${nondiagvs} = 'None'; then
    585     nvns=`echo ${nondiagvs} | tr ':' ' '`
    586     for vn in ${nvns}; do
    587       if ! $(isin_list ${vardiags} ${vn}); then vardiags=${vardiags}':'${vn}; fi
    588     done
    589     if ! $(isin_list ${vardiags} 'time'); then vardiags=${vardiags}':time'; fi
    590   fi
    591   vardiag=`echo ${vardiags} | tr ':' ','`
    592  
    593   # Getting values
    594   if ${fscratch}; then rm ${simsfcmapf} >& /dev/null; fi
    595   if test ! -f ${simsfcmapf}; then
    596     values='Time,0,-1,1@south_north,0,-1,1@west_east,0,-1,1:False'
    597     python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}               \
    598       -S ${values} -v ${vardiag}
    599     if test $? -ne 0; then
    600       echo ${errmsg}
    601       echo "  python failed!!"
    602       echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}        \
    603         -S "'"${values}"'"  -v ${vardiag}
    604       exit
    605     fi
    606     echo "* get values for 2D map diagnostics: " >> ${ofileins}
    607     echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen}          \
    608       -S "'"${values}"'" -v ${vardiag} >> ${ofileins}
    609     echo " " >> ${ofileins}
    610 
    611     ofilen='newfile_multidims.nc'
    612     mv ${ofilen} ${simsfcmapf}
    613   fi
    614 
    615   if ${fscratch}; then rm ${simsfcmapdiagsf}; fi
    616   if test ! -f ${simsfcmapdiagsf}; then
    617     python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d ${sfcmapdiagd}               \
    618       -v ${sfcdiagvals}
    619     if test $? -ne 0; then
    620       echo ${errmsg}
    621       echo "  python failed!!"
    622       echo python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'"  \
    623         -v "'"${sfcdiagvals}"'"
    624       exit
    625     fi
    626     echo "* diagnostics for sfc 2D map: " >> ${ofileins}
    627     echo python ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'"    \
    628       -v "'"${sfcdiagvals}"'" >> ${ofileins}
    629     echo " " >> ${ofileins}
    630     mv diagnostics.nc ${simsfcmapdiagsf}
    631 
    632     #Adding non-diagnostic variables
    633     if test ! ${nondiagvs} = 'None'; then
    634       varsadd=`echo ${nondiagvs} | tr ':' ' '`
    635       for vadd in ${varsadd}; do
    636         python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcmapf},${vadd}               \
    637           -f ${simsfcmapdiagsf}
    638         if test $? -ne 0; then
    639           echo ${errmsg}
    640           echo "  python failed!!"
    641           echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'"  \
    642             -f ${simsfcmapdiagsf}
    643           exit
    644           rm ${simsfcmapdiagsf}
    645         fi
    646         echo "* adding variable '"${vadd}"' at sfc map: " >> ${ofileins}
    647         echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'"    \
    648           -f ${simsfcmapdiagsf} >> ${ofileins}
    649         echo " " >> ${ofileins}
    650         # CF varname
    651         CFvarn=`python $pyHOME/generic.py -o variables_values -S ${vadd} |           \
    652           tr ':' ' ' | awk '{print $1}'`
    653         if test $? -ne 0; then
    654           echo ${errmsg}
    655           echo "  python failed!!"
    656           echo python $pyHOME/generic.py -o variables_values -S ${vadd}
    657           exit
    658           rm ${simsfcmapdiagsf}
    659         fi
    660         python $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcmapdiagsf}     \
    661           -v ${vadd}
    662         if test $? -ne 0; then
    663           echo ${errmsg}
    664           echo "  python failed!!"
    665           echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn}                  \
    666             -f ${simsfcmapdiagsf} -v ${vadd}
    667           exit
    668           rm ${simsfcmapdiagsf}
    669         fi
    670       done
    671     fi
    672144  fi
    673145}
     
    1112584
    1113585###
    1114 ## Preparing simulations
     586## Preparing stations data
    1115587###
    1116588
     
    1139611    echo ${prn}","${stid}","${ostlon}","${ostlat}","${ostheight} >> ${wdir}/stations.inf
    1140612  fi
    1141 
    1142   iexp=1
    1143   for exp in ${exps}; do
    1144     expf=`echo ${exp} | tr ',' ' ' | awk '{print $1}'`
    1145     expl=`echo ${exp} | tr ',' ' ' | awk '{print $2}'`
    1146     expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'`
    1147     expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'`
    1148     expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'`
    1149 
    1150     simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}`
    1151 
    1152     ofile=${odir}/simout_${prn}vars_${stid}_${expl}.nc
    1153     if ${fscratch}; then rm ${ofile} >& /dev/null; fi
    1154     if test ! -f ${ofile}; then
    1155       for simf in ${simfiles}; do
    1156         simfn=`basename ${simf}`
    1157         fdate=`echo ${simfn} | tr '.' ' ' | awk '{print $1}' | tr '_' ' ' |          \
    1158           awk '{print $3"_"$4}'`
    1159 
    1160         simsndptf=${odir}'/simout_vars_'${prn}'pt_'${stid}'_'${expl}'_'${fdate}'.nc'
    1161         simsnddiagsf=${odir}'/simout_'${prn}'diags_'${stid}'_'${expl}'_'${fdate}'.nc'
    1162 
    1163         fvals=${ostlon}'#'${ostlat}'#'${simf}'#XLONG#XLAT#'${wrfdiags}'#'
    1164         fvals=${fvals}${simdiagd}
    1165         get_WRFsounding_data ${fvals}
    1166 
    1167       # end of files
    1168       done
    1169 
    1170       # Concatenating files
    1171       Nconfc=`ls -1 ${odir}/simout_${prn}diags_*${stid}*${expl}*.nc | wc -l |        \
    1172         awk '{print $1}'`
    1173       if test ${Nconfc} -gt 1; then
    1174         values=${odir}',Time,time'
    1175         HMT='simout_'${prn}'diags_,'${stid}'_'${expn},'nc'
    1176         python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}      \
    1177          -f ${HMT} -v all
    1178         if test $? -ne 0; then
    1179           echo ${errmsg}
    1180           echo "  python failed!!"
    1181           echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}\
    1182           -f ${HMT} -v all
    1183           exit
    1184         fi
    1185         echo " * Concatenating "${obstype}" data at point: "${ostlon}", "${ostlat} >> ${ofileins}
    1186         echo python  ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S \
    1187           "'"${values}"'" -f ${HMT} -v all >> ${ofileins}
    1188         echo " " >> ${ofileins}
    1189         mv netcdf_fold_concatenated_HMT.nc ${ofile}
    1190       else
    1191         ffilen=`ls -1 ${odir}/simout_${prn}diags_*${stid}*${expl}*.nc`
    1192         cp ${ffilen} ${ofile}
    1193       fi
    1194     fi
    1195     iexp=`expr ${iexp} + 1`
    1196   # end of experiments
    1197   done
    1198613
    1199614  iost=`expr ${iost} + 1`
     
    1230645  fi
    1231646
    1232   iexp=1
    1233   for exp in ${exps}; do
    1234     expf=`echo ${exp} | tr ',' ' ' | awk '{print $1}'`
    1235     expl=`echo ${exp} | tr ',' ' ' | awk '{print $2}'`
    1236     expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'`
    1237     expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'`
    1238     expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'`
    1239 
    1240     simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}`
    1241 
    1242     for simf in ${simfiles}; do
    1243       simfn=`basename ${simf}`
    1244       fdate=`echo ${simfn} | tr '.' ' ' | awk '{print $1}' | tr '_' ' ' |            \
    1245         awk '{print $3"_"$4}'`
    1246 
    1247       simsfcptf=${odir}'/simout_vars_'${prn}'pt_'${stid}'_'${expl}'_'${fdate}'.nc'
    1248       simsfcdiagsf=${odir}'/simout_'${prn}'diags_'${stid}'_'${expl}'_'${fdate}'.nc'
    1249 
    1250       fvals=${ostlon}'#'${ostlat}'#'${simf}'#XLONG#XLAT#'${wrfdiags}'#'
    1251       fvals=${fvals}${wrfsfcnondiags}'#'${simdiagd}
    1252       get_WRFsurface_data ${fvals}
    1253 
    1254     # end of files
    1255     done
    1256 
    1257     # Concatenating files
    1258     ofile=${odir}/simout_${prn}vars_${stid}_${expl}.nc
    1259     if ${fscratch}; then rm ${ofile} >& /dev/null; fi
    1260     if test ! -f ${ofile}; then
    1261       Nconfc=`ls -1 ${odir}/simout_${prn}diags_*${stid}*${expl}*.nc | wc -l | awk '{print $1}'`
    1262       if test ${Nconfc} -gt 1; then
    1263         values=${odir}',Time,time'
    1264         HMT='simout_'${prn}'diags_,'${stid}'_'${expn},'nc'
    1265         python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}      \
    1266          -f ${HMT} -v all
    1267         if test $? -ne 0; then
    1268           echo ${errmsg}
    1269           echo "  python failed!!"
    1270           echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}\
    1271           -f ${HMT} -v all
    1272           exit
    1273         fi
    1274         echo " * Concatenating "${obstype}" data at point: "${ostlon}", "${ostlat} >> ${ofileins}
    1275         echo python  ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S \
    1276           "'"${values}"'" -f ${HMT} -v all >> ${ofileins}
    1277         echo " " >> ${ofileins}
    1278         mv netcdf_fold_concatenated_HMT.nc ${ofile}
    1279       else
    1280         ffilen=`ls -1 ${odir}/simout_${prn}diags_*${stid}*${expl}*.nc`
    1281         cp ${ffilen} ${ofile}
    1282       fi
    1283     fi
    1284     iexp=`expr ${iexp} + 1`
    1285   # end of experiments
    1286   done
    1287 
    1288647  iost=`expr ${iost} + 1`
    1289648done
    1290649if test ! ${sfcHf} = 'None'; then sfcstids=${oststids}; fi
    1291 
    1292 # surface data for maps
    1293 iost=1
    1294 obstype='surface_map'
    1295 prn='sfc'
    1296 listfiles=${sfcfiles}
    1297 wrfdiags=${wrfsfcdiags}
    1298 simdiagd=${simsfcmapdiagd}
    1299 iexp=1
    1300 for exp in ${exps}; do
    1301   expf=`echo ${exp} | tr ',' ' ' | awk '{print $1}'`
    1302   expl=`echo ${exp} | tr ',' ' ' | awk '{print $2}'`
    1303   expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'`
    1304   expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'`
    1305   expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'`
    1306 
    1307   simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}`
    1308 
    1309   for simf in ${simfiles}; do
    1310     simfn=`basename ${simf}`
    1311     fdate=`echo ${simfn} | tr '.' ' ' | awk '{print $1}' | tr '_' ' ' |            \
    1312       awk '{print $3"_"$4}'`
    1313 
    1314     simsfcmapf=${odir}'/simout_vars_'${prn}'map_'${expl}'_'${fdate}'.nc'
    1315     simsfcmapdiagsf=${odir}'/simout_'${prn}'mapdiags_'${expl}'_'${fdate}'.nc'
    1316 
    1317     fvals=${simf}'#'${wrfdiags}'#'${wrfsfcnondiags}'#'${simdiagd}
    1318     get_WRFsfc2D_data ${fvals}
    1319 
    1320   # end of files
    1321   done
    1322 
    1323   # Concatenating files
    1324   ofile=${odir}/simout_${prn}mapvars_${expl}.nc
    1325   if ${fscratch}; then rm ${ofile} >& /dev/null; fi
    1326   if test ! -f ${ofile}; then
    1327     Nconfc=`ls -1 ${odir}/simout_${prn}mapdiags_*${expl}*.nc | wc -l | awk '{print $1}'`
    1328     if test ${Nconfc} -gt 1; then
    1329       values=${odir}',Time,time'
    1330       HMT='simout_'${prn}'mapdiags_,'${expn},'nc'
    1331       python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}      \
    1332        -f ${HMT} -v all
    1333       if test $? -ne 0; then
    1334         echo ${errmsg}
    1335         echo "  python failed!!"
    1336         echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}\
    1337         -f ${HMT} -v all
    1338         exit
    1339       fi
    1340       echo " * Concatenating "${obstype}" data: " >> ${ofileins}
    1341       echo python  ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S           \
    1342         "'"${values}"'" -f ${HMT} -v all >> ${ofileins}
    1343       echo " " >> ${ofileins}
    1344       mv netcdf_fold_concatenated_HMT.nc ${ofile}
    1345     else
    1346       ffilen=`ls -1 ${odir}/simout_${prn}mapdiags_*${expl}*.nc`
    1347       cp ${ffilen} ${ofile}
    1348     fi
    1349   fi
    1350   iexp=`expr ${iexp} + 1`
    1351 # end of experiments
    1352 done
    1353650
    1354651###
Note: See TracChangeset for help on using the changeset viewer.