GRAS PYTHON Test Suite¶
All the code contained in the gras/python directory represents a PYTHON test suite to launch the GRAS test and examples and look at and/or plot the simulation results saved in csv files.
Directory structure¶
python_utilities: different python classes and modules: - start/control simulation - Look at the simulation results - python interface to spenvis (spenvis_csv subdirectory ) - some geometry/gdml classes allowing the building of GDML file from python functions
python_scripts: contains python scripts that the user can edit/modify to use the python test suite
csv_files: some Spenvis csv file examples * data: contains a list of isotope from NIST, used by the
MaterialManager
database: will contain after the first simulations a runtest Sqlite database that is used to store running and waiting_for_run simulation.
Dependencies¶
The following packages should be installed
python2.xxx (>2.5), (+library and include files)
the python numpy library
the mathplotlib/pylab python library for plotting of the results
the BOOST python library needed to build the python spenvis_csv interface (see below)
Installation of the PYTHON / SpenvisCSV interface¶
Once the dependency packages have been installed, it is necessary to build the SpenvisCSV python interface that allows to read Spenvis csv files in python. The C++ source files representing the interface are contained in the directory python_utilities/spenvis_csv. It consists into a slight modified version of the Spenvis CSV C++ code developed by H. Evans (ESA/ESTEC) plus a pySpenvis.cc code that realizes the interface withPYTHON, by using the BOOSTPYTHON library. This SpenvisPYTHON interface can be compiled and installed by running the python script install_pyspenvis.py in the gras/python directory. THis script uses first cmake to produce the Makefile for the compilation of Spenvis C++ code. The use of cmake allows installation of the PYTHON Spenvis interface on different types of platform with exactly the same installation procedure. At the moment the installation have been tested on Linux Suse11.3 (32/64bit) and MacOS 10.3 (64 bit).
Use of the testing suite¶
__Run of tests__¶
The PYTHON script
python/python_scripts/perform_gras_distribution_test.py
illustrates
how to run some or all tests and examples of the gras distributions. At
the moment the tests are run on the local directory of the test. The
PYTHON test suite will be further developed to able to run all tests on
a separate directory in order to keep track of previous tests results.
While several tests can be chosen to be performed in the same
script/call by the user, all the selected tests are not run in the same
time but in sequence using a queuing system. The user can define the
number maximal of test to be run in parallel (depends on the number of
cores available on the test machine). A sql_lite database is used to
check that he number of running tests is lower or equal to the user
defined max number of running tests. “Still to be run” tests are set in
a queue, waiting for the running tests to be finished. Any time the run
of a test is finished the top test in the queue system is launched for
running. At the end of the run of a test it is checked if an error file
has been produced and in the posotive case its content is printed on the
screen.
__Check of test results__¶
The PYTHON script python/python_scripts/check_gras_distribution_test_results.py illustrates how to check the results of some or all tests and examples of the gras distributions. For all user selected tests the following is done:
The content of the log file is printed on the screen
The content of the error file is printed on the screen
If the variable “view_plot” is set to True in the script check_gras_distribution_test_results all 1D Histogram registered in the GRAS csv file are plotted one after the other
Finally the value and estimated error of all GRASdouble contained in the GRAS csv file output are printed
GRAS/trunk/r2242