| 1 |
|
| 2 |
.. _sec:writeyourown: |
| 3 |
|
| 4 |
Data reads and command line options |
| 5 |
===================================== |
| 6 |
|
| 7 |
Requesting a customised data reader |
| 8 |
------------------------------------ |
| 9 |
The ``splash`` binary will read many formats. The default format is ascii or csv any ascii or csv data file where |
| 10 |
columns correspond to different quantities and rows correspond to each particle (actually |
| 11 |
I use splash to plot graphs for nearly all data in this form, whether SPH or not) |
| 12 |
-- it will also sensibly skip header lines which do not have the same number of columns. |
| 13 |
|
| 14 |
However, it is ultimately desirable to use SPLASH to directly visualise the |
| 15 |
(binary) output of your code. If your format is not amongst those distributed:: |
| 16 |
|
| 17 |
splash -f |
| 18 |
|
| 19 |
then BEFORE you start writing your own routine, please consider whether or not a routine |
| 20 |
to read your format would be of more general use (e.g. to other users of your code). |
| 21 |
If so, PLEASE email me to request a new read_data routine for your format, by sending an email attaching: |
| 22 |
|
| 23 |
a) an example dump |
| 24 |
|
| 25 |
and |
| 26 |
|
| 27 |
b) the source code from the routine which wrote the dump file. |
| 28 |
|
| 29 |
Then I can write a read for your format that can be added to the SPLASH repository |
| 30 |
and distributed in all future versions. Whilst I aim never to change the interface |
| 31 |
to the read_data routines, it is not impossible that some changes may occur |
| 32 |
somewhere down the line (or enhanced functionality -- for example the more advanced |
| 33 |
data reads are able to read only the required columns for a given plot from the |
| 34 |
file, rather than the whole file). It doesn’t matter if your code only has one user, |
| 35 |
we are still happy to do this as it makes splash more widely useable and |
| 36 |
saves trouble later. |
| 37 |
|
| 38 |
Writing your own data read |
| 39 |
--------------------------- |
| 40 |
If you *really* want to hack one yourself it is best to look at some of the |
| 41 |
other examples and change the necessary parts to suit your data files. Note |
| 42 |
that reading directly from unformatted data files is *much* faster than reading |
| 43 |
from formatted (ascii) data. |
| 44 |
|
| 45 |
If you do end up writing your own, again, please email me the end result so I |
| 46 |
can add it to the officially supported data reads. This also makes it much |
| 47 |
easier for you to upgrade to newer versions as you do not require a locally |
| 48 |
customised version. |
| 49 |
|
| 50 |
The second best way is to attempt to modify one of the existing data |
| 51 |
reads. Even then, there are some things to note: Most important is that, |
| 52 |
for the rendering routines to work, the density, particle masses and |
| 53 |
smoothing lengths for *all* of the (gas) particles *must* be read in |
| 54 |
from the data file and their locations in the main data array labelled |
| 55 |
using the integer parameters ``irho``, ``ipmass`` and ``ih``. Labelling |
| 56 |
of the location of other particle quantities (e.g. ``iutherm`` for the |
| 57 |
thermal energy) is used in order to plot the exact solutions on the |
| 58 |
appropriate graphs and also for calculating additional quantities (e.g. |
| 59 |
calculation of the pressure uses ``iutherm`` and ``irho``). |
| 60 |
|
| 61 |
The positions of vector components in the data columns are indicated by |
| 62 |
setting the variable ``iamvec`` of that column equal to the first |
| 63 |
component of the vector of which this component is a part. So if column |
| 64 |
4 is a vector quantity (say :math:`{\bf v}` in 3D), then |
| 65 |
``iamvec(4) = 4``, ``iamvec(5) = 4`` and ``iamvec(6) = 4``. Similarly |
| 66 |
the string ``labelvec`` should be set, i.e., ``labelvec = 'v'`` for |
| 67 |
these columns. |