Data visualisation and post-processing¶
Most of the output files written during a run of MagIC
can be treated with the python post-processing classes and functions present in the
$MAGIC_HOME/python/magic directory. These classes depend on several python libraries
that can be usually found in most of the Linux distributions.
Although entirely optional, the installation of ipython makes the interactive use of the post-processing python functions much more pleasant. Installing it is therefore recommanded for a smoother interactive usage of the python functions.
The installation of the basemap toolkit is optional. If installed, additional projections for the
magic.Surf(Aitoff, orthographic, Mollweide, etc.) class will be provided for 2-D surface plotting. Otherwise, the usage of
magic.Surfis limited to the standalone Hammer projection.
A file named magic.cfg located in
$MAGIC_HOME/python/magic/magic.cfg should have
been created when you used the
source path/sourceme.sh command for the first time on
your machine. At that stage, it tried to automatically fill the best options that
correspond to your setup. Although tested on several various machine configurations, the
auto-configuration script might however fail on your setup. The paragraph below details
the possible options that you may want to adjust in the
In case, the file
magic.cfg doesn’t exist in the directory
you can easily copy it from the default configuration
magic.cfg.default and then adjust
the options manually:
$ cp $MAGIC_HOME/python/magic/magic.cfg.default $MAGIC_HOME/python/magic/magic.cfg
In that file, you can set up the default matplotlib
rendering backend (among the possible options:
The default configuration is
backend = TkAgg
This is usually the default configuration which is the most likely to work on supercomputing clusters.
If LaTeX is installed on your work station, you might also want to make use of the better looking LaTeX fonts for all your displayed matplotlib figures (labels, caption, ticks, etc.). Be careful though that most of the time LaTeX is not installed on supercomputers. The default configuration is thus:
labTex = False
You can change the default colormap that will be used in the plotting routines.
defaultCm = seismic
You cant change the default number of contours that will be used in the plotting routines.
defaultLevels = 65
If you want to enable all the features of the python functions (faster reading the
G_#.TAG, conversion to the VTK/VTS
file format, potential extrapolation of the field lines, etc.), some fortran libraries
present in the $MAGIC_HOME/python/magic/fortranLib directory need to be built using
the f2py, which should be available on your Linux workstation
if all the required python libraries have been correctly installed. The boolean
buildLib can control whether you want to try building the fortran libraries
with f2py. The following configuration will try to build
buildLib = True
The exact name of the executable f2py
however varies from one Linux distribution to the other. Among possible
options, one frequently finds:
f2py3. This can be set to
your proper configuration using the
f2pyexec option of the
The default configuration is:
f2pyexec = f2py2
You can also choose the fortran compiler you want to use on your machine. A list
of the installed compilers can be obtained by using (where
f2py has to be
replaced by your own executable):
$ f2py -c --help-fcompiler
The most frequent options are:
gnu95for the GNU gfortran compiler.
intelemfor the Intel ifort compiler.
pgfor the Portlang group pgf compiler.
Once you’ve decided the ideal configuration for your machine, set it up via the option
fcompiler = intelem
Finally, he same configuration procedure can be applied to the C compiler using
the variable named
ccompiler. The possible options are:
unixfor the GNU gcc compiler.
intelemfor the Intel icc compiler.
In most of the configurations, the default configuration should do a good job:
ccompiler = unix
If you encounter any problem during the building stage, you can try playing with this parameter though.
Once you think you set up your
magic.cfg file correctly, you can test your
configuration. If you decided to build the fortran libraries (i.e.
you can easily test it with any python shell by typing the following command:
>>> from magic import *
If the build was successful, it should display:
Please wait: building greader_single... Please wait: building greader_double... Please wait: building lmrreader_single... Please wait: building Legendre transforms... Please wait: building vtklib... Please wait: building cylavg...
Once the libraries have been successfully installed, this message won’t be displayed
again, except if you remove the
*.so files that are now present in the
Python functions and classes¶
Once the python environment is correctly configured you can use the available functions and classes to analyse and post-process your data. The following pages will give you the detailed API of the available classes, as well as some practical examples: