Using with Python#
We provide a set of Python wrappers for the IRBEM Fortran library through the use of a shared library file (.so on Unix). The wrapper is found in python/IRBEM.py. Python interfaces with the compiled shared library file with ctypes.
Python wrapper install#
Compile the Fortran source as instructed by the README.install file. This will create the shared object file, “onera_desp_lib_linux….so” in the source firectory.
Change directory into the python folder and add the Python wrapper paths with “sudo python3 setup.py install”
Check that the installation worked by running the provided test scripts (python/<...>test_and_visualizations.py
).
If the wrapper crashes with the error “Either none or multiple .so files found in the sources folder!”, check that the shared object exists in the source folder.
Python usage#
The Python wrapper IRBEM.py`
currently consists of two classes that load the shared object file.
This class interface is used to avoid redudant user input formatting code. IRBEM.py
currently contains wrappers for the magnetic field library via the MagFields
class
and coordinate transformation library via the Coords
class.
The two classes contain methods which interface with the various IRBEM functions.
The output from each IRBEM wrapped function can be accesed with the usual return statement and <FUNCTION_NAME>_output
class attributes.
Current wrapped magnetic field functions are make_lstar
, drift_shell
, find_mirror_point
,
find_foot_point
, trace_field_line
, and find_magequator
. For more documentation, call help(<FUNCTION_NAME>)
.
Example code can be found in the python/<...>test_and_visualizations.py
files.