But I would like to show how simple it really is to use sumatra to
people unfamiliar with this way of doing numerical experiments. I
will illustrate this with a script taken from
tamasis-map which performs
map-making for the
Herschel Space Observatory
and in particular the PACS instrument.
A simple script to perform map-making looks like this :
This script consists in a few simple functions parametrized by a small
number of keywords. It takes a FITS file
as input and output another FITS file. The script can be executed from
the command line but no argument can be passed from the command line.
This is not what Sumatra expects. Sumatra expects a script which
accepts a configuration file which defines the parameters of the
numerical experiment. The configuration file should be passed from the
command line to the script and parsed.
So we should rewrite our map-making script in this manner. We can
separate it in two parts. A part parsing the configuration file.
This can be done for instance with the ConfigParser package.
This is a long code. But the longest part is used to define the data
type of the arguments. The idea here is that a section of the
configuration file correspond to a step of the map-making script. A
dictionary storing the parameters of each step is filled from the
values in the corresponding section.
Now the map-making script can be rewritten as a function accepting a
dictionary of dictionaries as follows :
It is also easy to add some documentation to the script :
The configuration file would look like this :
With this code, you can do from the command line :
Or using sumatra :
Note that the files you use with Sumatra should be under revision
control, with Mercurial for instance. This can be done like this
Also, you should have a Data subdirectory to store results.
Finally, to see the results of your experiments, you can take a look
at them using the built-in web interface :
You can also look at results from the command line :
One very nice feature of Sumatra is the possibility to change the
configuration file parameters from the cli :
One of Numpy very usefull feature is its ability to define very easily
an array with a very large choice of data types. For instance, this
gives the possibility to very easily test an algorithm for its
robustness against error propagation due to the floating point
precision. You could write something like this :
Changing the data dtype from 64 bits to 32 bits can save your code a
factor of 2 in memory usage. This can be very important for data
intensive applications. Numpy even provide a 16 bits float which can
be useful if precision requirements are not very high.