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