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.

Requirements

Hard dependencies

Optional dependencies

  • 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.Surf is limited to the standalone Hammer projection.

Configuration: magic.cfg file

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 magic.cfg file.

Detailed options

In case, the file magic.cfg doesn’t exist in the directory $MAGIC_HOME/python/magic, 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: TkAgg, GTKAgg, Qt5Agg, Qt4Agg, …). The default configuration is

backend = TkAgg

Note

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 the libraries:

buildLib = True

The exact name of the executable f2py however varies from one Linux distribution to the other. Among possible options, one frequently finds: f2py, f2py2, f2py3. This can be set to your proper configuration using the f2pyexec option of the magic.cfg file. 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:

  • gnu95 for the GNU gfortran compiler.

  • intelem for the Intel ifort compiler.

  • pg for the Portlang group pgf compiler.

Once you’ve decided the ideal configuration for your machine, set it up via the option fcompiler:

fcompiler = intelem

Finally, he same configuration procedure can be applied to the C compiler using the variable named ccompiler. The possible options are:

  • unix for the GNU gcc compiler.

  • intelem for 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.

Ready?!

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. buildLib=True), 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 $MAGIC_HOME/python/magic/ directory.

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:

Python classes

  1. To read the log.TAG files , see here.

  2. To read and analyse the time series, see here.

  3. To read and analyse the radial profiles, see here.

  4. To read and analyse spectra _spec_#.TAG, see here.

  5. To read and analyse the G_#.TAG files, see here.

  6. To read and analyse the checkpoint_#.TAG files, see here.

  7. To read and analyse movie files _mov.TAG, see here.

  8. To read and analyse coeff files [V|B|T]_coeff.TAG, see here.

  9. To read and analyse potential files [V|B|T]_lmr_#.TAG, see here.

  10. To read and analyse radial spectra B[r|p]Spec.TAG, see here.

  11. To read and analyse TO outputs, see here.

  12. To compare several runs simultaneously, see here.

  13. To transform the graphic files G_#.TAG to a file format readable by paraview, VisIt or mayavi and do some fancy 3-D visualisation, see here.

  14. For additional diagnostics (boundary layer, heat transport, interpolation on cylindrical grids, etc.), see here.

  15. To take a look at the additional useful functions available (derivation, integration, interpolation, etc.), see here.