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,None,None ccc_mpirun!python |
---|
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 | [pyBIN]('!' for spaces)" |
---|
14 | else |
---|
15 | errmsg='ERROR -- error -- ERROR -- error' |
---|
16 | |
---|
17 | if test $1 = 'true'; then fscratch=true |
---|
18 | else fscratch=false; fi |
---|
19 | |
---|
20 | odir=$2 |
---|
21 | expl=$3 |
---|
22 | if test ! $4 = 'None'; then |
---|
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 |
---|
29 | |
---|
30 | if test ! $5 = 'None'; then |
---|
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 |
---|
37 | |
---|
38 | infilen=$6 |
---|
39 | |
---|
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 | |
---|
48 | pyBIN=`echo $8 | tr '!' ' '` |
---|
49 | |
---|
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' |
---|
83 | gridsndv=`${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \ |
---|
84 | -v ${stlon},${stlat} | tr ' ' '!'` |
---|
85 | echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins} |
---|
86 | echo ${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \ |
---|
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}',' |
---|
104 | values=${values}${ysnd1}',1@west_east_stag,'${xsnd}','${xsnd1}',1:False' |
---|
105 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
106 | -S ${values} -v all |
---|
107 | if test $? -ne 0; then |
---|
108 | echo ${errmsg} |
---|
109 | echo " python failed!!" |
---|
110 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
111 | -S "'"${values}"'" -v all |
---|
112 | exit |
---|
113 | fi |
---|
114 | echo "* get values at snd point: "${stlon}", "${stlat} >> ${ofileins} |
---|
115 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
116 | -S "'"${values}"'" -v all >> ${ofileins} |
---|
117 | echo " " >> ${ofileins} |
---|
118 | |
---|
119 | ofilen='newfile_multidims.nc' |
---|
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 |
---|
141 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsndptf} -d ${snddiagd} -v ${snddiagvals} |
---|
142 | if test $? -ne 0; then |
---|
143 | echo ${errmsg} |
---|
144 | echo " python failed!!" |
---|
145 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsndptf} -d "'"${snddiagd}"'" -v \ |
---|
146 | "'"${snddiagvals}"'" |
---|
147 | exit |
---|
148 | fi |
---|
149 | echo "* computing diagnostics at snd point: "${stlon}", "${stlat} >> ${ofileins} |
---|
150 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f "'"${simsndptf}"'" -d "'"${snddiagd}"'" \ |
---|
151 | -v "'"${snddiagvals}"'" >> ${ofileins} |
---|
152 | echo " " >> ${ofileins} |
---|
153 | |
---|
154 | mv diagnostics.nc ${simsnddiagsf} |
---|
155 | if $(isin_list ${snddiagnames} WRFt); then |
---|
156 | #To deg |
---|
157 | ${pyBIN} ${pyHOME}/nc_var.py -o valmod -S subc,273.15 -f ${simsnddiagsf} -v ta |
---|
158 | fi |
---|
159 | if $(isin_list ${snddiagnames} WRFp); then |
---|
160 | #To Pa |
---|
161 | ${pyBIN} ${pyHOME}/nc_var.py -o valmod -S divc,100. -f ${simsnddiagsf} -v pres |
---|
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' |
---|
188 | gridsndv=`${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \ |
---|
189 | -v ${stlon},${stlat} | tr ' ' '!'` |
---|
190 | echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins} |
---|
191 | echo ${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \ |
---|
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}',' |
---|
208 | values=${values}${ysnd1}',1@west_east_stag,'${xsnd}','${xsnd1}',1:false' |
---|
209 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
210 | -S ${values} -v all |
---|
211 | if test $? -ne 0; then |
---|
212 | echo ${errmsg} |
---|
213 | echo " python failed!!" |
---|
214 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
215 | -S "'"${values}"'" -v all |
---|
216 | exit |
---|
217 | fi |
---|
218 | echo "* get values at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
219 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
220 | -S "'"${values}"'" -v all >> ${ofileins} |
---|
221 | echo " " >> ${ofileins} |
---|
222 | |
---|
223 | ofilen='newfile_multidims.nc' |
---|
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 |
---|
245 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d ${sfcdiagd} -v ${sfcdiagvals} |
---|
246 | if test $? -ne 0; then |
---|
247 | echo ${errmsg} |
---|
248 | echo " python failed!!" |
---|
249 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ |
---|
250 | -v "'"${sfcdiagvals}"'" |
---|
251 | exit |
---|
252 | fi |
---|
253 | echo "* diagnostics at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
254 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ |
---|
255 | -v "'"${sfcdiagvals}"'" >> ${ofileins} |
---|
256 | echo " " >> ${ofileins} |
---|
257 | mv diagnostics.nc ${simsfcdiagsf} |
---|
258 | if $(isin_list ${sfcdiagnames} wds); then |
---|
259 | #To rad |
---|
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} \ |
---|
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 |
---|
271 | ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd} -f ${simsfcdiagsf} |
---|
272 | if test $? -ne 0; then |
---|
273 | echo ${errmsg} |
---|
274 | echo " python failed!!" |
---|
275 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ |
---|
276 | -f ${simsfcdiagsf} |
---|
277 | exit |
---|
278 | rm ${simsfcdiagsf} |
---|
279 | fi |
---|
280 | echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
281 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ |
---|
282 | -f ${simsfcdiagsf} >> ${ofileins} |
---|
283 | echo " " >> ${ofileins} |
---|
284 | # CF varname |
---|
285 | CFvarn=`${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} | \ |
---|
286 | grep -v variables_values | tr ':' ' ' | awk '{print $1}'` |
---|
287 | if test $? -ne 0; then |
---|
288 | echo ${errmsg} |
---|
289 | echo " python failed!!" |
---|
290 | echo ${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} |
---|
291 | exit |
---|
292 | rm ${simsfcdiagsf} |
---|
293 | fi |
---|
294 | ${pyBIN} $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} -v ${vadd} |
---|
295 | if test $? -ne 0; then |
---|
296 | echo ${errmsg} |
---|
297 | echo " python failed!!" |
---|
298 | echo ${pyBIN} ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ |
---|
299 | -f ${simsfcdiagsf} -v ${vadd} |
---|
300 | exit |
---|
301 | rm ${simsfcdiagsf} |
---|
302 | fi |
---|
303 | done |
---|
304 | fi |
---|
305 | } |
---|
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 |
---|
321 | if test ! ${sfcdiagnames} = 'None'; then |
---|
322 | sfcmapdiagd='Time@WRFtime:south_north@XLAT:west_east@XLONG' |
---|
323 | diagns=`echo ${sfcdiagnames} | tr ':' ' '` |
---|
324 | |
---|
325 | # getting that variables only required for the diagnostics |
---|
326 | vardiags='' |
---|
327 | idiag=1 |
---|
328 | for diagn in ${diagns}; do |
---|
329 | diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |\ |
---|
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 |
---|
349 | done |
---|
350 | fi |
---|
351 | else |
---|
352 | vardiags='Times:XLONG:XLAT:'${nondiagvs} |
---|
353 | fi |
---|
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' |
---|
362 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
363 | -S ${values} -v ${vardiag} |
---|
364 | if test $? -ne 0; then |
---|
365 | echo ${errmsg} |
---|
366 | echo " python failed!!" |
---|
367 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
368 | -S "'"${values}"'" -v ${vardiag} |
---|
369 | exit |
---|
370 | fi |
---|
371 | echo "* get values for 2D map diagnostics: " >> ${ofileins} |
---|
372 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
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 |
---|
381 | if test ! -f ${simsfcmapdiagsf}; then |
---|
382 | if test ! ${sfcdiagnames} = 'None'; then |
---|
383 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d ${sfcmapdiagd} \ |
---|
384 | -v ${sfcdiagvals} |
---|
385 | if test $? -ne 0; then |
---|
386 | echo ${errmsg} |
---|
387 | echo " python failed!!" |
---|
388 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'" \ |
---|
389 | -v "'"${sfcdiagvals}"'" |
---|
390 | exit |
---|
391 | fi |
---|
392 | echo "* diagnostics for sfc 2D map: " >> ${ofileins} |
---|
393 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'" \ |
---|
394 | -v "'"${sfcdiagvals}"'" >> ${ofileins} |
---|
395 | echo " " >> ${ofileins} |
---|
396 | mv diagnostics.nc ${simsfcmapdiagsf} |
---|
397 | if $(isin_list ${sfcdiagnames} wds); then |
---|
398 | #To rad |
---|
399 | ${pyBIN} ${pyHOME}/nc_var.py -o valmod -S mulc,0.0174532925199 \ |
---|
400 | -f ${simsfcmapdiagsf} -v wds |
---|
401 | ${pyBIN} ${pyHOME}/nc_var.py -o varaddattr -S 'units|rad' \ |
---|
402 | -f ${simsfcmapdiagsf} -v wds |
---|
403 | fi |
---|
404 | fi |
---|
405 | # If there was not diagnostics |
---|
406 | if test ! -f ${simsfcmapdiagsf}; then |
---|
407 | dddv='Time@Times' |
---|
408 | selvars='XLONG,XLAT,Times' |
---|
409 | ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcmapf} -v ${selvars} |
---|
410 | if test $? -ne 0; then |
---|
411 | echo ${errmsg} |
---|
412 | echo " python failed!!" |
---|
413 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${ddv}"'" -f ${simsfmapf} \ |
---|
414 | -v ${vars} |
---|
415 | exit |
---|
416 | rm ${simsfcmapf} |
---|
417 | fi |
---|
418 | echo "* creation of diagnostics file for 2D map:" >> ${ofileins} |
---|
419 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcmapf} \ |
---|
420 | -v ${selvars} >> ${ofileins} |
---|
421 | echo " " >> ${ofileins} |
---|
422 | mv selvar_new.nc ${simsfcmapdiagsf} |
---|
423 | ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ |
---|
424 | -f ${simsfcmapdiagsf} -v time |
---|
425 | if test $? -ne 0; then |
---|
426 | echo ${errmsg} |
---|
427 | echo " python failed!!" |
---|
428 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
429 | -S 19491201000000,minutes -f ${simsfcmapdiagsf} -v time |
---|
430 | exit |
---|
431 | rm ${simsfcmapdiagsf} |
---|
432 | fi |
---|
433 | echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \ |
---|
434 | ${stlat} >> ${ofileins} |
---|
435 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
436 | -S 19491201000000,minutes -f ${simsfcmapdiagsf} -v time >> ${ofileins} |
---|
437 | echo " " >> ${ofileins} |
---|
438 | fi |
---|
439 | #Adding non-diagnostic variables |
---|
440 | if test ! ${nondiagvs} = 'None'; then |
---|
441 | varsadd=`echo ${nondiagvs} | tr ':' ' '` |
---|
442 | for vadd in ${varsadd}; do |
---|
443 | ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcmapf},${vadd} \ |
---|
444 | -f ${simsfcmapdiagsf} |
---|
445 | if test $? -ne 0; then |
---|
446 | echo ${errmsg} |
---|
447 | echo " python failed!!" |
---|
448 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ |
---|
449 | -f ${simsfcmapdiagsf} |
---|
450 | exit |
---|
451 | rm ${simsfcmapdiagsf} |
---|
452 | fi |
---|
453 | echo "* adding variable '"${vadd}"' at sfc map: " >> ${ofileins} |
---|
454 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ |
---|
455 | -f ${simsfcmapdiagsf} >> ${ofileins} |
---|
456 | echo " " >> ${ofileins} |
---|
457 | # CF varname |
---|
458 | CFvarn=`${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} | \ |
---|
459 | grep -v variables_values | tr ':' ' ' | awk '{print $1}'` |
---|
460 | if test $? -ne 0; then |
---|
461 | echo ${errmsg} |
---|
462 | echo " python failed!!" |
---|
463 | echo ${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} |
---|
464 | exit |
---|
465 | rm ${simsfcmapdiagsf} |
---|
466 | fi |
---|
467 | ${pyBIN} $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcmapdiagsf} \ |
---|
468 | -v ${vadd} |
---|
469 | if test $? -ne 0; then |
---|
470 | echo ${errmsg} |
---|
471 | echo " python failed!!" |
---|
472 | echo ${pyBIN} ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ |
---|
473 | -f ${simsfcmapdiagsf} -v ${vadd} |
---|
474 | exit |
---|
475 | rm ${simsfcmapdiagsf} |
---|
476 | fi |
---|
477 | done |
---|
478 | fi |
---|
479 | fi |
---|
480 | } |
---|
481 | |
---|
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' |
---|
504 | gridsndv=`${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S ${vals} \ |
---|
505 | -v ${stlon},${stlat} | tr ' ' '!'` |
---|
506 | echo "* get grid point: "${stlon}", "${stlat} >> ${ofileins} |
---|
507 | echo ${pyBIN} ${pyHOME}/nc_var.py -o get_point -f ${filen} -S "'"${vals}"'" \ |
---|
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' |
---|
524 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
525 | -S ${values} -v all |
---|
526 | if test $? -ne 0; then |
---|
527 | echo ${errmsg} |
---|
528 | echo " python failed!!" |
---|
529 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
530 | -S "'"${values}"'" -v all |
---|
531 | exit |
---|
532 | fi |
---|
533 | echo "* get values at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
534 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
535 | -S "'"${values}"'" -v all >> ${ofileins} |
---|
536 | echo " " >> ${ofileins} |
---|
537 | |
---|
538 | ofilen='newfile_multidims.nc' |
---|
539 | mv ${ofilen} ${simsfcptf} |
---|
540 | fi |
---|
541 | |
---|
542 | # Computing sfc diagnostics |
---|
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 ':' ' '` |
---|
548 | |
---|
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 |
---|
560 | |
---|
561 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d ${sfcdiagd} -v ${sfcdiagvals} |
---|
562 | if test $? -ne 0; then |
---|
563 | echo ${errmsg} |
---|
564 | echo " python failed!!" |
---|
565 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ |
---|
566 | -v "'"${sfcdiagvals}"'" |
---|
567 | exit |
---|
568 | fi |
---|
569 | echo "* diagnostics at sfc point: "${stlon}", "${stlat} >> ${ofileins} |
---|
570 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcptf} -d "'"${sfcdiagd}"'" \ |
---|
571 | -v "'"${sfcdiagvals}"'" >> ${ofileins} |
---|
572 | echo " " >> ${ofileins} |
---|
573 | mv diagnostics.nc ${simsfcdiagsf} |
---|
574 | fi |
---|
575 | |
---|
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' |
---|
582 | ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcptf} -v ${selvars} |
---|
583 | if test $? -ne 0; then |
---|
584 | echo ${errmsg} |
---|
585 | echo " python failed!!" |
---|
586 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcptf}\ |
---|
587 | -v ${vars} |
---|
588 | exit |
---|
589 | rm ${simsfcptf} |
---|
590 | fi |
---|
591 | echo "* creation of diagnostics file at sfc point: "${stlon}", "${stlat} >> \ |
---|
592 | ${ofileins} |
---|
593 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcptf} \ |
---|
594 | -v ${selvars} >> ${ofileins} |
---|
595 | echo " " >> ${ofileins} |
---|
596 | mv selvar_new.nc ${simsfcdiagsf} |
---|
597 | ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
598 | -S 19491201000000,minutes -f ${simsfcdiagsf} -v time |
---|
599 | if test $? -ne 0; then |
---|
600 | echo ${errmsg} |
---|
601 | echo " python failed!!" |
---|
602 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
603 | -S 19491201000000,minutes -f ${simsfcdiagsf} -v time |
---|
604 | exit |
---|
605 | rm ${simsfcdiagsf} |
---|
606 | fi |
---|
607 | echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \ |
---|
608 | ${stlat} >> ${ofileins} |
---|
609 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
610 | -S 19491201000000,minutes -f ${simsfcdiagsf} -v time >> ${ofileins} |
---|
611 | echo " " >> ${ofileins} |
---|
612 | fi |
---|
613 | varsadd=`echo ${nondiagvs} | tr ':' ' '` |
---|
614 | for vadd in ${varsadd}; do |
---|
615 | ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcptf},${vadd} \ |
---|
616 | -f ${simsfcdiagsf} |
---|
617 | if test $? -ne 0; then |
---|
618 | echo ${errmsg} |
---|
619 | echo " python failed!!" |
---|
620 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ |
---|
621 | -f ${simsfcdiagsf} |
---|
622 | exit |
---|
623 | rm ${simsfcdiagsf} |
---|
624 | fi |
---|
625 | echo "* adding variable '"${vadd}"' at sfc point: "${stlon}", "${stlat} >> \ |
---|
626 | ${ofileins} |
---|
627 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcptf},${vadd}"'" \ |
---|
628 | -f ${simsfcdiagsf} >> ${ofileins} |
---|
629 | echo " " >> ${ofileins} |
---|
630 | # CF varname |
---|
631 | CFvarn=`${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} | \ |
---|
632 | grep -v variables_values | tr ':' ' ' | awk '{print $1}'` |
---|
633 | if test $? -ne 0; then |
---|
634 | echo ${errmsg} |
---|
635 | echo " python failed!!" |
---|
636 | echo ${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} |
---|
637 | exit |
---|
638 | rm ${simsfcdiagsf} |
---|
639 | fi |
---|
640 | ${pyBIN} $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcdiagsf} \ |
---|
641 | -v ${vadd} |
---|
642 | if test $? -ne 0; then |
---|
643 | echo ${errmsg} |
---|
644 | echo " python failed!!" |
---|
645 | echo ${pyBIN} ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ |
---|
646 | -f ${simsfcdiagsf} -v ${vadd} |
---|
647 | exit |
---|
648 | rm ${simsfcdiagsf} |
---|
649 | fi |
---|
650 | done |
---|
651 | fi |
---|
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 |
---|
671 | if test ! ${sfcdiagnames} = 'None'; then |
---|
672 | diagns=`echo ${sfcdiagnames} | tr ':' ' '` |
---|
673 | |
---|
674 | # getting that variables only required for the diagnostics |
---|
675 | vardiags='' |
---|
676 | idiag=1 |
---|
677 | for diagn in ${diagns}; do |
---|
678 | diagv=`cat $pyHOME/diagnostics.inf | grep WRF | grep ${diagn}',' | tr ',' ' ' |\ |
---|
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 |
---|
698 | done |
---|
699 | if ! $(isin_list ${vardiags} 'time'); then vardiags=${vardiags}':time'; fi |
---|
700 | fi |
---|
701 | else |
---|
702 | vardiags='LON:LAT:Times:'${nondiagvs} |
---|
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' |
---|
710 | ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
711 | -S ${values} -v ${vardiag} |
---|
712 | if test $? -ne 0; then |
---|
713 | echo ${errmsg} |
---|
714 | echo " python failed!!" |
---|
715 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
716 | -S "'"${values}"'" -v ${vardiag} |
---|
717 | exit |
---|
718 | fi |
---|
719 | echo "* get values for 2D map diagnostics: " >> ${ofileins} |
---|
720 | echo ${pyBIN} ${pyHOME}/nc_var.py -o DataSetSection_multidims -f ${filen} \ |
---|
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 |
---|
730 | if test ! ${sfcdiagnames} = 'None'; then |
---|
731 | ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d ${sfcmapdiagd} \ |
---|
732 | -v ${sfcdiagvals} |
---|
733 | if test $? -ne 0; then |
---|
734 | echo ${errmsg} |
---|
735 | echo " python failed!!" |
---|
736 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} \ |
---|
737 | -d "'"${sfcmapdiagd}"'" -v "'"${sfcdiagvals}"'" |
---|
738 | exit |
---|
739 | fi |
---|
740 | echo "* diagnostics for sfc 2D map: " >> ${ofileins} |
---|
741 | echo ${pyBIN} ${pyHOME}/diagnostics.py -f ${simsfcmapf} -d "'"${sfcmapdiagd}"'" \ |
---|
742 | -v "'"${sfcdiagvals}"'" >> ${ofileins} |
---|
743 | echo " " >> ${ofileins} |
---|
744 | mv diagnostics.nc ${simsfcmapdiagsf} |
---|
745 | fi |
---|
746 | # If there was not diagnostics |
---|
747 | if test ! -f ${simsfcmapdiagsf}; then |
---|
748 | dddv='Time@Times' |
---|
749 | selvars='LON,LAT,Times' |
---|
750 | ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S ${dddv} -f ${simsfcmapf} -v ${selvars} |
---|
751 | if test $? -ne 0; then |
---|
752 | echo ${errmsg} |
---|
753 | echo " python failed!!" |
---|
754 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${ddv}"'" -f ${simsfmapf} \ |
---|
755 | -v ${vars} |
---|
756 | exit |
---|
757 | rm ${simsfcmapf} |
---|
758 | fi |
---|
759 | echo "* creation of diagnostics file for 2D map:" >> ${ofileins} |
---|
760 | echo ${pyBIN} ${pyHOME}/nc_var.py -o selvar -S "'"${dddv}"'" -f ${simsfcmapf} \ |
---|
761 | -v ${selvars} >> ${ofileins} |
---|
762 | echo " " >> ${ofileins} |
---|
763 | mv selvar_new.nc ${simsfcmapdiagsf} |
---|
764 | ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation -S 19491201000000,minutes \ |
---|
765 | -f ${simsfcmapdiagsf} -v time |
---|
766 | if test $? -ne 0; then |
---|
767 | echo ${errmsg} |
---|
768 | echo " python failed!!" |
---|
769 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
770 | -S 19491201000000,minutes -f ${simsfcmapdiagsf} -v time |
---|
771 | exit |
---|
772 | rm ${simsfcmapdiagsf} |
---|
773 | fi |
---|
774 | echo "* creation of CF-time variable for file at sfc point: "${stlon}", " \ |
---|
775 | ${stlat} >> ${ofileins} |
---|
776 | echo ${pyBIN} ${pyHOME}/nc_var.py -o WRF_CFtime_creation \ |
---|
777 | -S 19491201000000,minutes -f ${simsfcmapdiagsf} -v time >> ${ofileins} |
---|
778 | echo " " >> ${ofileins} |
---|
779 | fi |
---|
780 | |
---|
781 | #Adding non-diagnostic variables |
---|
782 | if test ! ${nondiagvs} = 'None'; then |
---|
783 | varsadd=`echo ${nondiagvs} | tr ':' ' '` |
---|
784 | for vadd in ${varsadd}; do |
---|
785 | ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S ${simsfcmapf},${vadd} \ |
---|
786 | -f ${simsfcmapdiagsf} |
---|
787 | if test $? -ne 0; then |
---|
788 | echo ${errmsg} |
---|
789 | echo " python failed!!" |
---|
790 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ |
---|
791 | -f ${simsfcmapdiagsf} |
---|
792 | exit |
---|
793 | rm ${simsfcmapdiagsf} |
---|
794 | fi |
---|
795 | echo "* adding variable '"${vadd}"' at sfc map: " >> ${ofileins} |
---|
796 | echo ${pyBIN} ${pyHOME}/nc_var.py -o fvaradd -S "'"${simsfcmapf},${vadd}"'" \ |
---|
797 | -f ${simsfcmapdiagsf} >> ${ofileins} |
---|
798 | echo " " >> ${ofileins} |
---|
799 | # CF varname |
---|
800 | CFvarn=`${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} | \ |
---|
801 | grep -v variables_values | tr ':' ' ' | awk '{print $1}'` |
---|
802 | if test $? -ne 0; then |
---|
803 | echo ${errmsg} |
---|
804 | echo " python failed!!" |
---|
805 | echo ${pyBIN} $pyHOME/generic.py -o variables_values -S ${vadd} |
---|
806 | exit |
---|
807 | rm ${simsfcmapdiagsf} |
---|
808 | fi |
---|
809 | ${pyBIN} $pyHOME/nc_var.py -o chvarname -S ${CFvarn} -f ${simsfcmapdiagsf} \ |
---|
810 | -v ${vadd} |
---|
811 | if test $? -ne 0; then |
---|
812 | echo ${errmsg} |
---|
813 | echo " python failed!!" |
---|
814 | echo ${pyBIN} ${pyHOME}/nc_var.py -o chvarname -S ${CFvarn} \ |
---|
815 | -f ${simsfcmapdiagsf} -v ${vadd} |
---|
816 | exit |
---|
817 | rm ${simsfcmapdiagsf} |
---|
818 | fi |
---|
819 | done |
---|
820 | fi |
---|
821 | fi |
---|
822 | } |
---|
823 | |
---|
824 | |
---|
825 | ####### ####### |
---|
826 | ## MAIN |
---|
827 | ####### |
---|
828 | |
---|
829 | rootsh=`pwd` |
---|
830 | |
---|
831 | ofileins=${rootsh}'/allins_functions.inf' |
---|
832 | |
---|
833 | if ${fscratch}; then |
---|
834 | echo "All instructions _______ " > ${ofileins} |
---|
835 | echo "******* ****** ***** **** *** ** *" >> ${ofileins} |
---|
836 | echo " " >> ${ofileins} |
---|
837 | fi |
---|
838 | |
---|
839 | fileN=`basename ${infilen}` |
---|
840 | fdate=`echo ${fileN} | tr '_' ' ' | awk '{print $3"_"$4}'` |
---|
841 | |
---|
842 | # Sounding |
---|
843 | if test ! ${sndid} = 'None' && test ! ${wrfsnddiags} = 'None'; then |
---|
844 | stid=${sndid} |
---|
845 | simsndptf=${odir}'/simout_vars_sndpt_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
846 | simsnddiagsf=${odir}'/simout_snddiags_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
847 | |
---|
848 | fvals=${sndlon}'#'${sndlat}'#'${infilen}'#XLONG#XLAT#'${wrfsnddiags} |
---|
849 | get_WRFsounding_data ${fvals} |
---|
850 | fi |
---|
851 | |
---|
852 | # Surface |
---|
853 | if test ! ${sfcid} = 'None' && test ! ${wrfsfcdiags} = 'None' || \ |
---|
854 | test ! ${wrfsfcnodiags} = 'None'; then |
---|
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 | |
---|
863 | # Surface maps |
---|
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' |
---|
867 | |
---|
868 | fvals=${infilen}'#'${wrfsfcdiags}'#'${wrfsfcnodiags} |
---|
869 | get_WRFsfc2D_data ${fvals} |
---|
870 | fi |
---|
871 | |
---|
872 | # cdx snd |
---|
873 | if test ! ${sndid} = 'None'; then |
---|
874 | if test ! ${wrfcdxdiags} = 'None' || test ! ${wrfcdxnodiags} = 'None'; then |
---|
875 | stid=${sndid} |
---|
876 | simsfcptf=${odir}'/simcdx_vars_sndpt_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
877 | simsfcdiagsf=${odir}'/simcdx_snddiags_'${stid}'_'${expl}'_'${fdate}'.nc' |
---|
878 | |
---|
879 | fvals=${sndlon}'#'${sndlat}'#'${infilen}'#LON#LAT#'${wrfcdxdiags}'#' |
---|
880 | fvals=${fvals}${wrfcdxnodiags} |
---|
881 | get_WRFCDXsurface_data ${fvals} |
---|
882 | fi |
---|
883 | fi |
---|
884 | |
---|
885 | # cdx Surface |
---|
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' |
---|
891 | |
---|
892 | fvals=${sfclon}'#'${sfclat}'#'${infilen}'#LON#LAT#'${wrfcdxdiags}'#' |
---|
893 | fvals=${fvals}${wrfcdxnodiags} |
---|
894 | get_WRFCDXsurface_data ${fvals} |
---|
895 | fi |
---|
896 | fi |
---|
897 | |
---|
898 | # cdx Surface maps |
---|
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' |
---|
902 | |
---|
903 | fvals=${infilen}'#'${wrfcdxdiags}'#'${wrfcdxnodiags} |
---|
904 | get_WRFCDXsfc2D_data ${fvals} |
---|
905 | fi |
---|
906 | |
---|
907 | fi |
---|