Debian Codegraph @

docs/basic.rst

raw
1 .. _sec:basic:
2
3 Basic splash usage
4 ==================
5
6 Simple two column plot
7 ----------------------
8
9 Once you have successfully compiled splash with a read data file that
10 will read your data format, splash is invoked with the name of the data
11 file(s) on the command line, e.g.
12
13 ::
14
15 splash myrun*.dat
16
17 | where splash should be replaced with `splash -f gadget`, `splash -f magma` etc.
18 depending on the data format.
19 | After a successful data read, the menu should appear as something like
20 the following (the example given is for a “minidump” from Stephan
21 Rosswog’s SPH code, MAGMA):
22
23 ::
24
25 dprice$ splash -magma minidump.00001
26
27 ::
28
29 _ _
30 (_) _ _ _ _ (_)_
31 _ (_) ___ _ __ | | __ _ ___| |__ (_) _ (_)
32 _ (_) _ / __| '_ \| |/ _` / __| '_ \ _ (_)
33 (_) _ (_) \__ \ |_) | | (_| \__ \ | | | _ (_) _
34 (_) _ |___/ .__/|_|\__,_|___/_| |_| (_) _ (_)
35 (_) (_)|_| (_) (_) (_)(_) (_)(_) (_)(_)
36
37 ( B | y ) ( D | a | n | i | e | l ) ( P | r | i | c | e )
38
39 ...etc...
40
41 ::
42
43 You may choose from a delectable sample of plots
44 -------------------------------------------------------
45 1) x 7) particle mass
46 2) y 8) B\dx
47 3) z 9) B\dy
48 4) h 10) B\dz
49 5) \gr 11) div B
50 6) T
51 -------------------------------------------------------
52 12) multiplot [ 4 ] m) set multiplot
53 -------------------------------------------------------
54 d(ata) p(age) o(pts) l(imits) le(g)end h(elp)
55 r(ender) v(ector) x(sec/rotate) s(ave) q(uit)
56 -------------------------------------------------------
57 Please enter your selection now (y axis or option):
58
59 The simplest plot is of two quantities which are not both coordinates.
60 For example, to plot density vs smoothing length, type
61
62 ::
63
64 Please enter your selection now (y axis or option): 5
65 (x axis) (default=1): 4
66 Graphics device/type (? to see list, default /xwin): /xw
67
68 The ``default=`` refers to the default value assigned if you just press
69 the return key. The last prompt asks for the device to which output
70 should be directed.
71
72 .. hint::
73 A full list of available graphics devices is given by typing ``?`` at the prompt.
74
75 Some of the most useful devices are given
76 in :ref:`tab:devices`. In the above we have selected
77 the X-window driver which means that the output is sent to the screen
78 (provided X-windows is running), as demonstrated in the screenshot shown
79 in :numref:`fig:rhoh`.
80
81
82 .. figure:: figs/rhoh.jpg
83 :alt: Screenshot of simple two column plot to an X-window
84 :name: fig:rhoh
85 :width: 80.0%
86
87 Screenshot of simple two column plot to an X-window
88
89 .. table:: Commonly used graphics devices available in giza
90 :name: tab:devices
91
92 +-----------------+-----------------+-----------------+-------------------+
93 | ``/xw``, | X-Window | ``/png`` | Portable |
94 | ``/xwin`` | (interactive) | | Network |
95 | | | | Graphics |
96 | | | | (bitmap) |
97 +-----------------+-----------------+-----------------+-------------------+
98 | ``/eps`` | Encapsulated | ``/svg`` | Scalable Vector |
99 | | postscript (one | | Graphics |
100 | | file per page) | | |
101 +-----------------+-----------------+-----------------+-------------------+
102 | ``/pdf`` | PDF | ``/null`` | null device (no |
103 | | | | output) |
104 +-----------------+-----------------+-----------------+-------------------+
105 | ``/ps`` | Postscript (all | ``/mp4`` | mpeg4 animation |
106 | | pages in one | | (requires ffmpeg) |
107 | | file) | | |
108 +-----------------+-----------------+-----------------+-------------------+
109
110 .. _sec:interactive:
111
112 Interactive mode
113 -----------------
114
115 Many useful tasks can now be achieved by moving the mouse to the plot
116 window and selecting areas or pressing keystrokes – this is :ref:`sec:interactive`.
117 Most useful are:
118
119 - press ``l`` with the mouse over the colour bar for a *log axis*
120
121 - ``a`` to *adapt the plot limits* (with mouse on the colour bar, inside the plot, or positioned next to the x or y axes)
122
123 - ``left click`` to *select an area* with the mouse and ``click`` to *zoom*
124
125 - ``left click`` on the colour bar to *change the rendering limits*
126
127 - ``space`` to *skip to the next file* (``right click`` or ``b`` to go back)
128
129 - ``-`` or ``+`` to *zoom in* or *out*
130
131 - ``Enter`` for :ref:`sec:hollywood`
132
133 - ``o`` to *recentre the plot* on the origin
134
135 - ``r`` to *refresh* the plot (e.g. after changing the window size)
136
137 - ``g`` to *plot a line and find its gradient*
138
139 - ``m`` or ``M`` to *change the colour map*
140
141 - ``f`` to *flip the rendering* to the next quantity
142
143 - ``<``, ``>``, ``{``, ``}`` and ``/``, ``\`` to *rotate particles* around *z*, *y* and *x axes*, respectively
144
145 - ``G`` to *move the legend*
146
147 - ``ctrl-t`` to *annotate with text*
148
149 - ``backspace`` to delete annotation
150
151 - ``s`` in the plot window to *save changes* between timesteps, otherwise the settings
152 will revert when you move to the next timestep.
153
154 - ``q`` in the plot window to *quit the plotting window* and return to the menu
155
156 - ``q`` again from the splash main menu to *quit splash altogether*.
157
158 - ``h`` in the plot window for the full list of commands
159
160 On particle plots you can additionally:
161
162 - select an area and press ``0``-``9`` to *colour particles* (particle colours stick
163 between plots, so you can use this to find particles with unusual parameters)
164
165 - select an area and press ``0`` to *hide selected particles*
166
167 - move the mouse over a particle and press ``c`` to see the size of the *smoothing
168 circle* for that particle
169
170 These tasks can also be achieved non-interactively by a series of
171 text-based :ref:`sec:menu` (see :ref:`sec:settings`). For example limits changing options are contained in the
172 :ref:`sec:menu-l`, so to manually set plot limits we would type ``l`` from
173 the main menu, then ``2`` for option 2 (set manual limits) and follow the
174 prompts to set the limits for a particular data column.
175 See also :ref:`sec:menu-i`.
176
177 .. _sec:renderplot:
178
179 Rendered plots
180 --------------
181
182 A more complicated plot is where both the :math:`x-` and :math:`y-` axes
183 refer to coordinates. For example
184
185 ::
186
187 Please enter your selection now (y axis or option):2
188 (x axis) (default=1): 1
189 (render) (0=none) ([0:11], default=0):5
190 (vector plot) (0=none, 8=B) ([0:8], default=0):0
191 Graphics device/type (? to see list, default /xwin): /xw
192
193 You can produce the same graph without answering prompts using::
194
195 splash -y 2 -x 1 -r 5 -dev /xw minidump.00001
196
197 or, since the other options are default anyway, simply::
198
199 splash -r 5 minidump.00001
200
201 Notice that in this case that options appeared for rendered and vector
202 plots. Our choice of ``5`` at the (render) prompt corresponds to column 5,
203 which in this case is the density, producing the plot shown in the
204 screenshot in :numref:`fig:renderplot`.
205
206 .. figure:: figs/renderplot.jpg
207 :alt: Screenshot of 3D column density plot to an X-window
208 :name: fig:renderplot
209 :width: 80.0%
210
211 Screenshot of 3D column density plot to an X-window
212
213 .. important::
214 Rendered plots only work if columns for density, particle mass and
215 smoothing length are correctly identified in the data, and provided the
216 number of coordinates is 2 or greater. Without these, rendering will
217 just colour the points according to the selected column.
218 See :ref:`sec:writeyourown` for internal details.
219
220 .. _sec:xsec:
221
222 Cross section
223 --------------
224
225 To plot a cross section slice instead of a projection in 3D, simply
226 use ``--xsec`` flag on the command line::
227
228 splash --xsec -r 5 minidump.00001
229
230 Or, type ``x`` at
231 the main menu to open the :ref:`sec:menu-x` and
232 choose option ``1) switch between cross section and projection``. Then
233 re-plot the rendered plot again (exactly as in the previous example
234 :ref:`sec:renderplot`), setting the slice position at the prompt:
235
236 ::
237
238 enter z position for cross-section slice: ([-8.328:8.327], default=0.000):
239
240 which produces the plot shown in the screenshot in :numref:`fig:renderplot_xsec`
241
242 .. figure:: figs/renderplot_xsec.jpg
243 :alt: Screenshot of 3D cross section slice plot to an X-window
244 :name: fig:renderplot_xsec
245 :width: 80.0%
246
247 Screenshot of 3D :ref:`sec:xsec` slice plot to an X-window
248
249 .. _sec:vectorplots:
250
251 Vector plots
252 ------------
253
254 A prompt to plot vector arrows on top of :ref:`sec:renderplot` (or on top of
255 particle plots) appears whenever vectors are present in the data (for
256 details of how to specify this in your data read, see
257 :ref:`sec:writeyourown`), taking the form:
258
259 ::
260
261 (vector plot) (0=none, 8=B) ([0:8], default=0):0
262
263 where the number refers to the column of the first component of the
264 vector quantity.
265
266 Vector plots in 3D show either the integral of each component along the
267 line of sight or, for a :ref:`sec:xsec`, the vector arrows in a :ref:`sec:xsec`
268 slice (depending on whether a projection or :ref:`sec:xsec` has
269 been selected for 3D plots – see the rendering examples given
270 previously). In 2D vector plots simply show the vector arrows mapped to
271 a pixel array using the SPH kernel.
272
273 Settings related to vector plots can be changed via :ref:`sec:menu-v`.
274 The size of the arrows is set by the maximum plot limit over all of the vector components.
275 Alternatively the arrow size can be changed interactively using ``v``, ``V`` (*decrease
276 /increase the arrow size*) and ``w`` (*automatically
277 adjust arrow size so longest arrow is one pixel width*).
278
279 Contour plots
280 -------------
281
282 To plot contours of a quantity instead of :ref:`sec:renderplot`, simply set
283 the colour scheme used for rendering to 0 (contours only) via the
284 “change colour scheme” option in the :ref:`sec:menu-r` (type “r2” from the
285 main menu as a shortcut to option 2 in the :ref:`sec:menu-r`).
286
287 Contours of an additional quantity can also be plotted on top of
288 :ref:`sec:renderplot`. However the prompt for an additional contour plot does not
289 appear by default – it can be turned on via the ``plot contours`` option
290 in the :ref:`sec:menu-r` (type ``r3`` at the main menu as a shortcut). With
291 this option set *and a non-zero response to the render prompt*, a prompt
292 appears below the render prompt:
293
294 ::
295
296 (render) (0=none) ([0:11], default=0):5
297 (contours) (0=none) ([0:11], default=0):6
298
299 Entering the column to use in the contour plot at this prompt (e.g.
300 column 6 in the above example would correspond to the temperature) gives
301 a rendered plot with overlaid contours.
302
303 Entering the same quantity used in the rendering at this prompt (e.g.
304 column 5 in the above example) triggers a subsequent prompt for the
305 contour limits which can then be set differently to those used in the
306 render plot. In this way it is possible to make a plot where the density
307 of one particle type is shown by the rendered plot and the density of
308 another particle type (with different limits) is shown by contours. This
309 can be achieved because once contour plotting is turned on, the
310 contribution of a given particle type to either the contours or rendered
311 plots can be turned on or off via the ``turn on/off particles by type``
312 option in the :ref:`sec:menu-o`.
313
314 Moving forwards and backwards through data files
315 ------------------------------------------------
316
317 See :ref:`sec:interactive`. If you have put more than one file on the command line (or alternatively
318 the file contains more than one dump), it is then possible to move
319 forwards and backwards through the data:
320
321 - press the ``space bar`` to move to the next file
322 (with the cursor in the plot window - this is :ref:`sec:interactive`).
323
324 - press ``b`` to load and plot the previous file
325
326 - type `9` and press ``space`` to move forward by 9 files
327
328 - type `10` and press ``b`` to move back by 10 files
329
330 Press ``h`` in :ref:`sec:interactive` for more.
331
332 .. important::
333 If you plot to
334 a non-interactive device, splash simply cycles through all the files on
335 the command line automatically.
336
337 Zooming in and out / changing plot limits
338 -----------------------------------------
339
340 See :ref:`sec:interactive`. Having plotted to an interactive device (e.g. ``/xw``), tasks such as
341 zooming in and out, selecting, colouring and hiding particles, changing
342 the limits of both the plot and the colour bar and many other things can
343 be achieved using either the mouse (i.e., selecting an area on which to
344 zoom in) or by a combination of the mouse and a keystroke.
345
346 .. _sec:postscript:
347
348 Producing figures for LaTeX documents
349 --------------------------------------
350
351 Producing a pdf or postscript plot suitable for inclusion in a LaTeX file is
352 simple. At the device prompt, type
353
354 ::
355
356 Graphics device/type (? to see list, default /xw): myfile.eps
357
358 that is, instead of ``/xw`` (for an X-window), simply type ``/eps`` or
359 ``.eps`` to use the encapsulated postscript driver. This produces a file
360 which by default is called ``splash.eps``, or if multiple files have
361 been read, a sequence of files called ``splash_0000.eps``,
362 ``splash_0001.eps``, etc. To specify both the device and filename, type
363 the full filename (e.g. ``myfile.eps``) as the device. Files produced in
364 this way can be directly incorporated into LaTeX using standard packages.
365
366 .. danger::
367 Do **not** use the ``/png`` driver to produce files for LaTeX documents. Your
368 axes will appear pixellated and blurred.
369 Use a vector graphics device (eps or pdf) instead. These give clean, sharp
370 and infinitely scalable text and lines.
371
372 .. hint::
373 Using ``eps`` format is recommended for LaTeX as it will always crop
374 to the exact boundaries of the plot. The inbuilt ``pdf`` driver may
375 require cropping of whitespace. Encapsulated postscript can be easily
376 converted to pdf (for pdflatex) on the command line using::
377
378 epstopdf file.eps
379
380 Most pdflatex engines (including `Overleaf <http://overleaf.com>`_)
381 will handle/convert eps automatically.
382
383 .. _sec:movies:
384
385 Producing a movie of your simulation
386 -------------------------------------
387 To make a movie of your simulation, first specify all of the files you
388 want to use on the command line:
389
390 ::
391
392 splash dump_*
393
394 and use an interactive device to adjust options until it looks right.
395
396 .. hint::
397 Movies look best with minimal annotation, e.g. using :ref:`sec:hollywood`
398 or the backspace key in interactive mode to manually delete annotation
399
400 If in interactive mode type ``s`` to save the current settings, then plot the
401 same thing again but to a non-interactive device.
402
403 In the latest version of splash you can generate an mp4 directly ::
404
405 Graphics device/type (? to see list, default /xw): splash.mp4
406
407 In older splash versions, or for more control, first generate a sequence of png files ::
408
409 Graphics device/type (? to see list, default /xw): /png
410
411 This will generate a series of images named ``splash_0000.png``,
412 ``splash_0001.png``, ``splash_0002.png`` corresponding to each new
413 plotting page generated (or enter “``myfile.png``” at the device prompt
414 to generate ``myfile_0000.png``, ``myfile_0001.png``,
415 ``myfile_0002.png``\ …).
416
417
418 .. hint::
419 Avoid prompts altogether using the :ref:`sec:commandline`. For example, to make
420 a movie as per the prompts above, simply type::
421
422 splash -r 5 --movie dump_*
423
424 which is a shortcut for::
425
426 splash -r 5 -dev splash.mp4 dump_*
427
428 To produce a sequence of images from the command line, use ::
429
430 splash -r 5 -dev /png
431
432 See also :ref:`sec:batchmode`.
433
434 .. _sec:animations:
435
436 Producing a movie from a sequence of images
437 --------------------------------------------
438 Having obtained a sequence of images there are a variety of ways to make
439 these into an animation using both free and commercial software. The simplest
440 is to use `ffmpeg <ffmpeg.org>`_::
441
442 ffmpeg -i splash_%04d.png -r 10 -vb 50M -bt 100M -pix_fmt yuv420p -vf setpts=4.*PTS movie.mp4
443
444 A simple script which executes the above command is included in the source file distribution
445 ::
446
447 ~/splash/scripts/movie.sh
448
449 Alternatively, it is possible to create an animation from a list of image files::
450
451 ffmpeg -f concat -r 25 -i list.txt -vb 50M -bt 100M -vcodec mpeg4 -vf setpts=4.*PTS movie.mp4
452
453 Where list.txt contains the image files you want to use like this::
454
455 file 'path/to/file1.png'
456 file 'path/to/file2.png' etc
457
458 See :ref:`sec:moviemaking` for more.
459
460 .. _sec:hollywood:
461
462 Hollywood mode
463 ---------------
464 Press ``Enter`` or ``ctrl-m`` in the interactive plot window to start ``Hollywood mode``,
465 which changes to plot settings better suited to movies.
466
467 The following shows :ref:`fig:default`:
468
469 .. figure:: figs/default-mode.png
470 :name: fig:default
471 :width: 80.0%
472
473 A circumbinary disc simulation viewed in default mode
474
475 and :ref:`fig:hollywood`
476
477 .. figure:: figs/hollywood-mode.png
478 :name: fig:hollywood
479 :width: 100.0%
480
481 The same simulation viewed in Hollywood mode
482
483 .. _sec:remote:
484
485 Remote visualisation
486 --------------------
487 Visualisation of data in-situ on a cluster or supercomputer is simple. Just
488 log in using ssh with X-windows forwarding, e.g.::
489
490 ssh -Y [email protected]
491
492 Then just plot to an interactive device (``/xw``) as usual and everything
493 in :ref:`sec:interactive` should *just work*.
494
495 splash has few dependencies and is simple to :ref:`install in your home space <installhome>` if necessary.
496 That said, it is always a good idea to get admins to install a shared package for all users.
497
498 Ten quick hints for producing good-looking plots
499 ------------------------------------------------
500
501 These can improve the look of a visualisation substantially
502 compared to the default options:
503
504 #. **Log the colour bar**. To do this simply move the cursor over the colour
505 bar and hit ``l`` (for log) in :ref:`sec:interactive`. Or non-interactively via the
506 ``apply log or inverse transformations to columns`` option in the :ref:`sec:menu-l`.
507
508 #. **Adjust the colour bar limits**. Position the mouse over the colour bar
509 and left-click in :ref:`sec:interactive`. To revert to the widest max/min possible for the data
510 plotted, press ``a`` with the cursor positioned over the colour bar.
511 Limits can also be set manually in the :ref:`sec:menu-l`.
512
513 #. **Change the colour scheme**. Press ``m`` or ``M`` in :ref:`sec:interactive`
514 to cycle forwards or backwards through the available colour schemes.
515
516 #. **Change the paper size**. To produce high-resolution images/movies, use
517 the ``change paper size`` option in the :ref:`sec:menu-p` to set the paper
518 size in pixels.
519
520 #. **Try normalised or exact interpolation**. If your simulation does *not*
521 involve free surfaces (or alternatively if the free surfaces are not
522 visible in the figure), turning the ``normalise interpolations`` option
523 on (in the :ref:`sec:menu-r`) may improve the smoothness of the
524 rendering. This is turned off by default because it leads to
525 funny-looking edges. Exact rendering performs exact sub-pixel rendering
526 so is more accurate but slower.
527
528 #. **Remove annotation/axes**. For movies, often axes are unnecessary and
529 detract from the visual appeal. Use :ref:`sec:hollywood` or delete
530 annotation by pressing backspace in :ref:`sec:interactive`. Alternatively each can
531 be turned off manually – axes via the ``axes options`` option in the
532 :ref:`sec:menu-p`; the colour bar by the ``colour bar options`` entry in
533 the :ref:`sec:menu-r` and the legends via options in the :ref:`sec:menu-g`.
534
535 #. **Change axes/page colours**. The background colour (colour of the page)
536 and foreground colour (used for axes etc) can be changed vie the
537 ``set foreground/background colours`` option in the :ref:`sec:menu-p`.
538
539 #. **Move the legend or turn it off**. The time legend can be moved by
540 positioning the mouse and pressing ``G`` in interactive mode. The
541 legend can be turned off in the :ref:`sec:menu-g` or by pressing
542 backspace in interactive mode. Similarly the vector plot legend can
543 be turned on/off in the :ref:`sec:menu-v` and moved by positioning the
544 cursor and pressing ``H``.
545
546 #. **Use physical units on the axes**. These can be set via the :ref:`sec:menu-d`.
547 See :ref:`sec:changingunits` for more details.
548
549 #. **Save settings to disk**! Don’t waste your effort without being able to
550 reproduce the plot you have been working on. Pressing ``s`` in
551 interactive mode only saves the current settings for subsequent
552 timesteps. Pressing ``s`` from the main menu saves these settings to
553 disk. Pressing ``S`` from the main menu saves both the plot options
554 *and* the plot limits, so that the current plot can be reproduced
555 exactly when splash is next invoked. Adding an ``a``, as in ``SA``, ``Sa``
556 or ``sa`` to the save options gives a prompt for a different prefix to
557 the filenames (e.g. ``splash.defaults`` becomes ``myplot.defaults``),
558 which splash can be invoked to use via the ``-p`` command line option
559 (e.g. ``splash -p myplot file1 file2...``).