Changeset 2006 in lmdz_wrf
- Timestamp:
- Aug 1, 2018, 10:45:00 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/obs-sim_Comparison.bash
r1995 r2006 133 133 } 134 134 135 function isin_list() { 136 # Function to check whether a value is in a list 137 list=$1 138 value=$2 139 140 is=`echo ${list} | tr ':' '\n' | awk '{print "@"$1"@"}' | grep '@'${value}'@' | wc -w` 141 if test ${is} -eq 1 142 then 143 true 144 else 145 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' 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=${Dfilen}/${Hhfilen}'_Time_B0-E-1-I1_bottom_top_B0-E-1-I1_'${yslc}'_'${xslc}'_' 216 ofilen=${ofilen}${ystslc}'_'${xstslc}'.nc' 217 mv ${ofilen} ${simsndptf} 218 fi 219 220 # Computing sounding diagnostics 221 diagns=`echo ${snddiagnames} | tr ':' ' '` 222 223 idiag=1 224 for diagn in ${diagns}; do 225 diagv=`cat $pyHOME/diagnostics.inf | grep ${diagn}',' | tr ',' ' ' | \ 226 awk '{print $2"|"$3}'` 227 if test ${idiag} -eq 1; then 228 snddiagvals=${diagv} 229 else 230 snddiagvals=${snddiagvals}','${diagv} 231 fi 232 idiag=`expr ${idiag} + 1` 233 done 234 235 if ${fscratch}; then rm ${simsnddiagsf}; fi 236 if test ! -f ${simsnddiagsf}; then 237 python ${pyHOME}/diagnostics.py -f ${simsndptf} -d ${snddiagd} -v ${snddiagvals} 238 if test $? -ne 0; then 239 echo ${errmsg} 240 echo " python failed!!" 241 echo python ${pyHOME}/diagnostics.py -f ${simsndptf} -d "'"${snddiagd}"'" -v \ 242 "'"${snddiagvals}"'" 243 exit 244 fi 245 echo "* computing diagnostics at snd point: "${stlon}", "${stlat} >> ${ofileins} 246 echo python ${pyHOME}/diagnostics.py -f "'"${simsndptf}"'" -d "'"${snddiagd}"'" \ 247 -v "'"${snddiagvals}"'" >> ${ofileins} 248 echo " " >> ${ofileins} 249 250 mv diagnostics.nc ${simsnddiagsf} 251 if $(isin_list ${snddiagnames} WRFt); then 252 #To deg 253 python ${pyHOME}/nc_var.py -o valmod -S subc,273.15 -f ${simsnddiagsf} -v ta 254 fi 255 if $(isin_list ${snddiagnames} WRFp); then 256 #To Pa 257 python ${pyHOME}/nc_var.py -o valmod -S divc,100. -f ${simsnddiagsf} -v pres 258 fi 259 fi 260 } 261 262 function get_WRFsurface_data(){ 263 # Function to get the data to compute analysis in a surface point 264 # stlon= longitude value of the station 265 # stlat= latitude value of the station 266 # filen= name of the file 267 # lonvarn= name of the longitude variable 268 # latvarn= name of the latitude variable 269 # sfcdiagnames= diagnostics to compute (as ':' separated list) 270 # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for 271 # without) 272 # sfcdiagd= name of the dimensions and dimension variables to use for diagnostics 273 274 funcvals=$1 275 276 stlon=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'` 277 stlat=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'` 278 filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'` 279 lonvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'` 280 latvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $5}'` 281 sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $6}'` 282 nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $7}'` 283 sfcdiagd=`echo ${funcvals} | tr '#' ' ' | awk '{print $8}'` 284 285 vals=${lonvarn}':'${latvarn}':Time|0' 286 gridsndv=`python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \ 287 -v ${stlon},${stlat} | tr ' ' '!'` 288 echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins} 289 echo python ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \ 290 -v ${stlon},${stlat} >> ${ofileins} 291 echo " " >> ${ofileins} 292 xsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ 293 awk '{print $1}'` 294 ysnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ 295 awk '{print $2}'` 296 dsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $2}'` 297 298 xsnd1=`expr ${xsnd} + 1` 299 ysnd1=`expr ${ysnd} + 1` 300 301 # Getting values 302 if ${fscratch}; then rm ${simsfcptf} >& /dev/null; fi 303 if test ! -f ${simsfcptf}; then 304 values='Time,0,-1,1@south_north,'${ysnd}','${ysnd}',1@' 305 values=${values}'west_east,'${xsnd}','${xsnd}',1@south_north_stag,'${ysnd}',' 306 values=${values}${ysnd1}',1@west_east_stag,'${xsnd}','${xsnd1}',1' 307 python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 308 -S ${values} -v all 309 if test $? -ne 0; then 310 echo ${errmsg} 311 echo " python failed!!" 312 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 313 -S "'"${values}"'" -v all 314 exit 315 fi 316 echo "* get values at sfc point: "${stlon}", "${stlat} >> ${ofileins} 317 echo python ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ 318 -S "'"${values}"'" -v all >> ${ofileins} 319 echo " " >> ${ofileins} 320 yslc='south_north_B'${ysnd}'-E'${ysnd}'-I1' 321 ystslc='south_north_stag_B'${ysnd}'-E'${ysnd1}'-I1' 322 xslc='west_east_B'${xsnd}'-E'${xsnd}'-I1' 323 xstslc='west_east_stag_B'${xsnd}'-E'${xsnd1}'-I1' 324 325 ofilen=${filen}'_Time_B0-E-1-I1_'${yslc}'_'${xslc}'_'${ystslc}'_'${xstslc}'.nc' 326 mv ${ofilen} ${simsfcptf} 327 fi 328 329 # Computing sfc diagnostics 330 diagns=`echo ${sfcdiagnames} | tr ':' ' '` 331 332 idiag=1 333 for diagn in ${diagns}; do 334 diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' | \ 335 awk '{print $2"|"$3}'` 336 if test ${idiag} -eq 1; then 337 sfcdiagvals=${diagv} 338 else 339 sfcdiagvals=${sfcdiagvals}','${diagv} 340 fi 341 idiag=`expr ${idiag} + 1` 342 done 343 344 if ${fscratch}; then rm ${simsfcdiagsf}; fi 345 if test ! -f ${simsfcdiagsf}; then 346 python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d ${sfcdiagd} -v ${sfcdiagvals} 347 if test $? -ne 0; then 348 echo ${errmsg} 349 echo " python failed!!" 350 echo python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ 351 -v "'"${sfcdiagvals}"'" 352 exit 353 fi 354 echo "* diagnostics at sfc point: "${stlon}", "${stlat} >> ${ofileins} 355 echo python ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ 356 -v "'"${sfcdiagvals}"'" >> ${ofileins} 357 echo " " >> ${ofileins} 358 mv diagnostics.nc ${simsfcdiagsf} 359 if $(isin_list ${sfcdiagnames} wds); then 360 #To rad 361 python ${pyHOME}/nc_var.py -o valmod -S mulc,0.0174532925199 -f ${simsfcdiagsf}\ 362 -v wds 363 python ${pyHOME}/nc_var.py -o varaddattr -S 'units|rad' -f ${simsfcdiagsf} -v wds 364 fi 365 fi 366 367 #Adding non-diagnostic variables 368 if test ! ${nondiagvs} = 'None'; then 369 varsadd=`echo ${nondiagvs} | tr ':' ' '` 370 for vadd in ${varsadd}; do 371 python ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd} -f ${simsfcdiagsf} 372 if test $? -ne 0; then 373 echo ${errmsg} 374 echo " python failed!!" 375 echo python ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ 376 -f ${simsfcdiagsf} 377 exit 378 rm ${simsfcdiagsf} 379 fi 380 echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >> ${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} | tr ':' ' ' |\ 386 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} -v ${vadd} 395 if test $? -ne 0; then 396 echo ${errmsg} 397 echo " python failed!!" 398 echo python ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} \ 399 -v ${vadd} 400 exit 401 rm ${simsfcdiagsf} 402 fi 403 done 404 fi 405 } 406 135 407 function WindRose_plot() { 136 408 # Function to plot a Wind rose … … 479 751 480 752 mkdir -p ${odir} 481 753 ofileins=${wdir}/allins_functions.inf 482 754 ofilefigs=${wdir}/allins_figures.inf 483 755 if ${fscratch}; then 484 echo "*** Instruction from all figures" > ${ofilefigs} 756 echo "*** Instruction from all functions _______" > ${ofileins} 757 echo " " >> ${ofileins} 758 echo "*** Instruction from all figures _______" > ${ofilefigs} 759 echo " " >> ${ofilefigs} 485 760 fi 761 762 # Files in sounding folder (from UWyoming_netcdf.py) 763 if test ! ${sndHf} = 'None'; then 764 sndfs=`ls -1 ${snddir}/${sndHf}* | tr '\n' ':'` 765 echo "Soundings files _______" 766 echo ${sndfs} | tr ':' '\n' 767 sndfiles=`echo ${sndfs} | tr ':' ' '` 768 else 769 sndfiles='None' 770 fi 771 772 # Files in sounding folder (from UWyoming_netcdf.py) 773 if test ! ${sfcHf} = 'None'; then 774 sfcfs=`ls -1 ${sfcdir}/${sfcHf}** | tr '\n' ':'` 775 echo "Surface files _______" 776 echo ${sfcfs} | tr ':' '\n' 777 sfcfiles=`echo ${sfcfs} | tr ':' ' '` 778 else 779 sfcfiles='None' 780 fi 781 782 exps=`echo ${sims} | tr ':' ' '` 783 simH=`echo ${simHMT} | tr ',' ' ' | awk '{print $1}'` 784 simM=`echo ${simHMT} | tr ',' ' ' | awk '{print $2}'` 785 simT=`echo ${simHMT} | tr ',' ' ' | awk '{print $3}'` 486 786 487 787 ### … … 489 789 ### 490 790 491 # sounding diags 791 # sounding data 792 isnd=1 793 for sndf in ${sndfiles}; do 794 stid=`python $pyHOME/nc_var.py -o grattr -f ${sndf} -S Station_number` 795 sndlon=`ncdump -h ${sndf} | grep Station_longitude | awk '{print $3}'` 796 sndlat=`ncdump -h ${sndf} | grep Station_latitude | awk '{print $3}'` 797 sndheight=`ncdump -h ${sndf} | grep Station_elevation | awk '{print $3}'` 798 799 if test ${isnd} -eq 1; then 800 sndstids=${stid}'@'${sndf} 801 echo "snd,"${stid}","${sndlon}","${sndlat}","${sndheight} > ${wdir}/stations.inf 802 else 803 sndstids=${sndstids}':'${stid}'@'${sndf} 804 echo "snd,"${stid}","${sndlon}","${sndlat}","${sndheight} >> ${wdir}/stations.inf 805 fi 806 807 iexp=1 808 for exp in ${exps}; do 809 expf=`echo ${exp} | tr ',' ' ' | awk '{print $1}'` 810 expl=`echo ${exp} | tr ',' ' ' | awk '{print $2}'` 811 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 812 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 813 814 simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}` 815 816 for simf in ${simfiles}; do 817 simfn=`basename ${simf}` 818 fdate=`echo ${simfn} | tr '.' ' ' | awk '{print $1}' | tr '_' ' ' | \ 819 awk '{print $3"_"$4}'` 820 821 simsndptf=${odir}'/simout_vars_sndpt_'${stid}'_'${expl}'_'${fdate}'.nc' 822 simsnddiagsf=${odir}'/simout_snddiags_'${stid}'_'${expl}'_'${fdate}'.nc' 823 824 fvals=${sndlon}'#'${sndlat}'#'${simf}'#XLONG#XLAT#'${wrfsnddiags}'#' 825 fvals=${fvals}${simsnddiagd} 826 get_WRFsounding_data ${fvals} 827 828 # end of files 829 done 830 831 # Concatenating files 832 ofile=${odir}/simout_sndvars_${stid}_${expn}.nc 833 if ${fscratch}; then rm ${ofile} >& /dev/null; fi 834 if test ! -f ${ofile}; then 835 Nconfc=`ls -1 ${odir}/simout_snddiags_*${stid}*nc | wc -l | awk '{print $1}'` 836 if test ${Nconfc} -gt 1; then 837 values=${odir}',Time,time' 838 HMT='simout_snddiags_,'${stid},'nc' 839 python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values} \ 840 -f ${HMT} -v all 841 if test $? -ne 0; then 842 echo ${errmsg} 843 echo " python failed!!" 844 echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}\ 845 -f ${HMT} -v all 846 exit 847 fi 848 echo " * Concatenating sounding data at point: "${sndlon}", "${sndlat} >> ${ofileins} 849 echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S \ 850 "'"${values}"'" -f ${HMT} -v all >> ${ofileins} 851 echo " " >> ${ofileins} 852 mv netcdf_fold_concatenated_HMT.nc ${ofile} 853 else 854 ffilen=`ls -1 ${odir}/simout_snddiags_*${stid}*nc` 855 cp ${ffilen} ${ofile} 856 fi 857 fi 858 859 iexp=`ecpr ${iexp} + 1` 860 # end of experiments 861 done 862 863 isnd=`expr ${isnd} + 1` 864 done 865 exit 866 492 867 diagns=`echo ${wrfsnddiags} | tr ':' ' '` 493 868 snddiagd='time@time,bottom_top@P,south_north@XLAT,west_east@XLONG' … … 640 1015 ### 641 1016 642 # Files in sounding folder (from UWyoming_netcdf.py)643 sndfiles=`ls -1 ${snddir}/${sndHf}*`644 645 echo "Soundings files:"${sndfiles}646 647 1017 isnd=1 648 1018 for sndf in ${sndfiles}; do … … 662 1032 mv diagnostics.nc ${ouavasndf} 663 1033 fi 664 if test ${isnd} -eq 1; then sndstids=${stid}'@'${sndf}665 else sndstids=${sndstids}':'${stid}'@'${sndf}; fi666 isnd=`expr ${isnd} + 1`667 1034 done 668 1035 … … 924 1291 # Joining all observations 925 1292 obssfcfile=${odir}'/all_single-stations.nc' 926 if test ! -f ${wdir}/${sfc obsdir}/${obssfcfile}; then1293 if test ! -f ${wdir}/${sfcdir}/${obssfcfile}; then 927 1294 python ${pyHOME}/nc_var.py -o join_singlestation_obsfiles -S \ 928 ${sfc obsdir}':OBSnetcdf' -v all1295 ${sfcdir}':OBSnetcdf' -v all 929 1296 if test $? -ne 0; then 930 1297 echo ${errmsg} 931 1298 echo " python failed!!" 932 1299 echo python ${pyHOME}/nc_var.py -o join_singlestation_obsfiles \ 933 -S ${sfc obsdir}':OBSnetcdf' -v all1300 -S ${sfcdir}':OBSnetcdf' -v all 934 1301 fi 935 1302 mv joined_singlestations.nc ${obssfcfile} -
trunk/tools/obs_simComparison.conf
r1984 r2006 33 33 34 34 # Folder with the observations surface files (single-station) 35 sfc obsdir=/home/lluis/estudios/ChemGBsAs/tests/199501/obs/sfc_CAM35 sfcdir=/home/lluis/estudios/ChemGBsAs/tests/199501/obs/sfc_CAM 36 36 37 # Header of the name of the surface observ stional files38 obsHf = OBSnetcdf_37 # Header of the name of the surface observational files 38 sfcHf = OBSnetcdf_ 39 39 40 40 # Name of surface variables and their extreme values in plots as … … 59 59 # Header, Middle, and, tail of the name of the simulation files [H],[M],[T] 60 60 simHMT = wrfout,d01,00 61 62 # Dimensions to use for sounding diagnostics 63 simsnddiagd=Time@time,bottom_top@P 64 65 # Dimensions to use for surface diagnostics 66 simsfcdiagd=Time@time 61 67 62 68 # time information from file
Note: See TracChangeset
for help on using the changeset viewer.