Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

GMT_Chapter_8.tex 10 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  1. %------------------------------------------
  2. % $Id$
  3. %
  4. % The GMT Documentation Project
  5. % Copyright (c) 2000-2012.
  6. % P. Wessel, W. H. F. Smith, R. Scharroo, and J. Luis
  7. %------------------------------------------
  8. %
  9. \chapter{Creating GMT Animations}
  10. \label{ch:8}
  11. \thispagestyle{headings}
  12. Unlike the previous chapter, in this chapter we will explore
  13. what is involved in creating animations (i.e., movies). Of course,
  14. an animation is nothing more than a series of individual images
  15. played back in an orderly fashion. Here, these images will have
  16. been created with \GMT. To ensure a smooth transition from frame
  17. to frame we will be following some general guidelines when writing
  18. our scripts. Since there is no ``movie'' mode in \GMT\ we must take
  19. care of all the book-keeping in our script. Thus, animations may
  20. require a bit of planning and may use more advanced scripting than the
  21. previous static examples. Note: This is a new chapter introduced with the
  22. 4.4.0 version and should be considered work in progress.
  23. Most, if not all, animation scripts must deal with several specific
  24. phases of movie making:
  25. \begin{enumerate}
  26. \item Define parameters that determine the dimension of the final movie.
  27. \item Pre-calculate all variables, data tables, grids, or background
  28. map layers that are \emph{independent} of your time variable.
  29. \item Have a frame-number loop where each frame is created as a \PS\ plot,
  30. then rasterized to a TIFF file of chosen dimension.
  31. \item Convert the individual frames to a single movie of suitable format.
  32. \item Clean up temporary files and eventually the individual frames.
  33. \end{enumerate}
  34. We will discuss these phases in more detail before showing our first example.
  35. % changes the format used by the counter:
  36. \let\oldenumi\labelenumi
  37. \renewcommand{\labelenumi}{\textbf{\arabic{enumi}.}}
  38. \begin{enumerate}
  39. \item There are several coordinates that you need to consider when planning
  40. your movie. The first is the coordinates of your data, i.e., the \emph{user
  41. coordinates}. As with all \GMT\ plots you will transform those to the
  42. second set of \emph{plot coordinates}
  43. in inches (or cm) by applying a suitable region and map projection. As
  44. before, you normally do this with a particular paper size in mind. When
  45. printed you get a high-resolution plot in monochrome or color.
  46. However, movies are not device-independent and you must finally consider
  47. the third set of \emph{pixel coordinates} which specifies the resolution of the final movie.
  48. We control the frame size by selecting a suitable \emph{dpi} setting that
  49. will scale your physical dimensions to the desired frame size in pixels.
  50. If you decide up front on a particular resolution (e.g., 480 by 320 pixels)
  51. then you should specify a paper size and \emph{dpi} so that their product yields the desired pixel dimensions.
  52. For instance, here it might make sense to plan your plotting on a 4.8 by 3.2 inch ``paper''
  53. and use 100 \emph{dpi} to convert it to pixels, but you are free to use any combination
  54. that multiplies to the desired dimensions. After deciding on frame size you need
  55. to consider how many frames your movie should have. This depends on lots of things
  56. such as how patient you are, how many frames per second you need and the time
  57. range of your animation. We recommend you use variables to specify the items that
  58. go into computing the number of frames so that you can easily test your script
  59. with a few frames before changing settings and running the full Hollywood production overnight.
  60. \item Depending on what you want to display, there are usually many elements that
  61. do not change between frames. Examples include a coastline base map for background,
  62. an overlay of text legends, perhaps some variables that hold information that will
  63. be used during the movie, and possibly subsets of larger data sets. Since movie-making
  64. can take a long time if you are ambitious, it is best to compute or plot all the
  65. elements that can be done outside your main frame-loop rather than waste time
  66. doing the same thing over and over again. You are then ready for the main loop.
  67. \item Initialize a frame counter to 0 and have a loop that continues until
  68. your frame counter equals the desired number of frames. You must use your frame
  69. counter to create a unique file name for each frame image so that the series of
  70. images can be lexically arranged. We recommend using the \GMT\ shell function
  71. \progname{gmt\_set\_framename} to format the frame counter
  72. with an adequate number of leading zeros; see our examples for details. The
  73. bulk of your main loop involves create the single \PS\ plot for this particular
  74. frame (time). This can be trivial or a serious scripting exercise depending on
  75. what you want to show. We will give a few examples with increasing complexity.
  76. Once the \PS\ plot is created you need to rasterize it; we recommend you use
  77. \GMTprog{ps2raster} to generate a TIFF image at the agreed-upon resolution.
  78. We also recommend that you place all frame images in a sub-directory. You may increment
  79. your frame counter using \progname{gmt\_set\_framenext}.
  80. \item Once you have all your frames you are ready to combine them into an animation.
  81. There are two general approaches. (a) If your image sequence is not too long then
  82. you can convert the images into a single animated GIF file. This file can be
  83. included in PowerPoint presentations or placed on a web page and will play back
  84. as a movie by pausing the specified amount between frames, optionally repeating
  85. the entire sequence one or more times. (b) For more elaborate projects
  86. you will need to convert the frames into a proper movie format such as Quicktime,
  87. AVI, MPEG-2, MPEG-4, etc., etc. There are both free and commercial tools that
  88. can help with this conversion and they tend to be platform-specific. Most movie
  89. tools such as iMovie or MovieMaker can ingest still images and let you specify
  90. the frame duration. Under OS X we prefer to use Quicktime.\footnote{While Quicktime
  91. is free you must upgrade to QuickTime Pro (USD 30) to use the authoring functions.} Free
  92. tools exist to call the Quicktime library functions from the command line as we
  93. prefer to do in our scripts. You will find yourself experimenting with compression
  94. settings and movie formats so that the final movie has the resolution and portability
  95. you require.
  96. \item Finally, when all is done you should delete any temporary files created.
  97. However, since creating the frames may take a lot of time it is best to not automatically
  98. delete the frame sub directory. That way you can
  99. redo the frames-to-movie conversion with different settings until you are satisfied.
  100. \end{enumerate}
  101. \renewcommand{\labelenumi}{\oldenumi} % reset the format used by the counter
  102. \section{Animation of the sine function}
  103. \index{Example!animation of the sine function|(}
  104. Our first animation is not very ambitious: We wish to plot the sine
  105. function from 0--360\DS\ and take snap shots every 20\DS. To get a
  106. smooth curve we must sample the function much more frequently; we
  107. settle on 10 times more frequently than the frame spacing. We place
  108. a bright red circle at the leading edge of the curve, and as we move
  109. forward in time (here, angles) we dim the older circles to a dark red
  110. color. We add a label that indicates the current angle value. Once
  111. the 18 frames are completed we convert them to a single animated GIF file
  112. and write a plain HTML wrapper with a simple legend. Opening the HTML
  113. page \filename{anim01.html} in the browser will display the animation.
  114. \script{anim_01}
  115. Make sure you understand the purpose of all the steps in our script.
  116. In this case we did some trial-and-error to determine the exact values
  117. to use for the map projection, the region, the spacing around the frame,
  118. etc. so that the final result gave a reasonable layout. Do this planning
  119. on a single \PS\ plot before running a lengthy animation script.
  120. \GMTanimation{01}{Animation of a simple sine function.}
  121. \index{Example!animation of the sine function|)}
  122. \section{Examining DEMs using variable illumination}
  123. \index{Example!examining DEMs using variable illumination|(}
  124. Our next animation uses a gridded topography for parts of Colorado (US);
  125. the file is distributed with the tutorial examples. Here, we want to
  126. use \GMTprog{grdimage} to generate a shaded-relief image sequence in
  127. which we sweep the illumination azimuth around the entire horizon. The
  128. resulting animation illustrates how changing the illumination azimuth
  129. can bring out subtle features (or artifacts) in the gridded data. The
  130. red arrow points in the direction of the illumination.
  131. \script{anim_02}
  132. As you can see, these sorts of animations are not terribly difficult to
  133. put together, especially since our vantage point is fixed. In the next
  134. example we will move the ``camera'' around and must therefore deal with
  135. how to frame perspective views.
  136. \GMTanimation{02}{Animation of a DEM using variable illumination.}
  137. \index{Example!examining DEMs using variable illumination|)}
  138. \section{Orbiting a static map}
  139. \index{Example!Orbiting a static map|(}
  140. Our third animation keeps a fixed gridded data set but moves the camera
  141. angle around the full 360\DS. We use \GMTprog{grdview} to generate a
  142. shaded-relief image sequence using the new enhanced \Opt{E} option.
  143. No additional information is plotted on the image. As before we produce
  144. an animated GIF image and a simple HTML wrapper for it.
  145. \script{anim_03}
  146. \GMTanimation{03}{Orbiting a static map.}
  147. \index{Example!Orbiting a static map|)}
  148. \section{Flying over topography}
  149. \index{Example!Flying over topography|(}
  150. Our next animation simulates what an imaginary satellite might see as it passes
  151. in a great circle from New York to Miami at an altitude of 160 km.
  152. We use the general perspective view projection with \GMTprog{grdimage} and
  153. use \GMTprog{project} to create a great circle path between the two cities,
  154. sampled every 5 km. The main part of the script will make the DVD-quality frames from
  155. different view points, draw the path on the ground, and add frame numbers to
  156. each frame. As this animation generates 355 frames we can use 3rd party tools
  157. to turn the image sequence into a MPEG-4 movie\footnote{QuickTime Pro can do this,
  158. as can most video-editing programs.}. Note: At the moment, \GMTprog{grdview} cannot
  159. use general perspective view projection to allow ``fly-through'' animations like
  160. Fledermaus; we expect to add this functionality in a future version.
  161. \script{anim_04}
  162. \GMTanimation{04}{Flying over topography.}
  163. \index{Example!Flying over topography|)}
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...