[2000] | 1 | #!/bin/bash |
---|
| 2 | #### Script to get data from a given specific sounding and surface stations from WRF |
---|
| 3 | ## |
---|
[2130] | 4 | ## e.g. # get_WRFsounding-surface_data.bash true ./ control 87576,-58.52,-34.81 87576,-58.52,-34.81 /home/lluis/PY/wrfout_d01_1995-01-01_00:00:00 WRFt:WRFtda:WRFp:WRFua:WRFva:ws:WRFwd,wds:wss:WRFtdas,T2,None,None ccc_mpirun!python |
---|
[2000] | 5 | if test $1 = '-h'; then |
---|
| 6 | echo "************************************" |
---|
| 7 | echo "*** Script to get snd & sfc data ***" |
---|
| 8 | echo "*** from WRF output ***" |
---|
| 9 | echo "************************************" |
---|
| 10 | echo "get_WRFsounding-surface_data.bash [scratch] [odir] [expl] \ |
---|
[2036] | 11 | [sndid],[sndlon],[sndlat] [sfcid],[sfclon],[sfclat] [infilen] \ |
---|
[2130] | 12 | [wrfsnddiags],[wrfsfcdiags],[wrfsfcnodiags],[wrfcdxdiags],[wrfcdxnodiags] \ |
---|
| 13 | [pyBIN]('!' for spaces)" |
---|
[2000] | 14 | else |
---|
[2057] | 15 | errmsg='ERROR -- error -- ERROR -- error' |
---|
[2000] | 16 | |
---|
| 17 | if test $1 = 'true'; then fscratch=true |
---|
| 18 | else fscratch=false; fi |
---|
| 19 | |
---|
| 20 | odir=$2 |
---|
| 21 | expl=$3 |
---|
[2002] | 22 | if test ! $4 = 'None'; then |
---|
[2001] | 23 | sndid=`echo $4 | tr ',' ' ' | awk '{print $1}'` |
---|
| 24 | sndlon=`echo $4 | tr ',' ' ' | awk '{print $2}'` |
---|
| 25 | sndlat=`echo $4 | tr ',' ' ' | awk '{print $3}'` |
---|
| 26 | else |
---|
| 27 | sndid='None' |
---|
| 28 | fi |
---|
[2000] | 29 | |
---|
[2002] | 30 | if test ! $5 = 'None'; then |
---|
[2001] | 31 | sfcid=`echo $5 | tr ',' ' ' | awk '{print $1}'` |
---|
| 32 | sfclon=`echo $5 | tr ',' ' ' | awk '{print $2}'` |
---|
| 33 | sfclat=`echo $5 | tr ',' ' ' | awk '{print $3}'` |
---|
| 34 | else |
---|
| 35 | sfcid='None' |
---|
| 36 | fi |
---|
[2000] | 37 | |
---|
| 38 | infilen=$6 |
---|
| 39 | |
---|
[2036] | 40 | if test ! $7 = 'None'; then |
---|
| 41 | wrfsnddiags=`echo $7 | tr ',' ' ' | awk '{print $1}'` |
---|
| 42 | wrfsfcdiags=`echo $7 | tr ',' ' ' | awk '{print $2}'` |
---|
| 43 | wrfsfcnodiags=`echo $7 | tr ',' ' ' | awk '{print $3}'` |
---|
| 44 | wrfcdxdiags=`echo $7 | tr ',' ' ' | awk '{print $4}'` |
---|
| 45 | wrfcdxnodiags=`echo $7 | tr ',' ' ' | awk '{print $5}'` |
---|
| 46 | fi |
---|
| 47 | |
---|
[2130] | 48 | pyBIN=`echo $8 | tr '!' ' '` |
---|
| 49 | |
---|
[2000] | 50 | function isin_list() { |
---|
| 51 | # Function to check whether a value is in a list |
---|
| 52 | list=$1 |
---|
| 53 | value=$2 |
---|
| 54 | |
---|
| 55 | is=`echo ${list} | tr ':' '\n' | awk '{print "@"$1"@"}' | grep '@'${value}'@' | wc -w` |
---|
| 56 | if test ${is} -eq 1 |
---|
| 57 | then |
---|
| 58 | true |
---|
| 59 | else |
---|
| 60 | false |
---|
| 61 | fi |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | function get_WRFsounding_data(){ |
---|
| 65 | # Function to get the data to compute analysis in a sounding point |
---|
| 66 | # stlon= longitude value of the station |
---|
| 67 | # stlat= latitude value of the station |
---|
| 68 | # filen= name of the file |
---|
| 69 | # lonvarn= name of the longitude variable |
---|
| 70 | # latvarn= name of the latitude variable |
---|
| 71 | # snddiagnames= diagnostics to compute (as ':' separated list) |
---|
| 72 | |
---|
| 73 | funcvals=$1 |
---|
| 74 | |
---|
| 75 | stlon=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'` |
---|
| 76 | stlat=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'` |
---|
| 77 | filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'` |
---|
| 78 | lonvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'` |
---|
| 79 | latvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $5}'` |
---|
| 80 | snddiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $6}'` |
---|
| 81 | |
---|
| 82 | vals=${lonvarn}':'${latvarn}':Time|0' |
---|
[2130] | 83 | gridsndv=`${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \ |
---|
[2000] | 84 | -v ${stlon},${stlat} | tr ' ' '!'` |
---|
| 85 | echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 86 | echo ${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \ |
---|
[2000] | 87 | -v ${stlon},${stlat} >> ${ofileins} |
---|
| 88 | echo " " >> ${ofileins} |
---|
| 89 | |
---|
| 90 | xsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ |
---|
| 91 | awk '{print $1}'` |
---|
| 92 | ysnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ |
---|
| 93 | awk '{print $2}'` |
---|
| 94 | dsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $2}'` |
---|
| 95 | |
---|
| 96 | xsnd1=`expr ${xsnd} + 1` |
---|
| 97 | ysnd1=`expr ${ysnd} + 1` |
---|
| 98 | |
---|
| 99 | # Getting values |
---|
| 100 | if ${fscratch}; then rm ${simsndptf} >& /dev/null; fi |
---|
| 101 | if test ! -f ${simsndptf}; then |
---|
| 102 | values='Time,0,-1,1@bottom_top,0,-1,1@south_north,'${ysnd}','${ysnd}',1@' |
---|
| 103 | values=${values}'west_east,'${xsnd}','${xsnd}',1@south_north_stag,'${ysnd}',' |
---|
[2021] | 104 | values=${values}${ysnd1}',1@west_east_stag,'${xsnd}','${xsnd1}',1:False' |
---|
[2130] | 105 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2000] | 106 | -S ${values} -v all |
---|
| 107 | if test $? -ne 0; then |
---|
| 108 | echo ${errmsg} |
---|
| 109 | echo " python failed!!" |
---|
[2130] | 110 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2000] | 111 | -S "'"${values}"'" -v all |
---|
| 112 | exit |
---|
| 113 | fi |
---|
| 114 | echo "* get values at snd point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 115 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2000] | 116 | -S "'"${values}"'" -v all >> ${ofileins} |
---|
| 117 | echo " " >> ${ofileins} |
---|
| 118 | |
---|
[2021] | 119 | ofilen='newfile_multidims.nc' |
---|
[2000] | 120 | mv ${ofilen} ${simsndptf} |
---|
| 121 | fi |
---|
| 122 | |
---|
| 123 | # Computing sounding diagnostics |
---|
| 124 | snddiagd='Time@WRFtime,bottom_top@P' |
---|
| 125 | diagns=`echo ${snddiagnames} | tr ':' ' '` |
---|
| 126 | |
---|
| 127 | idiag=1 |
---|
| 128 | for diagn in ${diagns}; do |
---|
| 129 | diagv=`cat $pyHOME/diagnostics.inf | grep ${diagn}',' | tr ',' ' ' | \ |
---|
| 130 | awk '{print $2"|"$3}'` |
---|
| 131 | if test ${idiag} -eq 1; then |
---|
| 132 | snddiagvals=${diagv} |
---|
| 133 | else |
---|
| 134 | snddiagvals=${snddiagvals}','${diagv} |
---|
| 135 | fi |
---|
| 136 | idiag=`expr ${idiag} + 1` |
---|
| 137 | done |
---|
| 138 | |
---|
| 139 | if ${fscratch}; then rm ${simsnddiagsf}; fi |
---|
| 140 | if test ! -f ${simsnddiagsf}; then |
---|
[2130] | 141 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsndptf} -d ${snddiagd} -v ${snddiagvals} |
---|
[2000] | 142 | if test $? -ne 0; then |
---|
| 143 | echo ${errmsg} |
---|
| 144 | echo " python failed!!" |
---|
[2130] | 145 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsndptf} -d "'"${snddiagd}"'" -v \ |
---|
[2000] | 146 | "'"${snddiagvals}"'" |
---|
| 147 | exit |
---|
| 148 | fi |
---|
| 149 | echo "* computing diagnostics at snd point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 150 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f "'"${simsndptf}"'" -d "'"${snddiagd}"'" \ |
---|
[2000] | 151 | -v "'"${snddiagvals}"'" >> ${ofileins} |
---|
| 152 | echo " " >> ${ofileins} |
---|
| 153 | |
---|
| 154 | mv diagnostics.nc ${simsnddiagsf} |
---|
| 155 | if $(isin_list ${snddiagnames} WRFt); then |
---|
| 156 | #To deg |
---|
[2130] | 157 | ${pyBIN} ${pyHOME}/nc_var.py -o valmod -S subc,273.15 -f ${simsnddiagsf} -v ta |
---|
[2000] | 158 | fi |
---|
| 159 | if $(isin_list ${snddiagnames} WRFp); then |
---|
| 160 | #To Pa |
---|
[2130] | 161 | ${pyBIN} ${pyHOME}/nc_var.py -o valmod -S divc,100. -f ${simsnddiagsf} -v pres |
---|
[2000] | 162 | fi |
---|
| 163 | fi |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | function get_WRFsurface_data(){ |
---|
| 167 | # Function to get the data to compute analysis in a surface point |
---|
| 168 | # stlon= longitude value of the station |
---|
| 169 | # stlat= latitude value of the station |
---|
| 170 | # filen= name of the file |
---|
| 171 | # lonvarn= name of the longitude variable |
---|
| 172 | # latvarn= name of the latitude variable |
---|
| 173 | # sfcdiagnames= diagnostics to compute (as ':' separated list) |
---|
| 174 | # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for |
---|
| 175 | # without) |
---|
| 176 | |
---|
| 177 | funcvals=$1 |
---|
| 178 | |
---|
| 179 | stlon=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'` |
---|
| 180 | stlat=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'` |
---|
| 181 | filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'` |
---|
| 182 | lonvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'` |
---|
| 183 | latvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $5}'` |
---|
| 184 | sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $6}'` |
---|
| 185 | nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $7}'` |
---|
| 186 | |
---|
| 187 | vals=${lonvarn}':'${latvarn}':Time|0' |
---|
[2130] | 188 | gridsndv=`${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \ |
---|
[2000] | 189 | -v ${stlon},${stlat} | tr ' ' '!'` |
---|
| 190 | echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 191 | echo ${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \ |
---|
[2000] | 192 | -v ${stlon},${stlat} >> ${ofileins} |
---|
| 193 | echo " " >> ${ofileins} |
---|
| 194 | xsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ |
---|
| 195 | awk '{print $1}'` |
---|
| 196 | ysnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ |
---|
| 197 | awk '{print $2}'` |
---|
| 198 | dsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $2}'` |
---|
| 199 | |
---|
| 200 | xsnd1=`expr ${xsnd} + 1` |
---|
| 201 | ysnd1=`expr ${ysnd} + 1` |
---|
| 202 | |
---|
| 203 | # Getting values |
---|
| 204 | if ${fscratch}; then rm ${simsfcptf} >& /dev/null; fi |
---|
| 205 | if test ! -f ${simsfcptf}; then |
---|
| 206 | values='Time,0,-1,1@south_north,'${ysnd}','${ysnd}',1@' |
---|
| 207 | values=${values}'west_east,'${xsnd}','${xsnd}',1@south_north_stag,'${ysnd}',' |
---|
[2021] | 208 | values=${values}${ysnd1}',1@west_east_stag,'${xsnd}','${xsnd1}',1:false' |
---|
[2130] | 209 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2000] | 210 | -S ${values} -v all |
---|
| 211 | if test $? -ne 0; then |
---|
| 212 | echo ${errmsg} |
---|
| 213 | echo " python failed!!" |
---|
[2130] | 214 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2000] | 215 | -S "'"${values}"'" -v all |
---|
| 216 | exit |
---|
| 217 | fi |
---|
| 218 | echo "* get values at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 219 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2000] | 220 | -S "'"${values}"'" -v all >> ${ofileins} |
---|
| 221 | echo " " >> ${ofileins} |
---|
| 222 | |
---|
[2021] | 223 | ofilen='newfile_multidims.nc' |
---|
[2000] | 224 | mv ${ofilen} ${simsfcptf} |
---|
| 225 | fi |
---|
| 226 | |
---|
| 227 | # Computing sfc diagnostics |
---|
| 228 | sfcdiagd='Time@WRFtime' |
---|
| 229 | diagns=`echo ${sfcdiagnames} | tr ':' ' '` |
---|
| 230 | |
---|
| 231 | idiag=1 |
---|
| 232 | for diagn in ${diagns}; do |
---|
| 233 | diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' | \ |
---|
| 234 | awk '{print $2"|"$3}'` |
---|
| 235 | if test ${idiag} -eq 1; then |
---|
| 236 | sfcdiagvals=${diagv} |
---|
| 237 | else |
---|
| 238 | sfcdiagvals=${sfcdiagvals}','${diagv} |
---|
| 239 | fi |
---|
| 240 | idiag=`expr ${idiag} + 1` |
---|
| 241 | done |
---|
| 242 | |
---|
| 243 | if ${fscratch}; then rm ${simsfcdiagsf}; fi |
---|
| 244 | if test ! -f ${simsfcdiagsf}; then |
---|
[2130] | 245 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d ${sfcdiagd} -v ${sfcdiagvals} |
---|
[2000] | 246 | if test $? -ne 0; then |
---|
| 247 | echo ${errmsg} |
---|
| 248 | echo " python failed!!" |
---|
[2130] | 249 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ |
---|
[2000] | 250 | -v "'"${sfcdiagvals}"'" |
---|
| 251 | exit |
---|
| 252 | fi |
---|
| 253 | echo "* diagnostics at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 254 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ |
---|
[2000] | 255 | -v "'"${sfcdiagvals}"'" >> ${ofileins} |
---|
| 256 | echo " " >> ${ofileins} |
---|
| 257 | mv diagnostics.nc ${simsfcdiagsf} |
---|
| 258 | if $(isin_list ${sfcdiagnames} wds); then |
---|
| 259 | #To rad |
---|
[2130] | 260 | ${pyBIN} ${pyHOME}/nc_var.py -o valmod -S mulc,0.0174532925199 -f \ |
---|
| 261 | ${simsfcdiagsf} -v wds |
---|
| 262 | ${pyBIN} ${pyHOME}/nc_var.py -o varaddattr -S 'units|rad' -f ${simsfcdiagsf} \ |
---|
[2000] | 263 | -v wds |
---|
| 264 | fi |
---|
| 265 | fi |
---|
| 266 | |
---|
| 267 | #Adding non-diagnostic variables |
---|
| 268 | if test ! ${nondiagvs} = 'None'; then |
---|
| 269 | varsadd=`echo ${nondiagvs} | tr ':' ' '` |
---|
| 270 | for vadd in ${varsadd}; do |
---|
[2130] | 271 | ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd} -f ${simsfcdiagsf} |
---|
[2000] | 272 | if test $? -ne 0; then |
---|
| 273 | echo ${errmsg} |
---|
| 274 | echo " python failed!!" |
---|
[2130] | 275 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ |
---|
[2000] | 276 | -f ${simsfcdiagsf} |
---|
| 277 | exit |
---|
| 278 | rm ${simsfcdiagsf} |
---|
| 279 | fi |
---|
| 280 | echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 281 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ |
---|
[2000] | 282 | -f ${simsfcdiagsf} >> ${ofileins} |
---|
| 283 | echo " " >> ${ofileins} |
---|
| 284 | # CF varname |
---|
[2130] | 285 | CFvarn=`${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} | \ |
---|
[2089] | 286 | grep -v variables_values | tr ':' ' ' | awk '{print $1}'` |
---|
[2000] | 287 | if test $? -ne 0; then |
---|
| 288 | echo ${errmsg} |
---|
| 289 | echo " python failed!!" |
---|
[2130] | 290 | echo ${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} |
---|
[2000] | 291 | exit |
---|
| 292 | rm ${simsfcdiagsf} |
---|
| 293 | fi |
---|
[2130] | 294 | ${pyBIN} $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} -v ${vadd} |
---|
[2000] | 295 | if test $? -ne 0; then |
---|
| 296 | echo ${errmsg} |
---|
| 297 | echo " python failed!!" |
---|
[2130] | 298 | echo ${pyBIN} ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ |
---|
| 299 | -f ${simsfcdiagsf} -v ${vadd} |
---|
[2000] | 300 | exit |
---|
| 301 | rm ${simsfcdiagsf} |
---|
| 302 | fi |
---|
| 303 | done |
---|
| 304 | fi |
---|
| 305 | } |
---|
[2023] | 306 | |
---|
| 307 | function get_WRFsfc2D_data(){ |
---|
| 308 | # Function to get the data to compute analysis in a surface map |
---|
| 309 | # filen= name of the file |
---|
| 310 | # sfcdiagnames= diagnostics to compute (as ':' separated list) |
---|
| 311 | # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for |
---|
| 312 | # without) |
---|
| 313 | |
---|
| 314 | funcvals=$1 |
---|
| 315 | |
---|
| 316 | filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'` |
---|
| 317 | sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'` |
---|
| 318 | nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'` |
---|
| 319 | |
---|
| 320 | # Computing sfc diagnostics |
---|
[2049] | 321 | if test ! ${sfcdiagnames} = 'None'; then |
---|
| 322 | sfcmapdiagd='Time@WRFtime:south_north@XLAT:west_east@XLONG' |
---|
| 323 | diagns=`echo ${sfcdiagnames} | tr ':' ' '` |
---|
[2023] | 324 | |
---|
[2049] | 325 | # getting that variables only required for the diagnostics |
---|
| 326 | vardiags='' |
---|
| 327 | idiag=1 |
---|
| 328 | for diagn in ${diagns}; do |
---|
[2130] | 329 | diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |\ |
---|
[2049] | 330 | awk '{print $2"|"$3}'` |
---|
| 331 | if test ${idiag} -eq 1; then |
---|
| 332 | sfcdiagvals=${diagv} |
---|
| 333 | vardiags=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ':'` |
---|
| 334 | else |
---|
| 335 | sfcdiagvals=${sfcdiagvals}','${diagv} |
---|
| 336 | vardiag=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ' '` |
---|
| 337 | for vd in ${vardiag}; do |
---|
| 338 | if ! $(isin_list ${vardiags} ${vd}); then vardiags=${vardiags}':'${vd}; fi |
---|
| 339 | done |
---|
| 340 | fi |
---|
| 341 | idiag=`expr ${idiag} + 1` |
---|
| 342 | done |
---|
| 343 | |
---|
| 344 | # Inlcuding non-diagnostics |
---|
| 345 | if test ! ${nondiagvs} = 'None'; then |
---|
| 346 | nvns=`echo ${nondiagvs} | tr ':' ' '` |
---|
| 347 | for vn in ${nvns}; do |
---|
| 348 | if ! $(isin_list ${vardiags} ${vn}); then vardiags=${vardiags}':'${vn}; fi |
---|
[2023] | 349 | done |
---|
| 350 | fi |
---|
[2049] | 351 | else |
---|
[2055] | 352 | vardiags='Times:XLONG:XLAT:'${nondiagvs} |
---|
[2049] | 353 | fi |
---|
[2023] | 354 | |
---|
| 355 | vardiag=`echo ${vardiags} | tr ':' ','` |
---|
| 356 | |
---|
| 357 | # Getting values |
---|
| 358 | if ${fscratch}; then rm ${simsfcmapf} >& /dev/null; fi |
---|
| 359 | if test ! -f ${simsfcmapf}; then |
---|
| 360 | values='Time,0,-1,1@south_north,0,-1,1@west_east,0,-1,1@south_north_stag,0,-1,1@' |
---|
| 361 | values=${values}'west_east_stag,0,-1,1:False' |
---|
[2130] | 362 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2023] | 363 | -S ${values} -v ${vardiag} |
---|
| 364 | if test $? -ne 0; then |
---|
| 365 | echo ${errmsg} |
---|
| 366 | echo " python failed!!" |
---|
[2130] | 367 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2023] | 368 | -S "'"${values}"'" -v ${vardiag} |
---|
| 369 | exit |
---|
| 370 | fi |
---|
| 371 | echo "* get values for 2D map diagnostics: " >> ${ofileins} |
---|
[2130] | 372 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2023] | 373 | -S "'"${values}"'" -v ${vardiag} >> ${ofileins} |
---|
| 374 | echo " " >> ${ofileins} |
---|
| 375 | |
---|
| 376 | ofilen='newfile_multidims.nc' |
---|
| 377 | mv ${ofilen} ${simsfcmapf} |
---|
| 378 | fi |
---|
| 379 | |
---|
| 380 | if ${fscratch}; then rm ${simsfcmapdiagsf}; fi |
---|
[2087] | 381 | if test ! -f ${simsfcmapdiagsf}; then |
---|
[2049] | 382 | if test ! ${sfcdiagnames} = 'None'; then |
---|
[2130] | 383 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d ${sfcmapdiagd} \ |
---|
[2049] | 384 | -v ${sfcdiagvals} |
---|
| 385 | if test $? -ne 0; then |
---|
| 386 | echo ${errmsg} |
---|
| 387 | echo " python failed!!" |
---|
[2130] | 388 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'" \ |
---|
[2049] | 389 | -v "'"${sfcdiagvals}"'" |
---|
| 390 | exit |
---|
| 391 | fi |
---|
| 392 | echo "* diagnostics for sfc 2D map: " >> ${ofileins} |
---|
[2130] | 393 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'" \ |
---|
[2049] | 394 | -v "'"${sfcdiagvals}"'" >> ${ofileins} |
---|
| 395 | echo " " >> ${ofileins} |
---|
| 396 | mv diagnostics.nc ${simsfcmapdiagsf} |
---|
| 397 | if $(isin_list ${sfcdiagnames} wds); then |
---|
| 398 | #To rad |
---|
[2130] | 399 | ${pyBIN} ${pyHOME}/nc_var.py -o valmod -S mulc,0.0174532925199 \ |
---|
[2049] | 400 | -f ${simsfcmapdiagsf} -v wds |
---|
[2130] | 401 | ${pyBIN} ${pyHOME}/nc_var.py -o varaddattr -S 'units|rad' \ |
---|
| 402 | -f ${simsfcmapdiagsf} -v wds |
---|
[2049] | 403 | fi |
---|
[2023] | 404 | fi |
---|
[2049] | 405 | # If there was not diagnostics |
---|
| 406 | if test ! -f ${simsfcmapdiagsf}; then |
---|
[2054] | 407 | dddv='Time@Times' |
---|
| 408 | selvars='XLONG,XLAT,Times' |
---|
[2130] | 409 | ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcmapf} -v ${selvars} |
---|
[2049] | 410 | if test $? -ne 0; then |
---|
| 411 | echo ${errmsg} |
---|
| 412 | echo " python failed!!" |
---|
[2130] | 413 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${ddv}"'" -f ${simsfmapf} \ |
---|
[2049] | 414 | -v ${vars} |
---|
| 415 | exit |
---|
| 416 | rm ${simsfcmapf} |
---|
| 417 | fi |
---|
| 418 | echo "* creation of diagnostics file for 2D map:" >> ${ofileins} |
---|
[2130] | 419 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcmapf} \ |
---|
[2049] | 420 | -v ${selvars} >> ${ofileins} |
---|
| 421 | echo " " >> ${ofileins} |
---|
| 422 | mv selvar_new.nc ${simsfcmapdiagsf} |
---|
[2130] | 423 | ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ |
---|
[2066] | 424 | -f ${simsfcmapdiagsf} -v time |
---|
[2050] | 425 | if test $? -ne 0; then |
---|
| 426 | echo ${errmsg} |
---|
| 427 | echo " python failed!!" |
---|
[2130] | 428 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
| 429 | -S 19491201000000,minutes -f ${simsfcmapdiagsf} -v time |
---|
[2050] | 430 | exit |
---|
[2066] | 431 | rm ${simsfcmapdiagsf} |
---|
[2050] | 432 | fi |
---|
| 433 | echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \ |
---|
| 434 | ${stlat} >> ${ofileins} |
---|
[2130] | 435 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
| 436 | -S 19491201000000,minutes -f ${simsfcmapdiagsf} -v time >> ${ofileins} |
---|
[2050] | 437 | echo " " >> ${ofileins} |
---|
[2049] | 438 | fi |
---|
[2023] | 439 | #Adding non-diagnostic variables |
---|
| 440 | if test ! ${nondiagvs} = 'None'; then |
---|
| 441 | varsadd=`echo ${nondiagvs} | tr ':' ' '` |
---|
| 442 | for vadd in ${varsadd}; do |
---|
[2130] | 443 | ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcmapf},${vadd} \ |
---|
[2023] | 444 | -f ${simsfcmapdiagsf} |
---|
| 445 | if test $? -ne 0; then |
---|
| 446 | echo ${errmsg} |
---|
| 447 | echo " python failed!!" |
---|
[2130] | 448 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ |
---|
[2023] | 449 | -f ${simsfcmapdiagsf} |
---|
| 450 | exit |
---|
| 451 | rm ${simsfcmapdiagsf} |
---|
| 452 | fi |
---|
| 453 | echo "* adding variable '"${vadd}"' at sfc map: " >> ${ofileins} |
---|
[2130] | 454 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ |
---|
[2023] | 455 | -f ${simsfcmapdiagsf} >> ${ofileins} |
---|
| 456 | echo " " >> ${ofileins} |
---|
[2087] | 457 | # CF varname |
---|
[2130] | 458 | CFvarn=`${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} | \ |
---|
[2089] | 459 | grep -v variables_values | tr ':' ' ' | awk '{print $1}'` |
---|
[2023] | 460 | if test $? -ne 0; then |
---|
| 461 | echo ${errmsg} |
---|
| 462 | echo " python failed!!" |
---|
[2130] | 463 | echo ${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} |
---|
[2023] | 464 | exit |
---|
| 465 | rm ${simsfcmapdiagsf} |
---|
| 466 | fi |
---|
[2130] | 467 | ${pyBIN} $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcmapdiagsf} \ |
---|
[2023] | 468 | -v ${vadd} |
---|
| 469 | if test $? -ne 0; then |
---|
| 470 | echo ${errmsg} |
---|
| 471 | echo " python failed!!" |
---|
[2130] | 472 | echo ${pyBIN} ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ |
---|
[2023] | 473 | -f ${simsfcmapdiagsf} -v ${vadd} |
---|
| 474 | exit |
---|
| 475 | rm ${simsfcmapdiagsf} |
---|
| 476 | fi |
---|
| 477 | done |
---|
| 478 | fi |
---|
| 479 | fi |
---|
| 480 | } |
---|
| 481 | |
---|
[2036] | 482 | function get_WRFCDXsurface_data(){ |
---|
| 483 | # Function to get the WRFCDX data to compute analysis in a surface point |
---|
| 484 | # stlon= longitude value of the station |
---|
| 485 | # stlat= latitude value of the station |
---|
| 486 | # filen= name of the file |
---|
| 487 | # lonvarn= name of the longitude variable |
---|
| 488 | # latvarn= name of the latitude variable |
---|
| 489 | # sfcdiagnames= diagnostics to compute (as ':' separated list) |
---|
| 490 | # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for |
---|
| 491 | # without) |
---|
| 492 | |
---|
| 493 | funcvals=$1 |
---|
| 494 | |
---|
| 495 | stlon=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'` |
---|
| 496 | stlat=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'` |
---|
| 497 | filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'` |
---|
| 498 | lonvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'` |
---|
| 499 | latvarn=`echo ${funcvals} | tr '#' ' ' | awk '{print $5}'` |
---|
| 500 | sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $6}'` |
---|
| 501 | nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $7}'` |
---|
| 502 | |
---|
| 503 | vals=${lonvarn}':'${latvarn}':Time|0' |
---|
[2130] | 504 | gridsndv=`${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \ |
---|
[2036] | 505 | -v ${stlon},${stlat} | tr ' ' '!'` |
---|
| 506 | echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 507 | echo ${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \ |
---|
[2036] | 508 | -v ${stlon},${stlat} >> ${ofileins} |
---|
| 509 | echo " " >> ${ofileins} |
---|
| 510 | xsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ |
---|
| 511 | awk '{print $1}'` |
---|
| 512 | ysnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $1}' | tr ',' ' ' | \ |
---|
| 513 | awk '{print $2}'` |
---|
| 514 | dsnd=`echo ${gridsndv} | tr '!' ' ' | awk '{print $2}'` |
---|
| 515 | |
---|
| 516 | xsnd1=`expr ${xsnd} + 1` |
---|
| 517 | ysnd1=`expr ${ysnd} + 1` |
---|
| 518 | |
---|
| 519 | # Getting values |
---|
| 520 | if ${fscratch}; then rm ${simsfcptf} >& /dev/null; fi |
---|
| 521 | if test ! -f ${simsfcptf}; then |
---|
| 522 | values='Time,0,-1,1@south_north,'${ysnd}','${ysnd}',1@' |
---|
| 523 | values=${values}'west_east,'${xsnd}','${xsnd}',1:False' |
---|
[2130] | 524 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2036] | 525 | -S ${values} -v all |
---|
| 526 | if test $? -ne 0; then |
---|
| 527 | echo ${errmsg} |
---|
| 528 | echo " python failed!!" |
---|
[2130] | 529 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2036] | 530 | -S "'"${values}"'" -v all |
---|
| 531 | exit |
---|
| 532 | fi |
---|
[2087] | 533 | echo "* get values at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 534 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2036] | 535 | -S "'"${values}"'" -v all >> ${ofileins} |
---|
[2087] | 536 | echo " " >> ${ofileins} |
---|
[2036] | 537 | |
---|
| 538 | ofilen='newfile_multidims.nc' |
---|
| 539 | mv ${ofilen} ${simsfcptf} |
---|
| 540 | fi |
---|
| 541 | |
---|
| 542 | # Computing sfc diagnostics |
---|
[2087] | 543 | if ${fscratch}; then rm ${simsfcdiagsf}; fi |
---|
| 544 | if test ! -f ${simsfcdiagsf}; then |
---|
| 545 | if test ! ${sfcdiagnames} = 'None'; then |
---|
| 546 | sfcdiagd='Time@WRFtime' |
---|
| 547 | diagns=`echo ${sfcdiagnames} | tr ':' ' '` |
---|
[2036] | 548 | |
---|
[2087] | 549 | idiag=1 |
---|
| 550 | for diagn in ${diagns}; do |
---|
| 551 | diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |\ |
---|
| 552 | awk '{print $2"|"$3}'` |
---|
| 553 | if test ${idiag} -eq 1; then |
---|
| 554 | sfcdiagvals=${diagv} |
---|
| 555 | else |
---|
| 556 | sfcdiagvals=${sfcdiagvals}','${diagv} |
---|
| 557 | fi |
---|
| 558 | idiag=`expr ${idiag} + 1` |
---|
| 559 | done |
---|
[2036] | 560 | |
---|
[2130] | 561 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d ${sfcdiagd} -v ${sfcdiagvals} |
---|
[2046] | 562 | if test $? -ne 0; then |
---|
| 563 | echo ${errmsg} |
---|
| 564 | echo " python failed!!" |
---|
[2130] | 565 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ |
---|
[2046] | 566 | -v "'"${sfcdiagvals}"'" |
---|
| 567 | exit |
---|
| 568 | fi |
---|
| 569 | echo "* diagnostics at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
[2130] | 570 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ |
---|
[2046] | 571 | -v "'"${sfcdiagvals}"'" >> ${ofileins} |
---|
| 572 | echo " " >> ${ofileins} |
---|
| 573 | mv diagnostics.nc ${simsfcdiagsf} |
---|
[2036] | 574 | fi |
---|
| 575 | |
---|
[2087] | 576 | #Adding non-diagnostic variables |
---|
| 577 | if test ! ${nondiagvs} = 'None'; then |
---|
| 578 | # If there was not diagnostics |
---|
| 579 | if test ! -f ${simsfcdiagsf}; then |
---|
| 580 | dddv='Time@Times' |
---|
| 581 | selvars='Times' |
---|
[2130] | 582 | ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcptf} -v ${selvars} |
---|
[2087] | 583 | if test $? -ne 0; then |
---|
| 584 | echo ${errmsg} |
---|
| 585 | echo " python failed!!" |
---|
[2130] | 586 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcptf}\ |
---|
[2087] | 587 | -v ${vars} |
---|
| 588 | exit |
---|
| 589 | rm ${simsfcptf} |
---|
| 590 | fi |
---|
[2130] | 591 | echo "* creation of diagnostics file at sfc point: "${stlon}", "${stlat} >> \ |
---|
[2087] | 592 | ${ofileins} |
---|
[2130] | 593 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcptf} \ |
---|
[2087] | 594 | -v ${selvars} >> ${ofileins} |
---|
| 595 | echo " " >> ${ofileins} |
---|
| 596 | mv selvar_new.nc ${simsfcdiagsf} |
---|
[2130] | 597 | ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
| 598 | -S 19491201000000,minutes -f ${simsfcdiagsf} -v time |
---|
[2087] | 599 | if test $? -ne 0; then |
---|
| 600 | echo ${errmsg} |
---|
| 601 | echo " python failed!!" |
---|
[2130] | 602 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
| 603 | -S 19491201000000,minutes -f ${simsfcdiagsf} -v time |
---|
[2087] | 604 | exit |
---|
| 605 | rm ${simsfcdiagsf} |
---|
| 606 | fi |
---|
[2130] | 607 | echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \ |
---|
[2087] | 608 | ${stlat} >> ${ofileins} |
---|
[2130] | 609 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
| 610 | -S 19491201000000,minutes -f ${simsfcdiagsf} -v time >> ${ofileins} |
---|
[2087] | 611 | echo " " >> ${ofileins} |
---|
| 612 | fi |
---|
| 613 | varsadd=`echo ${nondiagvs} | tr ':' ' '` |
---|
| 614 | for vadd in ${varsadd}; do |
---|
[2130] | 615 | ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd} \ |
---|
| 616 | -f ${simsfcdiagsf} |
---|
[2087] | 617 | if test $? -ne 0; then |
---|
| 618 | echo ${errmsg} |
---|
| 619 | echo " python failed!!" |
---|
[2130] | 620 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ |
---|
[2087] | 621 | -f ${simsfcdiagsf} |
---|
| 622 | exit |
---|
| 623 | rm ${simsfcdiagsf} |
---|
| 624 | fi |
---|
[2130] | 625 | echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >> \ |
---|
| 626 | ${ofileins} |
---|
| 627 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ |
---|
[2087] | 628 | -f ${simsfcdiagsf} >> ${ofileins} |
---|
| 629 | echo " " >> ${ofileins} |
---|
| 630 | # CF varname |
---|
[2130] | 631 | CFvarn=`${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} | \ |
---|
[2089] | 632 | grep -v variables_values | tr ':' ' ' | awk '{print $1}'` |
---|
[2087] | 633 | if test $? -ne 0; then |
---|
| 634 | echo ${errmsg} |
---|
| 635 | echo " python failed!!" |
---|
[2130] | 636 | echo ${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} |
---|
[2087] | 637 | exit |
---|
| 638 | rm ${simsfcdiagsf} |
---|
| 639 | fi |
---|
[2130] | 640 | ${pyBIN} $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} \ |
---|
| 641 | -v ${vadd} |
---|
[2087] | 642 | if test $? -ne 0; then |
---|
| 643 | echo ${errmsg} |
---|
| 644 | echo " python failed!!" |
---|
[2130] | 645 | echo ${pyBIN} ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ |
---|
| 646 | -f ${simsfcdiagsf} -v ${vadd} |
---|
[2087] | 647 | exit |
---|
| 648 | rm ${simsfcdiagsf} |
---|
| 649 | fi |
---|
| 650 | done |
---|
| 651 | fi |
---|
[2036] | 652 | fi |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | function get_WRFCDXsfc2D_data(){ |
---|
| 656 | # Function to get the data from WRFCDX to compute analysis in a surface map |
---|
| 657 | # filen= name of the file |
---|
| 658 | # sfcdiagnames= diagnostics to compute (as ':' separated list) |
---|
| 659 | # nondiagvs= ':' list of variables which are not from a diagnostics ('None' for |
---|
| 660 | # without) |
---|
| 661 | # sfcmapdiagd= name of the dimensions and dimension variables to use for diagnostics |
---|
| 662 | |
---|
| 663 | funcvals=$1 |
---|
| 664 | |
---|
| 665 | filen=`echo ${funcvals} | tr '#' ' ' | awk '{print $1}'` |
---|
| 666 | sfcdiagnames=`echo ${funcvals} | tr '#' ' ' | awk '{print $2}'` |
---|
| 667 | nondiagvs=`echo ${funcvals} | tr '#' ' ' | awk '{print $3}'` |
---|
| 668 | sfcmapdiagd=`echo ${funcvals} | tr '#' ' ' | awk '{print $4}'` |
---|
| 669 | |
---|
| 670 | # Computing sfc diagnostics |
---|
[2046] | 671 | if test ! ${sfcdiagnames} = 'None'; then |
---|
| 672 | diagns=`echo ${sfcdiagnames} | tr ':' ' '` |
---|
[2036] | 673 | |
---|
[2046] | 674 | # getting that variables only required for the diagnostics |
---|
| 675 | vardiags='' |
---|
| 676 | idiag=1 |
---|
| 677 | for diagn in ${diagns}; do |
---|
[2130] | 678 | diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |\ |
---|
[2046] | 679 | awk '{print $2"|"$3}'` |
---|
| 680 | if test ${idiag} -eq 1; then |
---|
| 681 | sfcdiagvals=${diagv} |
---|
| 682 | vardiags=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ':'` |
---|
| 683 | else |
---|
| 684 | sfcdiagvals=${sfcdiagvals}','${diagv} |
---|
| 685 | vardiag=`echo ${diagv} | tr '|' ' ' | awk '{print $2}' | tr '@' ' '` |
---|
| 686 | for vd in ${vardiag}; do |
---|
| 687 | if ! $(isin_list ${vardiags} ${vd}); then vardiags=${vardiags}':'${vd}; fi |
---|
| 688 | done |
---|
| 689 | fi |
---|
| 690 | idiag=`expr ${idiag} + 1` |
---|
| 691 | done |
---|
| 692 | |
---|
| 693 | # Inlcuding non-diagnostics |
---|
| 694 | if test ! ${nondiagvs} = 'None'; then |
---|
| 695 | nvns=`echo ${nondiagvs} | tr ':' ' '` |
---|
| 696 | for vn in ${nvns}; do |
---|
| 697 | if ! $(isin_list ${vardiags} ${vn}); then vardiags=${vardiags}':'${vn}; fi |
---|
[2036] | 698 | done |
---|
[2046] | 699 | if ! $(isin_list ${vardiags} 'time'); then vardiags=${vardiags}':time'; fi |
---|
[2036] | 700 | fi |
---|
[2046] | 701 | else |
---|
[2055] | 702 | vardiags='LON:LAT:Times:'${nondiagvs} |
---|
[2036] | 703 | fi |
---|
| 704 | vardiag=`echo ${vardiags} | tr ':' ','` |
---|
| 705 | |
---|
| 706 | # Getting values |
---|
| 707 | if ${fscratch}; then rm ${simsfcmapf} >& /dev/null; fi |
---|
| 708 | if test ! -f ${simsfcmapf}; then |
---|
| 709 | values='Time,0,-1,1@south_north,0,-1,1@west_east,0,-1,1:False' |
---|
[2130] | 710 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2036] | 711 | -S ${values} -v ${vardiag} |
---|
| 712 | if test $? -ne 0; then |
---|
| 713 | echo ${errmsg} |
---|
| 714 | echo " python failed!!" |
---|
[2130] | 715 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2036] | 716 | -S "'"${values}"'" -v ${vardiag} |
---|
| 717 | exit |
---|
| 718 | fi |
---|
| 719 | echo "* get values for 2D map diagnostics: " >> ${ofileins} |
---|
[2130] | 720 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
[2036] | 721 | -S "'"${values}"'" -v ${vardiag} >> ${ofileins} |
---|
| 722 | echo " " >> ${ofileins} |
---|
| 723 | |
---|
| 724 | ofilen='newfile_multidims.nc' |
---|
| 725 | mv ${ofilen} ${simsfcmapf} |
---|
| 726 | fi |
---|
| 727 | |
---|
| 728 | if ${fscratch}; then rm ${simsfcmapdiagsf}; fi |
---|
| 729 | if test ! -f ${simsfcmapdiagsf}; then |
---|
[2046] | 730 | if test ! ${sfcdiagnames} = 'None'; then |
---|
[2130] | 731 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d ${sfcmapdiagd} \ |
---|
[2046] | 732 | -v ${sfcdiagvals} |
---|
| 733 | if test $? -ne 0; then |
---|
| 734 | echo ${errmsg} |
---|
| 735 | echo " python failed!!" |
---|
[2130] | 736 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} \ |
---|
| 737 | -d "'"${sfcmapdiagd}"'" -v "'"${sfcdiagvals}"'" |
---|
[2046] | 738 | exit |
---|
| 739 | fi |
---|
| 740 | echo "* diagnostics for sfc 2D map: " >> ${ofileins} |
---|
[2130] | 741 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'" \ |
---|
[2046] | 742 | -v "'"${sfcdiagvals}"'" >> ${ofileins} |
---|
| 743 | echo " " >> ${ofileins} |
---|
| 744 | mv diagnostics.nc ${simsfcmapdiagsf} |
---|
[2036] | 745 | fi |
---|
[2046] | 746 | # If there was not diagnostics |
---|
| 747 | if test ! -f ${simsfcmapdiagsf}; then |
---|
[2051] | 748 | dddv='Time@Times' |
---|
| 749 | selvars='LON,LAT,Times' |
---|
[2130] | 750 | ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcmapf} -v ${selvars} |
---|
[2046] | 751 | if test $? -ne 0; then |
---|
| 752 | echo ${errmsg} |
---|
| 753 | echo " python failed!!" |
---|
[2130] | 754 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${ddv}"'" -f ${simsfmapf} \ |
---|
[2046] | 755 | -v ${vars} |
---|
| 756 | exit |
---|
| 757 | rm ${simsfcmapf} |
---|
| 758 | fi |
---|
| 759 | echo "* creation of diagnostics file for 2D map:" >> ${ofileins} |
---|
[2130] | 760 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcmapf} \ |
---|
[2048] | 761 | -v ${selvars} >> ${ofileins} |
---|
[2046] | 762 | echo " " >> ${ofileins} |
---|
| 763 | mv selvar_new.nc ${simsfcmapdiagsf} |
---|
[2130] | 764 | ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ |
---|
[2066] | 765 | -f ${simsfcmapdiagsf} -v time |
---|
[2050] | 766 | if test $? -ne 0; then |
---|
| 767 | echo ${errmsg} |
---|
| 768 | echo " python failed!!" |
---|
[2130] | 769 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
| 770 | -S 19491201000000,minutes -f ${simsfcmapdiagsf} -v time |
---|
[2050] | 771 | exit |
---|
[2066] | 772 | rm ${simsfcmapdiagsf} |
---|
[2050] | 773 | fi |
---|
| 774 | echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \ |
---|
| 775 | ${stlat} >> ${ofileins} |
---|
[2130] | 776 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
| 777 | -S 19491201000000,minutes -f ${simsfcmapdiagsf} -v time >> ${ofileins} |
---|
[2050] | 778 | echo " " >> ${ofileins} |
---|
[2046] | 779 | fi |
---|
[2036] | 780 | |
---|
| 781 | #Adding non-diagnostic variables |
---|
| 782 | if test ! ${nondiagvs} = 'None'; then |
---|
| 783 | varsadd=`echo ${nondiagvs} | tr ':' ' '` |
---|
| 784 | for vadd in ${varsadd}; do |
---|
[2130] | 785 | ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcmapf},${vadd} \ |
---|
[2036] | 786 | -f ${simsfcmapdiagsf} |
---|
| 787 | if test $? -ne 0; then |
---|
| 788 | echo ${errmsg} |
---|
| 789 | echo " python failed!!" |
---|
[2130] | 790 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ |
---|
[2036] | 791 | -f ${simsfcmapdiagsf} |
---|
| 792 | exit |
---|
| 793 | rm ${simsfcmapdiagsf} |
---|
| 794 | fi |
---|
| 795 | echo "* adding variable '"${vadd}"' at sfc map: " >> ${ofileins} |
---|
[2130] | 796 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ |
---|
[2036] | 797 | -f ${simsfcmapdiagsf} >> ${ofileins} |
---|
| 798 | echo " " >> ${ofileins} |
---|
| 799 | # CF varname |
---|
[2130] | 800 | CFvarn=`${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} | \ |
---|
[2089] | 801 | grep -v variables_values | tr ':' ' ' | awk '{print $1}'` |
---|
[2036] | 802 | if test $? -ne 0; then |
---|
| 803 | echo ${errmsg} |
---|
| 804 | echo " python failed!!" |
---|
[2130] | 805 | echo ${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} |
---|
[2036] | 806 | exit |
---|
| 807 | rm ${simsfcmapdiagsf} |
---|
| 808 | fi |
---|
[2130] | 809 | ${pyBIN} $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcmapdiagsf} \ |
---|
[2036] | 810 | -v ${vadd} |
---|
| 811 | if test $? -ne 0; then |
---|
| 812 | echo ${errmsg} |
---|
| 813 | echo " python failed!!" |
---|
[2130] | 814 | echo ${pyBIN} ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ |
---|
[2036] | 815 | -f ${simsfcmapdiagsf} -v ${vadd} |
---|
| 816 | exit |
---|
| 817 | rm ${simsfcmapdiagsf} |
---|
| 818 | fi |
---|
| 819 | done |
---|
| 820 | fi |
---|
| 821 | fi |
---|
| 822 | } |
---|
| 823 | |
---|
| 824 | |
---|
[2001] | 825 | ####### ####### |
---|
| 826 | ## MAIN |
---|
| 827 | ####### |
---|
[2000] | 828 | |
---|
[2001] | 829 | rootsh=`pwd` |
---|
[2000] | 830 | |
---|
[2001] | 831 | ofileins=${rootsh}'/allins_functions.inf' |
---|
[2000] | 832 | |
---|
[2001] | 833 | if ${fscratch}; then |
---|
| 834 | echo "All instructions _______ " > ${ofileins} |
---|
| 835 | echo "******* ****** ***** **** *** ** *" >> ${ofileins} |
---|
| 836 | echo " " >> ${ofileins} |
---|
| 837 | fi |
---|
[2000] | 838 | |
---|
[2022] | 839 | fileN=`basename ${infilen}` |
---|
| 840 | fdate=`echo ${fileN} | tr '_' ' ' | awk '{print $3"_"$4}'` |
---|
[2000] | 841 | |
---|
[2001] | 842 | # Sounding |
---|
[2044] | 843 | if test ! ${sndid} = 'None' && test ! ${wrfsnddiags} = 'None'; then |
---|
[2001] | 844 | stid=${sndid} |
---|
| 845 | simsndptf=${odir}'/simout_vars_sndpt_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
| 846 | simsnddiagsf=${odir}'/simout_snddiags_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
[2000] | 847 | |
---|
[2001] | 848 | fvals=${sndlon}'#'${sndlat}'#'${infilen}'#XLONG#XLAT#'${wrfsnddiags} |
---|
| 849 | get_WRFsounding_data ${fvals} |
---|
| 850 | fi |
---|
[2000] | 851 | |
---|
[2001] | 852 | # Surface |
---|
[2044] | 853 | if test ! ${sfcid} = 'None' && test ! ${wrfsfcdiags} = 'None' || \ |
---|
| 854 | test ! ${wrfsfcnodiags} = 'None'; then |
---|
[2001] | 855 | stid=${sfcid} |
---|
| 856 | simsfcptf=${odir}'/simout_vars_sfcpt_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
| 857 | simsfcdiagsf=${odir}'/simout_sfcdiags_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
| 858 | |
---|
| 859 | fvals=${sfclon}'#'${sfclat}'#'${infilen}'#XLONG#XLAT#'${wrfsfcdiags}'#'${wrfsfcnodiags} |
---|
| 860 | get_WRFsurface_data ${fvals} |
---|
| 861 | fi |
---|
| 862 | |
---|
[2023] | 863 | # Surface maps |
---|
[2044] | 864 | if test ! ${wrfsfcdiags} = 'None' || test ! ${wrfsfcnodiags} = 'None'; then |
---|
| 865 | simsfcmapf=${odir}'/simout_vars_sfcmap_'${expl}'_'${fdate}'.nc' |
---|
| 866 | simsfcmapdiagsf=${odir}'/simout_sfcmapdiags_'${expl}'_'${fdate}'.nc' |
---|
[2023] | 867 | |
---|
[2044] | 868 | fvals=${infilen}'#'${wrfsfcdiags}'#'${wrfsfcnodiags} |
---|
| 869 | get_WRFsfc2D_data ${fvals} |
---|
| 870 | fi |
---|
[2023] | 871 | |
---|
[2036] | 872 | # cdx snd |
---|
[2053] | 873 | if test ! ${sndid} = 'None'; then |
---|
| 874 | if test ! ${wrfcdxdiags} = 'None' || test ! ${wrfcdxnodiags} = 'None'; then |
---|
| 875 | stid=${sndid} |
---|
[2067] | 876 | simsfcptf=${odir}'/simcdx_vars_sndpt_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
| 877 | simsfcdiagsf=${odir}'/simcdx_snddiags_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
[2036] | 878 | |
---|
[2053] | 879 | fvals=${sndlon}'#'${sndlat}'#'${infilen}'#LON#LAT#'${wrfcdxdiags}'#' |
---|
| 880 | fvals=${fvals}${wrfcdxnodiags} |
---|
| 881 | get_WRFCDXsurface_data ${fvals} |
---|
| 882 | fi |
---|
[2036] | 883 | fi |
---|
| 884 | |
---|
| 885 | # cdx Surface |
---|
[2053] | 886 | if test ! ${sfcid} = 'None'; then |
---|
| 887 | if test ! ${wrfcdxdiags} = 'None' || test ! ${wrfcdxnodiags} = 'None'; then |
---|
| 888 | stid=${sfcid} |
---|
| 889 | simsfcptf=${odir}'/simcdx_vars_sfcpt_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
| 890 | simsfcdiagsf=${odir}'/simcdx_sfcdiags_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
[2036] | 891 | |
---|
[2053] | 892 | fvals=${sfclon}'#'${sfclat}'#'${infilen}'#LON#LAT#'${wrfcdxdiags}'#' |
---|
| 893 | fvals=${fvals}${wrfcdxnodiags} |
---|
| 894 | get_WRFCDXsurface_data ${fvals} |
---|
| 895 | fi |
---|
[2036] | 896 | fi |
---|
| 897 | |
---|
| 898 | # cdx Surface maps |
---|
[2044] | 899 | if test ! ${wrfcdxdiags} = 'None' || test ! ${wrfcdxnodiags} = 'None'; then |
---|
| 900 | simsfcmapf=${odir}'/simcdx_vars_sfcmap_'${expl}'_'${fdate}'.nc' |
---|
| 901 | simsfcmapdiagsf=${odir}'/simcdx_sfcmapdiags_'${expl}'_'${fdate}'.nc' |
---|
[2036] | 902 | |
---|
[2044] | 903 | fvals=${infilen}'#'${wrfcdxdiags}'#'${wrfcdxnodiags} |
---|
| 904 | get_WRFCDXsfc2D_data ${fvals} |
---|
| 905 | fi |
---|
[2036] | 906 | |
---|
[2000] | 907 | fi |
---|