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_shell_functions.sh.rst 6.1 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
  1. .. index:: ! gmt_shell_functions.sh
  2. **********************
  3. gmt_shell_functions.sh
  4. **********************
  5. .. only:: not man
  6. gmt_shell_functions.sh - Practical functions to be used in GMT Bourne Again shell scripts
  7. Synopsis
  8. --------
  9. **gmt_init_tmpdir**
  10. **gmt_remove_tmpdir**
  11. **gmt_clean_up** [ *prefix* ]
  12. **gmt_message** *message*
  13. **gmt_abort** *message*
  14. **gmt_build_movie** [ **-d** *directory* ] [ **-n** ] [ **-r** *framerate* ] [ **-v** ] *namestem*
  15. **gmt_build_gif** [ **-d** *directory* ] [ **-l** *loop* ] [ **-r** *delay* ] *namestem*
  16. **gmt_build_kmz** **-p** *prefix* [ **-r** ] *files*
  17. **gmt_get_nrecords** *file(s)*
  18. **gmt_get_ndatarecords** *file(s)*
  19. **gmt_get_nfields** *string*
  20. **gmt_get_field** *string*
  21. **gmt_get_region** *file(s)* [ *options* ]
  22. **gmt_get_gridregion** *file* [ *options* ]
  23. **gmt_get_map_width** **-R** **-J**
  24. **gmt_get_map_height** **-R** **-J**
  25. **gmt_movie_script** [ **-c** *canvas* OR **-e** *dpi* **-h** *height* **-w** *width* ] [ **-f** *format* ]
  26. [ **-g** *fill* ] [ **-n** *frames* ] [ **-m** *margin* ] [ **-r** *rate* ] *namestem*
  27. **gmt_launch_jobs** [ **-c** *n_cores* ] [ **-l** *nlines_per_cluster* ] [ **-n** ] [ **-v** ] [ **-w** ] *commandfile*
  28. **gmt_set_psfile** *scriptfile*
  29. **gmt_set_pdffile** *scriptfile*
  30. **gmt_set_framename** *prefix framenumber*
  31. **gmt_set_framenext** *framenumber*
  32. Description
  33. -----------
  34. **gmt_shell_functions.sh** provides a set of functions to Bourne
  35. (again) shell scripts in support of GMT. The calling shell script
  36. should include the following line, before the functions can be used:
  37. **. gmt_shell_functions.sh**
  38. Once included in a shell script, **gmt_shell_functions.sh** allows
  39. GMT users to do some scripting more easily than otherwise. The
  40. functions made available are:
  41. **gmt_init_tmpdir**
  42. Creates a temporary directory in **/tmp** or (when defined) in the
  43. directory specified by the environment variable **TMPDIR**. The name
  44. of the temporary directory is returned as environment variable
  45. **GMT_TMPDIR**. This function also causes GMT to run in
  46. 'isolation mode', i.e., all temporary files will be created in
  47. **GMT_TMPDIR** and the :doc:`gmt.conf` file will not be adjusted.
  48. **gmt_remove_tmpdir**
  49. Removes the temporary directory and unsets the **GMT_TMPDIR**
  50. environment variable.
  51. **gmt_cleanup**
  52. Remove all files and directories in which the current process number
  53. is part of the file name. If the optional *prefix* is given then we
  54. also delete all files and directories that begins with the given prefix.
  55. **gmt_message**
  56. Send a message to standard error.
  57. **gmt_abort**
  58. Send a message to standard error and exit the shell.
  59. **gmt_get_nrecords**
  60. Returns the total number of lines in *file(s)*
  61. **gmt_get_ndatarecords**
  62. Returns the total number of data records in *file(s)*, i.e., not counting headers.
  63. **gmt_get_nfields**
  64. Returns the number of fields or words in *string*
  65. **gmt_get_field**
  66. Returns the given *field* in a *string*. Must pass *string* between
  67. double quotes to preserve it as one item.
  68. **gmt_get_region**
  69. Returns the region in the form w/e/s/n based on the data in table
  70. *file(s)*. Optionally add **-I**\ *dx*/\ *dy* to round off the answer.
  71. **gmt_get_gridregion**
  72. Returns the region in the form w/e/s/n based on the header of a grid
  73. *file*. Optionally add **-I**\ *dx*/\ *dy* to round off the answer.
  74. **gmt_get_map_width**
  75. Expects the user to give the desired **-R** **-J** settings and
  76. returns the map width in the current measurement unit.
  77. **gmt_get_map_height**
  78. Expects the user to give the desired **-R** **-J** settings and
  79. returns the map height in the current measurement unit.
  80. **gmt_movie_script**
  81. Creates an animation bash script template based on the arguments
  82. that set size, number of frames, video format etc.
  83. Without arguments the function will display its usage.
  84. **gmt_launch_jobs**
  85. Takes a file with a long list of commands and splits them into
  86. many chunks that can be executed concurrently. Without arguments
  87. the function will display its usage. **Note**: It is your responsibility
  88. to make sure no race conditions occur (i.e., multiple commands
  89. writing to the same file).
  90. **gmt_set_psfile**
  91. Create the output PostScript file name based on the base name of a
  92. given file (usually the script name **$0**).
  93. **gmt_set_framename**
  94. Returns a lexically ordered filename stem (i.e., no extension) given
  95. the file prefix and the current frame number, using a width of 6 for
  96. the integer including leading zeros. Useful when creating animations
  97. and lexically sorted filenames are required.
  98. **gmt_set_framenext**
  99. Accepts the current frame integer counter and returns the next
  100. integer counter.
  101. **gmt_build_movie**
  102. Accepts a *namestem* which gives the prefix of a series of image files
  103. with names *dir*/*namestem*\ _*.*. Optional argument sets the
  104. directory [same as *namestem* ], and frame rate [24].
  105. Without arguments the function will display its usage.
  106. **gmt_build_gif**
  107. Accepts a *namestem* which gives the prefix of a series of image files
  108. with names *dir*/*namestem*\ _*.*. Optional argument sets the
  109. directory [same as *namestem*], loop count and frame rate [24].
  110. Without arguments the function will display its usage.
  111. **gmt_build_kmz**
  112. Accepts **-p** *prefix* [ **-r** ] and any number of KML files and
  113. and the images they may refer to, and builds a single KMZ file with
  114. the name *prefix*.kmz.
  115. Without arguments the function will display its usage.
  116. Notes
  117. -----
  118. 1. These functions only work in the Bourne shell (**sh**) and their
  119. derivatives (like **ash**, **bash**, **ksh** and **zsh**). These
  120. functions do not work in the C shell (**csh**) or their derivatives
  121. (like **tcsh**), and cannot be used in DOS batch scripts either.
  122. 2. **gmt_shell_functions.sh** were first introduced in GMT version
  123. 4.2.2 and have since been regularly expanded with other practical
  124. scripting short-cuts. If you want to suggest other functions, please do
  125. so by adding a New Issue request on https://github.com/GenericMappingTools/gmt.
  126. See Also
  127. --------
  128. :doc:`gmt` , :doc:`gmt.conf` ,
  129. :doc:`gmtinfo` , :doc:`grdinfo`
Tip!

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

Comments

Loading...