Changeset 2019 in lmdz_wrf for trunk/tools
- Timestamp:
- Aug 2, 2018, 10:24:30 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/obs-sim_Comparison.bash
r2017 r2019 1 #!/bin/bash 1 #!/bin/bash -x 2 2 # Shell script to compare observations with simulations using PyNCplot 3 3 # … … 407 407 } 408 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 409 547 function WindRose_plot() { 410 548 # Function to plot a Wind rose … … 876 1014 sndstids=${oststids} 877 1015 878 # surface data 1016 # surface data at station 879 1017 iost=1 880 1018 obstype='surface' … … 961 1099 sfcstids=${oststids} 962 1100 1101 # surface data for maps 1102 iost=1 1103 obstype='surface_map' 1104 prn='sfc' 1105 listfiles=${sfcfiles} 1106 wrfdiags=${wrfsfcdiags} 1107 simdiagd=${simsfcmapdiagd} 1108 iexp=1 1109 for exp in ${exps}; do 1110 expf=`echo ${exp} | tr ',' ' ' | awk '{print $1}'` 1111 expl=`echo ${exp} | tr ',' ' ' | awk '{print $2}'` 1112 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 1113 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 1114 1115 simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}` 1116 1117 for simf in ${simfiles}; do 1118 simfn=`basename ${simf}` 1119 fdate=`echo ${simfn} | tr '.' ' ' | awk '{print $1}' | tr '_' ' ' | \ 1120 awk '{print $3"_"$4}'` 1121 1122 simsfcmapf=${odir}'/simout_vars_'${prn}'map_'${expl}'_'${fdate}'.nc' 1123 simsfcmapdiagsf=${odir}'/simout_'${prn}'mapdiags_'${expl}'_'${fdate}'.nc' 1124 1125 fvals=${simf}'#'${wrfdiags}'#'${wrfsfcnondiags}'#'${simdiagd} 1126 get_WRFsfc2D_data ${fvals} 1127 1128 # end of files 1129 done 1130 1131 # Concatenating files 1132 ofile=${odir}/simout_${prn}mapvars_${expl}.nc 1133 if ${fscratch}; then rm ${ofile} >& /dev/null; fi 1134 if test ! -f ${ofile}; then 1135 Nconfc=`ls -1 ${odir}/simout_${prn}mapdiags_*${expl}*.nc | wc -l | awk '{print $1}'` 1136 if test ${Nconfc} -gt 1; then 1137 values=${odir}',Time,time' 1138 HMT='simout_'${prn}'mapdiags_,'${expn},'nc' 1139 python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values} \ 1140 -f ${HMT} -v all 1141 if test $? -ne 0; then 1142 echo ${errmsg} 1143 echo " python failed!!" 1144 echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}\ 1145 -f ${HMT} -v all 1146 exit 1147 fi 1148 echo " * Concatenating "${obstype}" data: " >> ${ofileins} 1149 echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S \ 1150 "'"${values}"'" -f ${HMT} -v all >> ${ofileins} 1151 echo " " >> ${ofileins} 1152 mv netcdf_fold_concatenated_HMT.nc ${ofile} 1153 else 1154 ffilen=`ls -1 ${odir}/simout_${prn}mapdiags_*${expl}*.nc` 1155 cp ${ffilen} ${ofile} 1156 fi 1157 fi 1158 iexp=`expr ${iexp} + 1` 1159 # end of experiments 1160 done 1161 963 1162 ### 964 1163 ## … … 1101 1300 # End of soundings 1102 1301 done 1103 exit1104 1302 1105 1303 # snd-sims comparison … … 1256 1454 done 1257 1455 1258 exit1259 1260 1456 ### 1261 1457 ## SFC figures … … 1264 1460 # Joining all observations 1265 1461 obssfcfile=${odir}'/all_single-stations.nc' 1266 if test ! -f ${ wdir}/${sfcdir}/${obssfcfile}; then1462 if test ! -f ${obssfcfile}; then 1267 1463 python ${pyHOME}/nc_var.py -o join_singlestation_obsfiles -S \ 1268 1464 ${sfcdir}':OBSnetcdf' -v all
Note: See TracChangeset
for help on using the changeset viewer.