| 1 | #!/bin/bash |
|---|
| 2 | ### Script to get sounding and surface points for validation purposes |
|---|
| 3 | |
|---|
| 4 | scratch='false' |
|---|
| 5 | |
|---|
| 6 | # Input folder |
|---|
| 7 | infolder='/ccc/scratch/cont003/lmd/fitaborl/estudios/FPS_ALPS/additional/IOP' |
|---|
| 8 | |
|---|
| 9 | # Output folder |
|---|
| 10 | ofolder='/ccc/scratch/cont003/lmd/fitaborl/estudios/FPS_ALPS/additional/IOP/validation' |
|---|
| 11 | |
|---|
| 12 | # Labels of the experiments |
|---|
| 13 | experiments='120lev:80lev:50lev:50lev_assigned:38lev:NOaerosol' |
|---|
| 14 | |
|---|
| 15 | # Sounding stations [sndid],[sndlon],[sndlat]:[sndid2],[sndlon2],[sndlat2]:... |
|---|
| 16 | sndstations='10868,11.55,48.25:16080,9.28,45.43:16144,11.61,44.65:16546,8.85,39.35' |
|---|
| 17 | |
|---|
| 18 | # Surface stations [sfcid],[sfclon],[sfclat]:[sfcid2],[sfclon2],[sfclat2]:... |
|---|
| 19 | sfcstations='None' |
|---|
| 20 | |
|---|
| 21 | # Sounding diagnostics |
|---|
| 22 | snddiags='WRFt:WRFtda:WRFp:WRFua:WRFva:ws:WRFwd' |
|---|
| 23 | |
|---|
| 24 | # Surface diagnostics |
|---|
| 25 | sfcdiags='wds:wss:WRFtdas' |
|---|
| 26 | |
|---|
| 27 | # Surface NON-diag variables |
|---|
| 28 | sfcnondiags='T2' |
|---|
| 29 | |
|---|
| 30 | ####### ####### |
|---|
| 31 | ## MAIN |
|---|
| 32 | ####### |
|---|
| 33 | insoutf='allins_functions.inf' |
|---|
| 34 | module load python/2.7.14 |
|---|
| 35 | |
|---|
| 36 | exps=`echo ${experiments} | tr ':' ' '` |
|---|
| 37 | sndsts=`echo ${sndstations} | tr ':' ' '` |
|---|
| 38 | sfcsts=`echo ${sfcstations} | tr ':' ' '` |
|---|
| 39 | |
|---|
| 40 | for expn in ${exps}; do |
|---|
| 41 | ifold=${infolder}/${expn}/wrfout |
|---|
| 42 | ofold=${ofolder}/${expn} |
|---|
| 43 | |
|---|
| 44 | files=`ls -1 ${infolder}/${expn}/wrfout/wrfout_d02*` |
|---|
| 45 | |
|---|
| 46 | mkdir -p ${ofold} |
|---|
| 47 | |
|---|
| 48 | if test ! ${sndstations} = 'None'; then |
|---|
| 49 | for sndvn in ${sndsts}; do |
|---|
| 50 | sndid=`echo ${sndvn} | tr ',' ' ' | awk '{print $1}'` |
|---|
| 51 | sndlon=`echo ${sndvn} | tr ',' ' ' | awk '{print $2}'` |
|---|
| 52 | sndlat=`echo ${sndvn} | tr ',' ' ' | awk '{print $3}'` |
|---|
| 53 | |
|---|
| 54 | for filen in ${files}; do |
|---|
| 55 | $pyHOME/get_WRFsounding-surface_data.bash ${scratch} ${ofold} ${expn} ${sndvn} \ |
|---|
| 56 | None ${filen} ${snddiags} ${sfcdiags} ${sfcnondiags} |
|---|
| 57 | # end of files |
|---|
| 58 | done |
|---|
| 59 | |
|---|
| 60 | # Concatenating files |
|---|
| 61 | ofile=${ofold}/simout_sndvars_${sndid}_${expn}.nc |
|---|
| 62 | if test ${scratch} = 'true'; then rm ${ofile} >& /dev/null; fi |
|---|
| 63 | if test ! -f ${ofile}; then |
|---|
| 64 | values=${ofold}',Time,time' |
|---|
| 65 | HMT='simout_snddiags_,'${sndid},'nc' |
|---|
| 66 | python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values} \ |
|---|
| 67 | -f ${HMT} -v all |
|---|
| 68 | if test $? -ne 0; then |
|---|
| 69 | echo ${errmsg} |
|---|
| 70 | echo " python failed!!" |
|---|
| 71 | echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values} \ |
|---|
| 72 | -f ${HMT} -v all |
|---|
| 73 | exit |
|---|
| 74 | fi |
|---|
| 75 | echo " * Concatenating sounding data at point: "${sndlon}", "${sndlat} >> ${insoutf} |
|---|
| 76 | echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S "'"${values}"'" \ |
|---|
| 77 | -f ${HMT} -v all >> ${insoutf} |
|---|
| 78 | echo " " >> ${insoutf} |
|---|
| 79 | mv netcdf_fold_concatenated_HMT.nc ${ofile} |
|---|
| 80 | fi |
|---|
| 81 | #exit |
|---|
| 82 | |
|---|
| 83 | # end of soundings |
|---|
| 84 | done |
|---|
| 85 | fi |
|---|
| 86 | |
|---|
| 87 | if test ! ${sfcstations} = 'None'; then |
|---|
| 88 | for sfcvn in ${sfcsts}; do |
|---|
| 89 | sfcid=`echo ${sfcvn} | tr ',' ' ' | awk '{print $1}'` |
|---|
| 90 | sfclon=`echo ${sfcvn} | tr ',' ' ' | awk '{print $2}'` |
|---|
| 91 | sfclat=`echo ${sfcvn} | tr ',' ' ' | awk '{print $3}'` |
|---|
| 92 | |
|---|
| 93 | for filen in ${files}; do |
|---|
| 94 | $pyHOME/get_WRFsounding-surface_data.bash ${scratch} ${ofold} ${expn} None \ |
|---|
| 95 | ${sfcvn} ${filen} ${snddiags} ${sfcdiags} ${sfcnondiags} |
|---|
| 96 | # end of files |
|---|
| 97 | done |
|---|
| 98 | |
|---|
| 99 | # Concatenating files |
|---|
| 100 | ofile=${ofold}/simout_sfcvars_${sfcid}_${expn}.nc |
|---|
| 101 | if test ${scratch} = 'true'; then rm ${ofile} >& /dev/null; fi |
|---|
| 102 | if test ! -f ${ofile}; then |
|---|
| 103 | values=${ofold}',Time,time' |
|---|
| 104 | HMT='simout_sfcdiags_,'${sfcid},'nc' |
|---|
| 105 | python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values} \ |
|---|
| 106 | -f ${HMT} -v all |
|---|
| 107 | if test $? -ne 0; then |
|---|
| 108 | echo ${errmsg} |
|---|
| 109 | echo " python failed!!" |
|---|
| 110 | echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S ${values} \ |
|---|
| 111 | -f ${HMT} -v all |
|---|
| 112 | exit |
|---|
| 113 | fi |
|---|
| 114 | echo " * Concatenating surface data at point: "${sfclon}", "${sfclat} >> ${insoutf} |
|---|
| 115 | echo python ${pyHOME}/nc_var.py -o netcdf_fold_concatenation_HMT -S "'"${values}"'" \ |
|---|
| 116 | -f ${HMT} -v all >> ${insoutf} |
|---|
| 117 | echo " " >> ${insoutf} |
|---|
| 118 | mv netcdf_fold_concatenated_HMT.nc ${ofile} |
|---|
| 119 | fi |
|---|
| 120 | #exit |
|---|
| 121 | |
|---|
| 122 | # end of surfaces |
|---|
| 123 | done |
|---|
| 124 | fi |
|---|
| 125 | |
|---|
| 126 | # End of experiments |
|---|
| 127 | done |
|---|