Subversion Repositories lagranto.um

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
\documentclass[a4paper,10pt]{article}
2
\usepackage[utf8x]{inputenc}
3
 
4
\usepackage{graphicx}
5
\graphicspath{{/home/sprenger/lagranto/docu/tutorial/}}
6
 
7
\textwidth16cm
8
\textheight22.5cm
9
\oddsidemargin0.5cm
10
\evensidemargin0cm
11
\topmargin0.cm
12
\headsep0cm
13
\topskip-0.5cm
14
 
15
\title{Lagranto - Tutorial}
16
\author{Michael Sprenger and Heini Wernli}
17
 
18
\begin{document}
19
 
20
\maketitle
21
 
22
\section{Definition of the Problem}
23
 
24
In this tutorial we consider a simple way how to find airstreams which transport air from the surface into the upper troposphere and lower stratosphere, i.e. the UTLS region. More specifically, we intend
25
\begin{itemize}
26
\item[1)] to initialize starting positions over the North Atlantic and Europe (80 W to 20 E, 40 N to 80 N) for 00 UTC, 20 October 1989. The starting positions are horizontally equidistant with 80 km horizontal spacing and are set 100 hPa above ground level.
27
\item[2)] to calculate trajectories several hours forward in time.
28
\item[3)] to select trajectories which ascend to levels above 400 hPa within 48 hours and are found at starting time below 700 hPa.
29
\item[4)] to trace several meteorological fields along the trajectories: potential vorticity (PV), potential temperature (TH), relative (RH) and specific humidity (Q).
30
\item[4] to select subsamples of trajectories: a) those reaching the stratosphere; b) those travelling at most 2000 km; ... 
31
\item[5)] to show the densities of the trajectories on a geographical map.
32
\end{itemize}
33
 
34
\section{Meteorological Data}
35
 
36
The following dates and netCDF files are needed for a Lagranto calculation covering the time period from 07\,UTC 14 February 2011 to 11\,UTC 14 February 2011. 
37
\begin{verbatim}
38
> datelist stdout -create 20110214_07 20110214_11 interval 1
39
 20110214_07
40
 20110214_08
41
 20110214_09
42
 20110214_10
43
 20110214_11
44
\end{verbatim}
45
 
46
\noindent
47
There are two different files involved, the P and the S files. Lagranto expects them to be in the running directory:
48
 
49
\begin{verbatim}
50
> ls -1
51
 P20110214_07 P20110214_08 P20110214_09 P20110214_10 P20110214_11
52
 S20110214_07 S20110214_08 S20110214_09 S20110214_10 S20110214_11
53
\end{verbatim}
54
 
55
\noindent
56
The meteorological fields on the primary P files are at least: zonal wind (U, in m/s); meridional wind (V, in m/s); vertical wind (OMEGA, in Pa/s); 
57
surface pressure (PS, in hPa). Additional fields might be available on the P files, e.g. temperature (T), specific
58
humidity (Q),... Secondary fields can be saved in the S files, which must have the same grid structure as the P files.
59
In the example the following fields are saved on the S files: potential temperature (TH, in K); Ertel potential vorticity (PV, in pvu); relative humidity (in \%). 
60
Furthermore, the surface pressure (PS) is also saved on the S files; it must be exactly identical to the one in the P files.\\
61
 
62
\noindent
63
If surface pressure is not saved on the S files, it must be copied from the corresponding P files. This can most readily be done using the NCO tools (http://nco.sourceforge.net/):
64
 
65
\begin{verbatim}
66
> ncks -A -v PS P20110214_07 S$20110214_07
67
\end{verbatim}
68
 
69
\noindent
70
If the P and S files are stored at another place, they might be linked with a simple Shell script (in csh), usimg the command {\em datelist}:
71
\begin{verbatim}
72
> foreach date ( `datelist stdout -create 20110214_07 20110214_11 -interval 1` )
73
>   ln -s {SOURCE DIR}/P${date} {DEST DIR}/P${date}
74
>   ln -s {SOURCE DIR}/S${date} {DEST DIR}/S${date}
75
> end
76
\end{verbatim}
77
Note that the command {\em datelist} offers several options how to work with date list - creating, stepping through, comparing.
78
 
79
\section{Starting Positions}
80
 
81
In a first step the starting positions must be specified. To this aim a file {\em regionf} must be created with the definition of the region. Note that the UM uses a rotated coordinated system, whereas the starting region must be specified in true longitude and latitude in {\em regionf}. The position of the rotated north pole can easily be extracted with
82
 
83
\begin{verbatim}
84
> rot2geo -file 20110214_07
85
112 157.5
86
\end{verbatim}
87
 
88
\noindent
89
where 112.0 and 157.5 are longitude and latitude of the rotated north pole. The file {\em regionf} is in the same directory as the meteorological data (section 1):
90
 
91
\begin{verbatim}
92
> more regionf 
93
"1 -69.0 -67.0 -68.0 -66.0"
94
\end{verbatim}
95
 
96
\noindent
97
The first number specifies a region ID (here 1) and the other values are: west boundary (69 W), east boundary (67 W), southern boundary (68 S) and northern boundary (66 S). It is easily checked whether the lat/lon points are within the rotated domain. To this aim, use for instance
98
 
99
\begin{verbatim}
100
> geo2rot -69.0 -68.0 -file P20110214_07
101
  -0.3746045      -0.5030226
102
\end{verbatim}
103
 
104
\noindent
105
where now the output give the rotated longitude and latitude. These coordinates can be compared to the ones (domxmin,domxmax,domymin,domymax) on the netCDF files:
106
 
107
\begin{verbatim}
108
> ncdump -h P20110214_09
109
...
110
/ global attributes:
111
                :domxmin = 359.3602f ;
112
                :domxmax = 362.9647f ;
113
                :domymin = -1.5665f ;
114
                :domymax = 2.038f ;
115
                :domzmin = 1000.f ;
116
                :domzmax = 50.f ;
117
...
118
\end{verbatim}
119
 
120
\noindent
121
The starting positions are then created with
122
 
123
\begin{verbatim}
124
> create_startf 20110214_07 startf.2 'region.eqd(1,10) ...
125
                             ... @ level(100) @ hPa,agl' -changet
126
\end{verbatim}
127
 
128
\noindent
129
The starting positions are written to {\em startf.2}, i.e. in format 2, and cover the region 1 specified in {\em regionf}. The horizontal start points are equidistantly distributed with 10 km spacing, and they are all at 100 hPa above ground. All points refer to the starting date 07 UTC, 14 February 2011.
130
In total, 3750 starting positions are written to {\em startf.2}. The first few lines of the file look as follows:
131
 
132
\begin{verbatim}
133
> head -10 startf.2
134
Reference date 20110214_0700 / Time range       0 min
135
 
136
  time      lon     lat     p     level
137
---------------------------------------
138
 
139
   0.00   -68.996  -67.928   908   100.000
140
   0.00   -68.756  -67.928   908   100.000
141
   0.00   -68.516  -67.928   908   100.000
142
   0.00   -68.276  -67.928   908   100.000
143
   0.00   -68.037  -67.928   908   100.000
144
\end{verbatim}
145
 
146
\noindent
147
The different columns are: time, longitude, latitude, pressure (in hPa) and level (in hPa,agl). Note that the 'same' starting file could have been created without a region file. In this case, the command would have been:
148
 
149
\begin{verbatim}
150
> create_startf 19891020_00 startf.2 'box.eqd(-69,-67,-68,-66,10) ...
151
                             ... @ level(100) @ hPa,agl' -changet
152
\end{verbatim}
153
 
154
\noindent
155
However, note that the starting positions are not exactly the same as with the previous command: it is only guaranteed that the starting points are equidistantly distributed within the region.
156
 
157
 
158
\section{Trajectory Calculation}
159
 
160
In a next step, the trajectories are calculated 72 h forward in time, with starting date 00 UTC, 20 October 1989. The command is:
161
 
162
\begin{verbatim}
163
> caltra 19891020_00 19891023_00 startf.2 traj.4 -j
164
\end{verbatim}
165
 
166
\noindent
167
The taring positions are taken from{\em startf.2} and the output is written to {\em traj.4}. Furthermore, the jumping flag {\em -j} is set, i.e. if trajectories run into the ground they are lifted a little and allowed to move on.\\
168
 
169
\noindent
170
Note that the output file {\em traj.4} is not in ASCII format. To look at the file, use the command {\em trainfo}, for instance:
171
 
172
\begin{verbatim}
173
> trainfo traj.4 vars
174
time lon lat p 
175
 
176
> trainfo traj.4 dim
177
3750           13            4
178
 
179
> trainfo trai.4 startdate
180
19891020_0000
181
\end{verbatim}
182
 
183
\noindent
184
It is also possible to convert the trajectory file into ASCII format with the command {\em reformat}:
185
 
186
\begin{verbatim}
187
> reformat traj.4 traj.1
188
> more traj.1
189
Reference date 19891020_0000 / Time range    4320 min
190
 
191
  time      lon     lat     p
192
-----------------------------
193
 
194
   0.00   -79.61   40.45   862
195
   6.00   -80.57   43.23   791
196
  12.00   -82.23   45.89   782
197
  18.00   -84.94   47.07   744
198
\end{verbatim}
199
 
200
\noindent
201
The command {\em trafinfo} cna also be used to look at the trajectory tables, i.e. without a conversion to ASCII format. To this aim, use
202
 
203
\begin{verbatim}
204
> trainfo traj.4 list
205
\end{verbatim}
206
 
207
\noindent
208
Whereas the ASCII format is most convenient for visual inspection, it is the least compact format. In particular, if the output of {\em caltra} should be further processed, e.g. with {\em trace} or {\em select}, the binary formats should be used (see documentation for {\em reformat}).
209
 
210
\section{Pre-Selection of Trajectories}
211
 
212
Quite often, the position of the air parcels is sufficient to select trajectories. It is then most efficient to pre-select these trajectories and do the tracing of additional fields along the trajectories only on the pre-selected ones. In the example, airstreams should be identified which ascend from below 700 hPa at initial time to levels above 300 hPa. The ascent has to take place within 48 h. This selection can be achieved with the command:
213
 
214
\begin{verbatim}
215
> select traj.4 wcb.1 'GT:p:700:FIRST & LT:p(MIN):400:0 to 48'
216
\end{verbatim}
217
 
218
\noindent
219
The first criterion selects all trajectories for which the pressure (p) at the initial time (FIRST) is greater than (GT) 700 hPa. This criterison is logically AND-combined with the second criteron: consider all times between 0 and 48 h and take the minimum pressure, i.e. p(MIN), over this time interval; if the minium pressure is less than (LT) 400 hPa, the trajectory is selected. A sample trajectory looks like:
220
 
221
\begin{verbatim}
222
> trainfo wcb.1 list 
223
Reference date 19891020_0000 / Time range    4320 min
224
 
225
  time      lon     lat     p
226
-----------------------------
227
 
228
   0.00   -72.98   40.45   918
229
   6.00   -76.45   43.14   879
230
  12.00   -78.53   46.69   808
231
  18.00   -80.08   48.70   770
232
  24.00   -84.49   48.71   563
233
  30.00   -87.89   43.32   377
234
  36.00   -80.69   37.24   396
235
  42.00   -73.05   39.00   477
236
  48.00   -67.62   47.21   488
237
  54.00   -63.53   54.61   455
238
  60.00   -53.79   58.53   447
239
  66.00   -38.79   59.08   452
240
  72.00   -27.72   55.51   493
241
\end{verbatim}
242
 
243
\noindent
244
In total, 99 trajectories are selected. Further Lagrangian selection criteria might be reasonable. For instance, it could be of interest whether the air parcels are far away from their initial position after 48 h:
245
 
246
\begin{verbatim}
247
> select traj.4 wcb.1 'GT:p:700:FIRST & LT:p(MIN):400:0 to 48 & GT:DIST0:5000:48'
248
\end{verbatim}
249
 
250
\noindent
251
The last criterion test whether the spherical distance from the initial position exceeds 5000 km at 48 h (only met by 4 trajectories). Note that the field {\em DIST0} is not available on the trajectory file {\em traj.4}, but is implicitely calculated. \\
252
 
253
\noindent
254
Similarly, it can be tested whether a trajectory passes through a target region (e.g. 20E-30E,50N-60N). Such a region might be defined in the region file {\em regionf}:
255
 
256
\begin{verbatim}
257
> more regionf 
258
# Starting positions
259
"1 -80  20 40 80"
260
# Target region
261
"2 20 30 50 60"
262
\end{verbatim}
263
 
264
\noindent
265
The call to {\em select} now looks as follows:
266
 
267
\begin{verbatim}
268
> select traj.4 wcb.1 'GT:p:700:FIRST & LT:p(MIN):400:0 to 48 & ...
269
                       ... TRUE:INREGION:2:42 to 54(ANY)'
270
\end{verbatim}
271
 
272
\noindent
273
The last criterion is interpreted in the following way: consider the times from 42 h to 48 h (42 to 54) and check whether a trajectory is at any of these times (ANY) in the traget region 2, as specified in {\em regionf}. A sample trajectory is given below:
274
 
275
\begin{verbatim}
276
> more wcb.1
277
Reference date 19891020_0000 / Time range    4320 min
278
 
279
  time      lon     lat     p
280
-----------------------------
281
 
282
   0.00   -44.56   40.45   914
283
   6.00   -41.22   38.95   885
284
  12.00   -37.50   37.59   849
285
  18.00   -33.54   36.76   823
286
  24.00   -29.45   36.45   770
287
  30.00   -24.56   37.44   622
288
  36.00   -18.89   41.17   429
289
  42.00   -10.48   49.48   349
290
  48.00     8.75   57.02   355
291
  54.00    28.74   56.97   354
292
  60.00    37.14   53.71   320
293
  66.00    38.99   49.75   334
294
  72.00    37.57   45.94   349
295
\end{verbatim}
296
 
297
\section{Tracing Meteorological Fields}
298
 
299
Meteorological fields can be traced along the trajectories with the command {\em trace}. Most often, a list of fields to trace will be listed in a file {\em tracevars}:
300
 
301
\begin{verbatim}
302
> more tracevars 
303
PS    1.  0 P
304
Q  1000.  0 P
305
TH    1.  0 S
306
RH    1.  1 *
307
\end{verbatim}
308
 
309
\noindent
310
The following fields are to be traced: surface pressure (PS), specific humidity (Q), potential temperature (TH) and relative humidity (RH). PS and Q are available on the P files and need not to be calculated; Q will be scaled by a factor 1000 to convert from Kg/kg to g/kg. TH is found on the S file and need not to be calculated. Finally, RH is found neither on the P nor on the S file and must becomputed - the flag 1 in the third column.\\
311
 
312
\noindent
313
With the {\em tracevars} file ready, the tracing is started with:
314
 
315
\begin{verbatim}
316
> trace wcb.1 wcb.1
317
\end{verbatim}
318
 
319
\noindent
320
Note that the input and output file are allowed to have the same name. The following table shows the first few lines of the new trajectory file:
321
 
322
\begin{verbatim}
323
> more wcb.1 
324
Reference date 19891020_0000 / Time range    4320 min
325
 
326
  time      lon     lat     p        PS         Q        TH        RH
327
---------------------------------------------------------------------
328
 
329
   0.00   -44.56   40.45   914  1014.093     9.664   294.921    86.667
330
   6.00   -41.22   38.95   885  1012.965     8.380   296.549    77.992
331
  12.00   -37.50   37.59   849  1014.056     8.565   299.122    81.321
332
  18.00   -33.54   36.76   823  1012.074     8.720   300.798    85.407
333
  24.00   -29.45   36.45   770  1012.254     7.666   303.487    85.262
334
\end{verbatim}
335
 
336
\noindent
337
If it is later found that additional fields should be traced, this can be done with a new {\em tracevars} file or for a single field with (the second number being the scaling factor):
338
 
339
\begin{verbatim}
340
> trace wcb.1 wcb.1 -f PV 1.
341
\end{verbatim}
342
 
343
\noindent
344
Note that several fields are allowed for online computation, i.e. with the computation flag set in {\em tracevars}. This is convenient for interactive mode and for few trajectories. However, if tracing is needed for many trajectories, a pre-calculation and saving on the S files is much more efficient! A list of fields for online computation is found in the reference guide for {\em trace}. \\
345
 
346
\noindent
347
It is also possible to trace the surrounding of a trajectory position, i.e. to get for instance not the temperature at the air parcel's position, but at 50 hPa above or below it. This is done with:
348
 
349
\begin{verbatim}
350
> trace wcb.1 wcb.1 -f T:-50HPA 1.
351
> trace wcb.1 wcb.1 -f T:+50HPA 1.
352
\end{verbatim}
353
 
354
\noindent
355
Finally, if it is decided that a field is no longer needed in the trajectory file, or if it has to be corrected, it is possible to remove columns from the trajectory file. This can be achieved with {\em extract} - for instance if only PS, TH and RH should be kept:
356
 
357
\begin{verbatim}
358
> extract wcb.1 wcb.1 -var PS TH RH
359
\end{verbatim}
360
 
361
\noindent
362
Note that {\em extract} can also be used to extract different times or starting positions (see the reference documentation). 
363
 
364
 
365
\section{Final Selection of Trajectories}
366
 
367
In this section the selection of trajectories should be refined, i.e. it is not only based on positional information but also on further meteorological parameters. We look at several questions:\\
368
 
369
\begin{itemize}
370
\item[a)] Is there a trajectory which reaches saturation ($RH>99$\%)? The trajectories should be saved in a new trajectory file.
371
\begin{verbatim}
372
> select wcb.1 sat.1 'GT:RH:99:0 to 72(ANY)'
373
> more sat.1
374
Reference date 19891020_0000 / Time range    4320 min
375
 
376
  time      lon     lat     p        PS         Q        TH        RH        PV   
377
---------------------------------------------------------------------------------
378
   0.00   -72.98   40.45   918  1018.161     9.503   292.020   100.722     0.920    
379
   6.00   -76.45   43.14   879   986.319     8.723   294.933    92.837     1.101    
380
  12.00   -78.53   46.69   808   972.550     7.621   297.875    97.737     0.794    
381
  18.00   -80.08   48.70   770   973.957     6.147   297.914    97.912     1.078    
382
  24.00   -84.49   48.71   563   962.279     2.327   307.548    87.923     1.034    
383
  30.00   -87.89   43.32   377   977.415     0.319   314.210    65.759     0.108    
384
  36.00   -80.69   37.24   396   939.606     0.303   312.705    52.845     0.323    
385
  42.00   -73.05   39.00   477  1013.693     0.298   314.614    16.248     0.309    
386
  48.00   -67.62   47.21   488   970.025     0.442   312.975    23.890     0.463    
387
  54.00   -63.53   54.61   455   950.011     0.386   313.047    30.182     0.479    
388
  60.00   -53.79   58.53   447  1007.039     0.392   311.951    36.578     0.487    
389
  66.00   -38.79   59.08   452  1006.532     0.319   311.316    29.286     0.443    
390
  72.00   -27.72   55.51   493  1009.871     0.279   311.428    15.950     0.513    
391
\end{verbatim}
392
 
393
\item[b)] Get a list of all trajectories which pass through a circle around 20\,W/40\,N and radius 500\,km.
394
\begin{verbatim}
395
> select wcb.1 indlist 'TRUE:INCIRCLE:-20,40,500:ALL(ANY)' -index
396
> more indlist
397
            4
398
            5
399
            6
400
           11
401
           12
402
           13
403
           14
404
           19
405
           20
406
           21
407
           22
408
           47
409
\end{verbatim}
410
Hence, the trajectories 4,5,... pass through the circle. The trajectories themselves can be extracted in a second step with
411
\begin{verbatim}
412
> extract wcb.1 pass.1 -index indlist
413
\end{verbatim}
414
where now the selected trajectories are written to the trajectory file {\em pass.1}.
415
 
416
\item[c)] Select all trajectories which are in the stratosphere after 48 h. The dynamical tropopause is defined as the 2-PVU isosurface?
417
\begin{verbatim}
418
> select wcb.1 out 'GT:PV:2:48 to 72(ALL) & LT:P:500:48 to 72(ALL)' 
419
\end{verbatim}
420
The second criterion guarantees that the air parcel is at a height above 500 hPa; indeed, low-level high-PV regions might mimick a stratosphere, although they are of diabatic origin.  
421
 
422
\item[d)] Select all trajectories which are within 2000 km distance of their starting position after 72 h.
423
\begin{verbatim}
424
> select wcb.1 sel.1 'LT:DIST0:2000:LAST'
425
\end{verbatim}
426
Note that the fields {\em DIST0} needs not to be available on the trajectory file - it is calculated during the selection. {\em DIST0} refers to the spherical distance (in km) from the strting position. If the path length (in km) is needed, {\em DIST} can be used instead.
427
 
428
\item[e)] How many trajectories ascend more than 550 hPa between 12 h and 54 h? We are only interested in the number of selected trajectories.
429
\begin{verbatim}
430
> select wcb.1 count 'GT:P(DIFF):550:12,54' -count
431
> more count
432
3
433
\end{verbatim}
434
 
435
\item[f)] We would like to select all trajectories which reach potential vorticity (PV) greather than 2 PVU at levels above 500 hPa. In a first attempt, this might be accomplished with the criterion
436
\begin{verbatim}
437
> select wcb.1 wcb.1 'GT:PV:2:ALL(ANY) & LT:p:500:ALL(ANY)' 
438
\end{verbatim} 
439
But note that this is not exactly what we want - the first criterion might be fulfilled at a time 48 h, for instance, whereas the second criterion is fulfilled at another time, say 72 h. Hence they are not both fulfilled at the same time! A way around this problem is possible if a TRIGGER column is used to mark the two events. The original trajectory file looks as follows:
440
\begin{verbatim}
441
> more wcb.1
442
Reference date 19891020_0000 / Time range    4320 min
443
 
444
  time      lon     lat     p        PS          RH        PV
445
------------------------------------------------------------
446
 
447
   0.00   -19.56   46.94   905  1005.242     83.514     0.291
448
   6.00   -14.72   48.17   892   999.182     88.325     0.242
449
  12.00   -10.58   50.53   862   993.145     97.718     0.293
450
  18.00    -7.22   53.02   792   972.076     99.216     0.738
451
  24.00    -3.71   55.89   724   956.135     93.218     1.076
452
  30.00    -0.19   58.87   629   971.334     70.088     1.076
453
  36.00     1.46   61.62   452   966.406     66.056     0.558
454
  42.00     0.01   62.49   328   977.209     65.319     1.754
455
  48.00    -1.54   63.41   313   983.930     56.822     2.727
456
  54.00    -3.59   64.77   322   984.627     58.328     1.874
457
  60.00    -9.91   66.07   323   988.185     57.894     2.052
458
  66.00   -20.91   66.02   316   976.560     57.989     2.565
459
  72.00   -28.89   66.19   319  1007.175     54.477     2.693
460
\end{verbatim}
461
Then we mark the two events with a TRIGGER:
462
\begin{verbatim}
463
> select wcb.1 wcb.1 'GT:PV:2:1(TRIGGER) & LT:p:500:2(TRIGGER)' -trigger
464
\end{verbatim}
465
The first criterion (PV) gets the trigger 1 (in binary system 01), the second one (pressure) get the trigger 2 (in binary system 10). If both criteria are fulfilled, the trigger column becomes 3, which corresponds in the binary system to 11 - i.e. each flag corresponds to a bit in the trigger value. With the option '-trigger' the trigger column is written to the output trajectory file:
466
\begin{verbatim}
467
> more wcb.1
468
Reference date 19891020_0000 / Time range    4320 min
469
 
470
  time      lon     lat     p        PS         RH        PV     TRIGGER
471
-------------------------------------------------------------------------
472
 
473
   0.00   -19.56   46.94   905  1005.242    83.514     0.291      0.000
474
   6.00   -14.72   48.17   892   999.182    88.325     0.242      0.000
475
  12.00   -10.58   50.53   862   993.145    97.718     0.293      0.000
476
  18.00    -7.22   53.02   792   972.076    99.216     0.738      0.000
477
  24.00    -3.71   55.89   724   956.135    93.218     1.076      0.000
478
  30.00    -0.19   58.87   629   971.334    70.088     1.076      0.000
479
  36.00     1.46   61.62   452   966.406    66.056     0.558      2.000
480
  42.00     0.01   62.49   328   977.200    65.319     1.754      2.000
481
  48.00    -1.54   63.41   313   983.930    56.822     2.727      3.000
482
  54.00    -3.59   64.77   322   984.627    58.328     1.874      2.000
483
  60.00    -9.91   66.07   323   988.185    57.894     2.052      3.000
484
  66.00   -20.91   66.02   316   976.560    57.989     2.565      3.000
485
  72.00   -28.89   66.19   319  1007.175    54.477     2.693      3.000
486
\end{verbatim}
487
Now the selection can be achieved by refering to the TRIGGER column:
488
\begin{verbatim}
489
> select wcb.1 wcb.1 'ALL:TRIGGER:1,2:ALL(ANY)'
490
\end{verbatim}
491
This selection means that the trigger values 1 and 2 must be set - the operator ALL (first term) guaranteeing that all selected triggers are set. The time specification ALL(ANY) is as before, i.e. the check is performed for all times and he criterion must be fulfilled at any of these times.\\
492
 
493
\item[g)] Select all trajectories which pass at time 60 h over Switzerland! The coordinates of the Swiss boundary are listed in a file {\em borders.dat}:
494
\begin{verbatim}
495
> more borders.dat
496
8.55 47.45
497
7.942863 46.002075
498
7.949024 46.001195
499
7.956945 46.000022
500
7.984226 46.000022
501
7.989800 46.001489
502
8.000068 46.007356
503
8.011508 46.018503
504
...
505
\end{verbatim}
506
The first line is a point (longitude, latitude) within Switzerland (Zurich), the other lines define the boundary of Switzerland (as 1373 points). With this polygon file, the selection command becomes
507
\begin{verbatim}
508
> select wcb.1 out.1 'TRUE:INPOLYGON:borders.dat:60'
509
\end{verbatim} 
510
Note that in a criterion only one polygon can be specified.
511
 
512
\item[g)] New criteria can easily be implemented into the Fortran code; to this aim the file {\em special.f} in directory {\em select} must be edited. The following example shows the implementation of an identification for warm conveyor belts (WCB). The calling sequence for the criterion is {\em SPECIAL:WCB:ascent,first,last}, the air stream must ascend at least {\em ascent} hPa between time {\em first} and time {\em last}. The corresponding Fortran looks as follows:
513
\begin{small}
514
\begin{verbatim}
515
> more select/special.f
516
 
517
      SUBROUTINE special (flag,cmd,tra,ntim,ncol,
518
     >                    vars,times,param,nparam)
519
 
520
c     ***************************************************************************
521
c     *                                                                         *
522
c     * OUTPUT:  flag           -> 1 if trajectory is selected, 0 if not        *
523
c     *                                                                         *
524
c     * INPUT:   cmd            <- command string (e.g. WCB)                    *
525
c     *          tra(ntim,ncol) <- single trajectory: indices time,column       *
526
c     *          ntim           <- number of times                              *
527
c     *          ncol           <- number of columns (including time,lon,lat,p) *
528
c     *          vars(ncol)     <- names of columns                             *
529
c     *          times(ntim)    <- List of times
530
c     *          param(nparam)  <- parameter values                             *
531
c     *          nparam         <- number of parameters                         *
532
c     *                                                                         *
533
c     ***************************************************************************
534
 
535
      implicit none
536
 
537
c     ---------------------------------------------------------------------------
538
c     Declaration of subroutine parameters
539
c     ---------------------------------------------------------------------------
540
 
541
      integer       flag           ! Boolean flag whether trajectory is selected
542
      character*80  cmd            ! Command string
543
      integer       ntim,ncol      ! Dimension of single trajectory
544
      real          tra(ntim,ncol) ! Single trajectory
545
      character*80  vars(ncol)     ! Name of columns
546
      real          times(ntim)    ! List of times
547
      integer       nparam         ! # parameters
548
      real          param(nparam)  ! List of parameters
549
 
550
c     ---------------------------------------------------------------------------
551
c     Declaration of local variables
552
c     ---------------------------------------------------------------------------
553
 
554
      integer       i
555
      integer       ip,i0,i1
556
 
557
c     --------------------------------------------------------------------------  %)
558
c     SPECIAL:WCB:ascent,first,last                                               %)
559
c         : Detect Warm Conveyor Belts (WCB); the air stream must ascend at least %)
560
c         : <ascent=param(1)> hPa between the two times <first=param(2)> and      %)
561
c         : <last=param(3)>. Note, the lowest pressure is allowed to occur at any %)
562
c         : time between <first> and <last>.                                      %)
563
c     --------------------------------------------------------------------------- %)
564
 
565
      if ( cmd.eq.'WCB' ) then
566
 
567
c        Reset the flag for selection
568
         flag = 0
569
 
570
c        Pressure is in the 4th column
571
         ip = 4
572
 
573
c        Get indices for times <first> and <last>
574
         i0 = 0
575
         i1 = 0
576
         do i=1,ntim
577
            if ( param(2).eq.times(i) ) i0 = i
578
            if ( param(3).eq.times(i) ) i1 = i
579
         enddo
580
         if ( (i0.eq.0).or.(i1.eq.0) ) then
581
            print*,' ERROR: invalid times in SPECIAL:WCB... Stop'
582
            stop
583
         endif
584
 
585
c        Check for ascent 
586
         do i=i0+1,i1
587
            if ( ( tra(1,ip)-tra(i,ip) ) .gt. param(1) ) flag = 1
588
         enddo
589
 
590
      endif
591
 
592
c     ---------------------------------------------------------------------------
593
 
594
      end
595
\end{verbatim}
596
\end{small}
597
 
598
\end{itemize}
599
 
600
\section{Trajectory Densities}
601
Single trajectories can be visualised e.g. with Matlab or wit NCL (see template scripts in the Lagranto folder). If many trajectories should be visualised instead, it is much more convenient to show trajectory densities. The easiiest way to get trajectory densities is:
602
\begin{verbatim}
603
> density wcb.1 densisty
604
> ncview density 
605
\end{verbatim}
606
This will project the trajectories in the trajectory file {\em wcb.1} onto a global longitude/latitude grid with 1 degree horizontal resolution. A filter radius of 100 km will be used
607
 
608
\includegraphics[width=0.9\textwidth]{screen1.ps}
609
 
610
\noindent
611
The CF-netCDF file contains several fields: a) the number of trajectory points associated to each grid point (COUNT); b) the residence time of the trajectories (in hours) associated to each grid point - the residence time being the time a trajectory stays at a certain grid cell (RESIDENCE); c) the area (im $km^2$) associated with each grid cell. The area allows to change the unit of the gridded trajectory from counts per grid point to counts per $km^2$.\\
612
 
613
\noindent
614
Often the trajectories do not spread over the whole globe; then the subdomain can be specified with
615
\begin{verbatim}
616
> density traj.1 density -latlon 300 150 -100 10 0.5 0.5 -create
617
\end{verbatim}
618
where the new grid has 300x150 grid points in zonal and meridional direction with south-eastern corner at 100\,W/10\,S and resolution of 0.5 degree in zonal and 0.5 degree in meridional direction. The flag {\em create} forces the netCDF file to be created anew, even if it already exists.
619
 
620
\includegraphics[width=0.9\textwidth]{screen2.ps}
621
 
622
\noindent
623
It is also possible to re-parameterise the trajectories before they are gridded. For instance, the following command interpolates the positions to a 1-h time interval and then performs the grissing. This results in a smoother density plot:
624
\begin{verbatim}
625
> density traj.1 density -latlon 300 150 -100 10 0.5 0.5 -create -interp 1 h
626
\end{verbatim}
627
 
628
\includegraphics[width=0.9\textwidth]{screen3.ps}
629
 
630
\noindent
631
In addition to a gridding of the complete trajectories, the single trajectory times can be gridded. 
632
\begin{verbatim}
633
> density traj.1 density -create -time  0.00 -create
634
> density traj.1 density -create -time  6.00 
635
> density traj.1 density -create -time 12.00 
636
> density traj.1 density -create -time 18.00 
637
> density traj.1 density -create -time 24.00 
638
\end{verbatim}
639
 
640
\noindent
641
In the previous figures, the density of the trajectories was determined - i.e. the number of trajectories associated with a grid point or the residence associated with a grid cell was determined. In addition to this most basic information, it is also possible to perform a gridding of any trajectory field. For instance, the trajectory file contains
642
 
643
\begin{verbatim}
644
Reference date 19891020_0000 / Time range    4320 min
645
 
646
  time      lon     lat     p
647
-----------------------------
648
 
649
   0.00   -79.61   40.45   862
650
   6.00   -80.57   43.23   791
651
  12.00   -82.23   45.89   782
652
  18.00   -84.94   47.07   744
653
\end{verbatim}
654
 
655
\noindent
656
and we would like to know at what height the trajectories typically (in the mean) are at a specific grid point. Then we would grid the pressure ``p'' instead of the position:
657
 
658
\begin{verbatim}
659
> density traj.1 density -create -latlon 300 150 -100 10 0.5 0.5 -field p -time 0.00
660
> density traj.1 density  -field p -time 24.00
661
> density traj.1 density  -field p -time 48.00
662
\end{verbatim}
663
 
664
\noindent
665
The following figures show the gridded pressure at time 0.00 and 24.00 h; note that the trajectories were initialised 100 hPa above ground.
666
 
667
\noindent
668
\begin{center}
669
\includegraphics[width=0.8\textwidth]{screen4.ps}
670
\\
671
\includegraphics[width=0.8\textwidth]{screen5.ps}
672
\end{center}
673
 
674
\section{Interface Script}
675
 
676
\subsection{Start from local directory}
677
 
678
In addition to the programs {\em create\_startf}, {\em caltra}, {\em trace}, {\em select}, Lagranto offers a ``master'' script which combines the call to the individual programs into one single call. For instance,
679
\begin{verbatim}
680
> lagranto local 19891020_00 19891024_18 startf nil -changet
681
\end{verbatim}
682
will start a Lagranto run starting from 00,UTC 20 Octiober 2010 to  18,UTC 24 Octiober 2010, based upon the starting positions in the file {\em startf}. No selection of trajectories is applied, as specified with the flag {\em nil}, and the times on the netCDF P and S files are set relative to the starting date prior  to the Lagranto run. Finally, {\em local} means that all input files are expected in the directory where Lagranto was called.\\
683
 
684
\noindent
685
The output for the above Lagranto call is saved in a newly created directory, which is located in the calling directory:
686
\begin{verbatim}
687
> ls -l ntr_19891020_00_f114_local_startf_nil/
688
-rw-r--r-- 1 michaesp wheel 5328945 2011-03-21 14:03 lsl_19891020_00
689
-rw-r--r-- 1 michaesp wheel   68195 2011-03-21 14:03 runscript.logfile
690
-rwxr--r-- 1 michaesp wheel    1025 2011-03-21 14:02 runscript.sh*
691
\end{verbatim}
692
The three different files are:
693
\begin{itemize}
694
\item[a)]  {\bf lsl\_19891020\_00}: the output trajectory file -the file name starts with {\em lsl} and contains the starting date of the Lagranto run:
695
\begin{verbatim}
696
> more lsl_19891020_00
697
Reference date 19891020_0000 / Time range    6840 min
698
 
699
  time      lon     lat     p        PS         Q        TH        RH
700
---------------------------------------------------------------------
701
 
702
   0.00   -79.61   40.45   862   961.659     6.434   290.838    97.722
703
   6.00   -80.57   43.23   791   980.984     5.334   293.824    98.773
704
   ...
705
\end{verbatim}
706
Note that additional fields have been traced along the trajectories, as specified in the tracing file {\em tracevars}:
707
\begin{verbatim}
708
> more tracevars
709
PS    1.  0 P
710
Q  1000.  0 P
711
TH    1.  0 S
712
RH    1.  1 *
713
\end{verbatim}
714
\item[b)] {\bf runscript.logfile}: a log file with all status and error information of the Lagranto run. If the flag {\em -log} is set in a Lagranto call, the log will be written to screen.
715
\item[c)] {\bf runscript.sh}: the calling script for the programs {\em create\_startf}, {\em caltra}, {\em trace} and {\em select}. The basic idea of {\em lagranto} is to create the output directory, to prepare all netCDF and other files in this output directory and to create a Shell script with name {\em runscript.sh}. If all these preparations were successfull, Lagranto will change into the output directory and launch {\em runscript.sh}. The {\em runscript.sh} for the previous Lagranto call looks as follows:
716
\begin{small}
717
\begin{verbatim}
718
#!/bin/csh
719
#
720
#----- Calling command
721
#
722
# lagranto local 19891020_00 19891024_18 startf nil -changet -log 
723
#
724
#----- Output file    
725
#
726
# lsl_19891020_00                
727
#
728
#------ Abort if no startf is available
729
#
730
if ( ! -f startf ) then
731
  echo " ERROR: no start file available .... Stop"
732
  exit 1
733
endif
734
#
735
#------ Remove existing trajectory files
736
#
737
if ( -f lsl_19891020_00.4 ) then
738
  \rm -f lsl_19891020_00.4
739
endif
740
if ( -f lsl_19891020_00 ) then
741
  \rm -f lsl_19891020_00
742
endif
743
#
744
#------ Run <caltra>
745
#
746
/home/sprenger/lagranto//bin/caltra.sh 19891020_00 19891024_18 startf lsl_19891020_00.4
747
#
748
#------ Abort if caltra was not successful
749
#
750
if ( ! -f lsl_19891020_00.4 ) then
751
  echo " ERROR: caltra failed .... Stop"
752
  exit 1
753
endif
754
#
755
#------ Run <trace>
756
#
757
/home/sprenger/lagranto//bin/trace.sh lsl_19891020_00.4 lsl_19891020_00 -v tracevars
758
#
759
#------ Abort if trace was not successful
760
#
761
if ( ! -f lsl_19891020_00 ) then
762
  echo " ERROR: trace failed .... Stop"
763
  exit 1
764
endif
765
\end{verbatim}
766
\end{small}
767
\end{itemize}
768
 
769
\noindent
770
Note that you are free to change to the output directory and manually launch {\em runscript.sh}, possibly after having modified it to your needs. This way of working is uspported by the optional flag {\em -prep} which will only prepare all files and then changes to the output directory:
771
\begin{verbatim}
772
> lagranto local 19891020_00 19891024_18 startf nil -changet -prep
773
\end{verbatim}
774
At the end of this call you will be asked to change to the output directory, which -after having agreed- will open a new {\em xterm} window. Note that you can always easily change to a output directory by calling
775
\begin{verbatim}
776
> lagranto -open local 
777
\end{verbatim}
778
If several trajectory runs are available in the local directory, you are asked to select one. Often, you would like to see the outcome of a run without changing to the output directory. This is most easily accomplished with the following call:
779
\begin{verbatim}
780
> lagranto -show local 
781
\end{verbatim}
782
 
783
\subsection{Start from case directory}
784
 
785
In this calling sequence, for instance
786
\begin{verbatim}
787
> lagranto tutorial 19891020_00 19891024_18 startf nil -changet
788
\end{verbatim}
789
the input files are not expected in the local directory, but are specified by means of a case identifier. For instance, a case has the identifier {\em tutorial}. Then Lagranto will expect the input netCDF P and S files to be located in
790
\begin{verbatim}
791
> ls -l ${HOME}/cdf/tutorial
792
/home/sprenger/cdf/tutorial/P19891020_00
793
/home/sprenger/cdf/tutorial/P19891020_06
794
/home/sprenger/cdf/tutorial/P19891020_12
795
/home/sprenger/cdf/tutorial/P19891020_18
796
/home/sprenger/cdf/tutorial/P19891021_00
797
/home/sprenger/cdf/tutorial/P19891021_06
798
/home/sprenger/cdf/tutorial/P19891021_12
799
/hom
800
\end{verbatim}
801
and all the other input files (starting positions, tracing file, region file, polygon specification) are expected in 
802
\begin{verbatim}
803
> ls -l ${HOME}/tra/tutorial
804
startf
805
tracevars
806
\end{verbatim}
807
The output of the trajectory calculation will be written to the following output directory, where now the case identifier {\em tutorial} is part of the directory name:
808
\begin{verbatim}
809
> cd /home/michaesp/tra/tutorial/ntr_19891020_00_f114_tutorial_startf_nil
810
> ls -1
811
-rw-r--r-- 1 michaesp wheel 5328945 2011-03-21 14:03 lsl_19891020_00
812
-rw-r--r-- 1 michaesp wheel   68195 2011-03-21 14:03 runscript.logfile
813
-rwxr--r-- 1 michaesp wheel    1025 2011-03-21 14:02 runscript.sh*
814
\end{verbatim}
815
All other aspects are identical to the ones described in the previous section. 
816
 
817
 
818
\section{Installation}
819
 
820
In this section you will find some hints how to install Lagranto on a Linux platform. Everthing is handled with the installation script {\em install.sh} which comes with the Lagranto distribution:
821
\begin{verbatim}
822
> install.csh 
823
install.sh [lib|core|goodies|links|all]
824
\end{verbatim}
825
The installation should proceed in several distinct steps:
826
\begin{itemize}
827
\item[a)] Find the place of the netCDF (http://www.unidata.ucar.edu/software/netcdf/) installation on your system - note that the netCDF comes as a pre-compiled package for many Linux distributions and most often can be installed with the Linux software management. Define an environmental variable {\em NETCDF} which directs to your installation, e.g.
828
\begin{verbatim}
829
> setenv NETCDF /usr/local/netcdf/
830
\end{verbatim}
831
\item[b)] Set the environmental variable {\em LAGRANTO} to the place where you have stored the Lagranto source code and include Lagranto in your search path. In {\em csh} this might look as follows:
832
\begin{verbatim}
833
> setenv LAGRANTO   /home/michaesp/lagranto/
834
> set isLAGRANTO=`echo $PATH | grep $LAGRANTO | wc -l`
835
> if ( $isLAGRANTO == 0 ) then
836
>   setenv PATH $LAGRANTO/bin:${PATH}
837
> endif
838
\end{verbatim}
839
You might include these statements also in your {\em .cshrc} file. If successful, you will then be able to open the lagranto help, e.g. with
840
\begin{verbatim}
841
> lagrantohelp
842
\end{verbatim} 
843
\item[c)] Install the different components of Lagranto and create links - proceed step by step to ensure that each one was successfully completed:
844
\begin{verbatim}
845
> install lib
846
> install core
847
> install goodies
848
> install links
849
\end{verbatim} 
850
\end{itemize}
851
Lagranto should now be ready to run! As a next step you might want to consider the tutorial, which can be invoked with the command:
852
\begin{verbatim}
853
> lagrantohelp tutorial
854
\end{verbatim}
855
If you are familiar with the most basic aspects of Lagranto, please refer to the reference guide which enlists all options of Lagranto:
856
\begin{verbatim}
857
> lagrantohelp refernce
858
\end{verbatim}
859
The contents of the reference guide can also be called from within the Linux shell, e.g. the documentation of {\em caltra} can be seen in man page format with:
860
\begin{verbatim}
861
> lagrantohelp caltra 
862
\end{verbatim}
863
 
864
\end{document}