Changeset 2024 in lmdz_wrf for trunk/tools
- Timestamp:
- Aug 3, 2018, 10:51:34 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r2015 r2024 9954 9954 close: whether figure should be closed or not 9955 9955 """ 9956 fname = 'draw_ WindRose'9956 fname = 'draw_multiWindRose' 9957 9957 9958 9958 if values == 'h': -
trunk/tools/obs-sim_Comparison.bash
r2020 r2024 1 #!/bin/bash -x1 #!/bin/bash 2 2 # Shell script to compare observations with simulations using PyNCplot 3 3 # … … 720 720 } 721 721 722 function Ho moeller_SkewT_map_plot() {722 function Hovmoeller_SkewT_map_plot() { 723 723 # Function to plot a Hovmoeller SkewT_map 724 724 # sndstid: id of the sounding station … … 889 889 } 890 890 891 function multi_WindRose_plot(){ 892 # Function to plot a WindRose with data from multiple soundings 893 # sti: id of the sounding station 894 # stn: name of the sounding station to appear in plot ('!' for spaces) 895 # ofigdir: folder for the output of the figure 896 # files: files to use 897 # labs: labels of the legend 898 # lmark: marker of lines to use 899 # timeS: time of the plot as it should appear in the figure ('!' for spaces) 900 # timefS: time of the plot as it should appear in the figure's file 901 # figheader: header of the figure's file name 902 903 valuesfig=$1 904 905 stid=`echo ${valuesfig} | tr '%' ' ' | awk '{print $1}'` 906 stn=`echo ${valuesfig} | tr '%' ' ' | awk '{print $2}'` 907 ofigdir=`echo ${valuesfig} | tr '%' ' ' | awk '{print $3}'` 908 files=`echo ${valuesfig} | tr '%' ' ' | awk '{print $4}'` 909 labs=`echo ${valuesfig} | tr '%' ' ' | awk '{print $5}'` 910 lmark=`echo ${valuesfig} | tr '%' ' ' | awk '{print $6}'` 911 timeS=`echo ${valuesfig} | tr '%' ' ' | awk '{print $7}'` 912 timefS=`echo ${valuesfig} | tr '%' ' ' | awk '{print $8}'` 913 figheader=`echo ${valuesfig} | tr '%' ' ' | awk '{print $9}'` 914 915 values='linepoint;multicol;pres;-;'${lmark}';spectral;auto:'${labs}':' 916 values=${values}'WindRose!obs!,!sim!comparison!at!'${stid}'!on!'${timeS}'!UTC:' 917 values=${values}${kfig}':auto:''True' 918 919 ofign=${ofigdir}'/'${figheader}'_'${stid}'_'${timefS}'.'${kfig} 920 if ${gscratch}; then rm ${ofign} >& /dev/null; fi 921 if test ! -f ${ofign}; then 922 echo " WindRose comparison at: "${stid}" on "$(echo ${timeS} | tr '!' ' ') 923 python ${pyHOME}/drawing.py -o draw_multiWindRose -f ${files} -S ${values} 924 if test $? -ne 0; then 925 echo ${errmsg} 926 echo " python failed!!" 927 echo python ${pyHOME}/drawing.py -o draw_multiWindRose -f "'"${files}"'" \ 928 -S "'"${values}"'" 929 exit 930 fi 931 convert -trim multi_WindRose.${kfig} ${ofign} 932 echo "* "${ofign} >> ${ofilefigs} 933 echo python ${pyHOME}/drawing.py -o draw_multiWindRose -f "'"${files}"'" \ 934 -S "'"${values}"'" -v ${sfcv} >> ${ofilefigs} 935 echo " "${ofign} >> ${ofilefigs} 936 fi 937 } 938 891 939 ####### ####### 892 940 ## MAIN … … 938 986 obstype='sounding' 939 987 prn='snd' 940 listfiles=${sndfiles} 988 if test ! ${sndHf} = 'None'; then 989 listfiles=${sndfiles} 990 else 991 listfiles=' ' 992 fi 941 993 wrfdiags=${wrfsnddiags} 942 994 simdiagd=${simsnddiagd} … … 961 1013 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 962 1014 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 1015 expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'` 1016 1017 simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}` 1018 1019 ofile=${odir}/simout_${prn}vars_${stid}_${expl}.nc 1020 if ${fscratch}; then rm ${ofile} >& /dev/null; fi 1021 if test ! -f ${ofile}; then 1022 for simf in ${simfiles}; do 1023 simfn=`basename ${simf}` 1024 fdate=`echo ${simfn} | tr '.' ' ' | awk '{print $1}' | tr '_' ' ' | \ 1025 awk '{print $3"_"$4}'` 1026 1027 simsndptf=${odir}'/simout_vars_'${prn}'pt_'${stid}'_'${expl}'_'${fdate}'.nc' 1028 simsnddiagsf=${odir}'/simout_'${prn}'diags_'${stid}'_'${expl}'_'${fdate}'.nc' 1029 1030 fvals=${ostlon}'#'${ostlat}'#'${simf}'#XLONG#XLAT#'${wrfdiags}'#' 1031 fvals=${fvals}${simdiagd} 1032 get_WRFsounding_data ${fvals} 1033 1034 # end of files 1035 done 1036 1037 # Concatenating files 1038 Nconfc=`ls -1 ${odir}/simout_${prn}diags_*${stid}*${expl}*.nc | wc -l | \ 1039 awk '{print $1}'` 1040 if test ${Nconfc} -gt 1; then 1041 values=${odir}',Time,time' 1042 HMT='simout_'${prn}'diags_,'${stid}'_'${expn},'nc' 1043 python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values} \ 1044 -f ${HMT} -v all 1045 if test $? -ne 0; then 1046 echo ${errmsg} 1047 echo " python failed!!" 1048 echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}\ 1049 -f ${HMT} -v all 1050 exit 1051 fi 1052 echo " * Concatenating "${obstype}" data at point: "${ostlon}", "${ostlat} >> ${ofileins} 1053 echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S \ 1054 "'"${values}"'" -f ${HMT} -v all >> ${ofileins} 1055 echo " " >> ${ofileins} 1056 mv netcdf_fold_concatenated_HMT.nc ${ofile} 1057 else 1058 ffilen=`ls -1 ${odir}/simout_${prn}diags_*${stid}*${expl}*.nc` 1059 cp ${ffilen} ${ofile} 1060 fi 1061 fi 1062 iexp=`expr ${iexp} + 1` 1063 # end of experiments 1064 done 1065 1066 iost=`expr ${iost} + 1` 1067 done 1068 if test ! ${sndHf} = 'None'; then sndstids=${oststids}; fi 1069 1070 # surface data at station 1071 iost=1 1072 obstype='surface' 1073 prn='sfc' 1074 if test ! ${sfcHf} = 'None'; then 1075 listfiles=${sndfiles} 1076 else 1077 listfiles=' ' 1078 fi 1079 wrfdiags=${wrfsfcdiags} 1080 simdiagd=${simsfcdiagd} 1081 for ostf in ${listfiles}; do 1082 stid=`python $pyHOME/nc_var.py -o varout -f ${ostf} -S 'time:0' -v id | grep NC \ 1083 | awk '{printf("%d",$2)}'` 1084 ostlon=`python $pyHOME/nc_var.py -o varout -f ${ostf} -S 'time:0' -v lon | grep NC \ 1085 | awk '{print $2}'` 1086 ostlat=`python $pyHOME/nc_var.py -o varout -f ${ostf} -S 'time:0' -v lat | grep NC \ 1087 | awk '{print $2}'` 1088 ostheight=`python $pyHOME/nc_var.py -o varout -f ${ostf} -S 'time:0' -v height | \ 1089 grep NC | awk '{print $2}'` 1090 1091 if test ! ${wdir}/stations.inf; then 1092 oststids=${stid}'@'${ostf} 1093 echo ${prn}","${stid}","${ostlon}","${ostlat}","${ostheight} > ${wdir}/stations.inf 1094 else 1095 oststids=${oststids}':'${stid}'@'${ostf} 1096 echo ${prn}","${stid}","${ostlon}","${ostlat}","${ostheight} >> ${wdir}/stations.inf 1097 fi 1098 1099 iexp=1 1100 for exp in ${exps}; do 1101 expf=`echo ${exp} | tr ',' ' ' | awk '{print $1}'` 1102 expl=`echo ${exp} | tr ',' ' ' | awk '{print $2}'` 1103 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 1104 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 1105 expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'` 963 1106 964 1107 simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}` … … 969 1112 awk '{print $3"_"$4}'` 970 1113 971 sims ndptf=${odir}'/simout_vars_'${prn}'pt_'${stid}'_'${expl}'_'${fdate}'.nc'972 sims nddiagsf=${odir}'/simout_'${prn}'diags_'${stid}'_'${expl}'_'${fdate}'.nc'1114 simsfcptf=${odir}'/simout_vars_'${prn}'pt_'${stid}'_'${expl}'_'${fdate}'.nc' 1115 simsfcdiagsf=${odir}'/simout_'${prn}'diags_'${stid}'_'${expl}'_'${fdate}'.nc' 973 1116 974 1117 fvals=${ostlon}'#'${ostlat}'#'${simf}'#XLONG#XLAT#'${wrfdiags}'#' 975 fvals=${fvals}${ simdiagd}976 get_WRFs ounding_data ${fvals}1118 fvals=${fvals}${wrfsfcnondiags}'#'${simdiagd} 1119 get_WRFsurface_data ${fvals} 977 1120 978 1121 # end of files … … 1012 1155 iost=`expr ${iost} + 1` 1013 1156 done 1014 sndstids=${oststids} 1015 1016 # surface data at station 1017 iost=1 1018 obstype='surface' 1019 prn='sfc' 1020 listfiles=${sfcfiles} 1021 wrfdiags=${wrfsfcdiags} 1022 simdiagd=${simsfcdiagd} 1023 for ostf in ${listfiles}; do 1024 1025 stid=`python $pyHOME/nc_var.py -o varout -f ${ostf} -S 'time:0' -v id | grep NC \ 1026 | awk '{printf("%d",$2)}'` 1027 ostlon=`python $pyHOME/nc_var.py -o varout -f ${ostf} -S 'time:0' -v lon | grep NC \ 1028 | awk '{print $2}'` 1029 ostlat=`python $pyHOME/nc_var.py -o varout -f ${ostf} -S 'time:0' -v lat | grep NC \ 1030 | awk '{print $2}'` 1031 ostheight=`python $pyHOME/nc_var.py -o varout -f ${ostf} -S 'time:0' -v height | \ 1032 grep NC | awk '{print $2}'` 1033 1034 if test ! ${wdir}/stations.inf; then 1035 oststids=${stid}'@'${ostf} 1036 echo ${prn}","${stid}","${ostlon}","${ostlat}","${ostheight} > ${wdir}/stations.inf 1037 else 1038 oststids=${oststids}':'${stid}'@'${ostf} 1039 echo ${prn}","${stid}","${ostlon}","${ostlat}","${ostheight} >> ${wdir}/stations.inf 1040 fi 1041 1042 iexp=1 1043 for exp in ${exps}; do 1044 expf=`echo ${exp} | tr ',' ' ' | awk '{print $1}'` 1045 expl=`echo ${exp} | tr ',' ' ' | awk '{print $2}'` 1046 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 1047 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 1048 1049 simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}` 1050 1051 for simf in ${simfiles}; do 1052 simfn=`basename ${simf}` 1053 fdate=`echo ${simfn} | tr '.' ' ' | awk '{print $1}' | tr '_' ' ' | \ 1054 awk '{print $3"_"$4}'` 1055 1056 simsfcptf=${odir}'/simout_vars_'${prn}'pt_'${stid}'_'${expl}'_'${fdate}'.nc' 1057 simsfcdiagsf=${odir}'/simout_'${prn}'diags_'${stid}'_'${expl}'_'${fdate}'.nc' 1058 1059 fvals=${ostlon}'#'${ostlat}'#'${simf}'#XLONG#XLAT#'${wrfdiags}'#' 1060 fvals=${fvals}${wrfsfcnondiags}'#'${simdiagd} 1061 get_WRFsurface_data ${fvals} 1062 1063 # end of files 1064 done 1065 1066 # Concatenating files 1067 ofile=${odir}/simout_${prn}vars_${stid}_${expl}.nc 1068 if ${fscratch}; then rm ${ofile} >& /dev/null; fi 1069 if test ! -f ${ofile}; then 1070 Nconfc=`ls -1 ${odir}/simout_${prn}diags_*${stid}*${expl}*.nc | wc -l | awk '{print $1}'` 1071 if test ${Nconfc} -gt 1; then 1072 values=${odir}',Time,time' 1073 HMT='simout_'${prn}'diags_,'${stid}'_'${expn},'nc' 1074 python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values} \ 1075 -f ${HMT} -v all 1076 if test $? -ne 0; then 1077 echo ${errmsg} 1078 echo " python failed!!" 1079 echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values}\ 1080 -f ${HMT} -v all 1081 exit 1082 fi 1083 echo " * Concatenating "${obstype}" data at point: "${ostlon}", "${ostlat} >> ${ofileins} 1084 echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S \ 1085 "'"${values}"'" -f ${HMT} -v all >> ${ofileins} 1086 echo " " >> ${ofileins} 1087 mv netcdf_fold_concatenated_HMT.nc ${ofile} 1088 else 1089 ffilen=`ls -1 ${odir}/simout_${prn}diags_*${stid}*${expl}*.nc` 1090 cp ${ffilen} ${ofile} 1091 fi 1092 fi 1093 iexp=`expr ${iexp} + 1` 1094 # end of experiments 1095 done 1096 1097 iost=`expr ${iost} + 1` 1098 done 1099 sfcstids=${oststids} 1157 if test ! ${sfcHf} = 'None'; then sfcstids=${oststids}; fi 1100 1158 1101 1159 # surface data for maps … … 1112 1170 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 1113 1171 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 1172 expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'` 1114 1173 1115 1174 simfiles=`ls -1 ${simdir}/${expf}/${simH}*${simM}*${simT}` … … 1343 1402 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 1344 1403 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 1404 expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'` 1345 1405 1346 1406 #simjoinselvars=${odir}'/simout_vars_'${expl}'.nc' … … 1394 1454 tdacompltyp='-,-.' 1395 1455 tacompfiles=${sndorigfn}':pres|-1,time|'${it}':ta,pres;' 1396 tacompfiles=${tacompfiles}${simsndptf}':bottom_top|-1, time|'${timestep}':'1456 tacompfiles=${tacompfiles}${simsndptf}':bottom_top|-1,Time|'${timestep}':' 1397 1457 tacompfiles=${tacompfiles}'ta,pres' 1398 1458 tdacompfiles=${sndorigfn}':pres|-1,time|'${it}':tda,pres;' 1399 tdacompfiles=${tdacompfiles}${simsndptf}':bottom_top|-1, time|'${timestep}':'1459 tdacompfiles=${tdacompfiles}${simsndptf}':bottom_top|-1,Time|'${timestep}':' 1400 1460 tdacompfiles=${tdacompfiles}'tda,pres' 1461 1462 # multi Wind-Rose 1463 # Getting pressure level from observations to plot 1464 if test ${it} -eq 0; then 1465 fstats=`python $pyHOME/nc_var.py -o field_stats -S full,1.e+20,None \ 1466 -f ${simsndptf} -v pres | grep MAT | grep pres` 1467 nsimpres=`echo ${fstats} | awk '{printf ("%d",$3*1000)}'` 1468 fi 1469 1470 obsuavaf=${odir}/sounding_uava_${stid}.nc 1471 obspres=`python $pyHOME/nc_var.py -o varout -f ${obsuavaf} -S time:${it} \ 1472 -v pres | awk '{print $2}' | tr '\n' ' '` 1473 kobs=0 1474 for obsp0 in ${obspres}; do 1475 obsp=`echo ${obsp0} | awk '{printf ("%d",$1*1000)}'` 1476 if test ${obsp} -gt ${nsimpres}; then kobs=`expr ${kobs} + 1` 1477 else kobs=`expr ${kobs} + 1`; break; fi 1478 done 1479 1480 mWRcomplabs='obs,'${expn} 1481 mWRcompfiles=${odir}'/sounding_uava_'${stid}'.nc@pres|1,'${kobs}',1;time|' 1482 mWRcompfiles=${mWRcompfiles}${it}'@ua,va#'${simsndptf}'@bottom_top|-1;Time|' 1483 mWRcompfiles=${mWRcompfiles}${timestep}'@ua,va' 1484 mWRmarks='.@'${expm} 1401 1485 else 1402 1486 tacomplabs=${tacomplabs}',$ta^{'${expn}'}$' … … 1406 1490 tacompltyp=${tacompltyp}',-' 1407 1491 tdacompltyp=${tdacompltyp}',-.' 1408 tacompfiles=${tacompfiles}';'${simsndptf}':bottom_top|-1, time|'${timestep}':'1492 tacompfiles=${tacompfiles}';'${simsndptf}':bottom_top|-1,Time|'${timestep}':' 1409 1493 tacompfiles=${tacompfiles}'ta,pres' 1410 tdacompfiles=${tdacompfiles}';'${simsndptf}':bottom_top|-1, time|'${timestep}1494 tdacompfiles=${tdacompfiles}';'${simsndptf}':bottom_top|-1,Time|'${timestep} 1411 1495 tdacompfiles=${tdacompfiles}':tda,pres' 1496 # multi Wind-Rose 1497 mWRcomplabs=${mWRcomplabs}','${expn} 1498 mWRcompfiles=${mWRcompfiles}'#'${simsndptf}'@bottom_top|-1;Time|'${timestep} 1499 mWRcompfiles=${mWRcompfiles}'@ua,va' 1500 mWRmarks=${mWRmarks}'@'${expm} 1412 1501 fi 1413 1502 1414 # Hovmoeller maps 1415 sndvs=`echo ${sndvars} | tr ':' ' '` 1416 for sndv in ${sndvs}; do 1417 1418 CFvarvals=`python $pyHOME/generic.py -o variables_values -S ${sndv}` 1419 cbar=`echo ${CFvarvals} | tr ':' ' ' | awk '{print $7}'` 1420 1421 fivals=${stid}'#'${sndstn}'#'${sndv}'#'${ofigdir}'#'${datefS}'#'${fmtTts} 1422 fivals=${fivals}'#'${simsndptf}'#'${sndorigfn}'#'${expl}'#'${expn}'#'${cbar} 1423 fivals=${fivals}'#SkewT-logP_obs-sim_evol' 1424 1425 Homoeller_SkewT_map_plot ${fivals} 1426 1427 # end sounding vars 1428 done 1503 if test ${it} -eq 0; then 1504 # Hovmoeller maps 1505 sndvs=`echo ${sndvars} | tr ':' ' '` 1506 for sndv in ${sndvs}; do 1507 1508 CFvarvals=`python $pyHOME/generic.py -o variables_values -S ${sndv}` 1509 cbar=`echo ${CFvarvals} | tr ':' ' ' | awk '{print $7}'` 1510 1511 fivals=${stid}'#'${sndstn}'#'${sndv}'#'${ofigdir}'#'${datefS}'#'${fmtTts} 1512 fivals=${fivals}'#'${simsndptf}'#'${sndorigfn}'#'${expl}'#'${expn}'#'${cbar} 1513 fivals=${fivals}'#SkewT-logP_obs-sim_evol' 1514 1515 Hovmoeller_SkewT_map_plot ${fivals} 1516 1517 # end sounding vars 1518 done 1519 fi 1429 1520 1430 1521 iexp=`expr ${iexp} + 1` … … 1438 1529 1439 1530 fivals=${stid}'@'${sndstn}'@'${complabs}'@'${compcols}'@'${compltyp}'@' 1440 fivals=${fivals}${compfiles}'@'${dateS}'@'${ofigdir}'@'${datefS}'@' ${ofigdir}'@'1531 fivals=${fivals}${compfiles}'@'${dateS}'@'${ofigdir}'@'${datefS}'@' 1441 1532 fivals=${fivals}'SkewT-logP_obs-sim_step' 1442 1533 multi_SkewT_logP_plot ${fivals} 1443 1534 1444 1535 # Wind Rose comparison 1445 fivals=${it}'#'${stid}'#'${sndstn}'#'${timeS}'#'${ofigdir}'#'${timefS}'#' 1446 fivals=${fivals}${ouavasndf}'#WindRose_obs-sim_' 1536 fivals=${stid}'%'${sndstn}'%'${ofigdir}'%'${mWRcompfiles}'%'${mWRcomplabs}'%' 1537 fivals=${fivals}${mWRmarks}'%'${dateS}'%'${datefS}'%WindRose_obs-sim_step' 1538 1447 1539 multi_WindRose_plot ${fivals} 1448 1540 … … 1453 1545 # End of soundings stations 1454 1546 done 1547 exit 1455 1548 1456 1549 ### … … 1606 1699 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 1607 1700 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 1701 expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'` 1608 1702 1609 1703 simsfcdiagf=${odir}'/simout_sfcvars_'${stdi}'_'${expl}'.nc' … … 1642 1736 expn=`echo ${exp} | tr ',' ' ' | awk '{print $3}'` 1643 1737 expc=`echo ${exp} | tr ',' ' ' | awk '{print $4}'` 1738 expm=`echo ${exp} | tr ',' ' ' | awk '{print $5}'` 1644 1739 1645 1740 simsfcdiagf=${odir}'/simout_sfcmapdiags_'${expl}'.nc'
Note: See TracChangeset
for help on using the changeset viewer.