Skip to content

j0r1/GRALE2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GRALE2: pygrale

GRALE is a project to allow you to simulate and invert gravitational lenses. The first generation of GRALE consisted of C++ libraries and an interactive program called GRALESHELL with which many useful commands could be executed without having to write a program yourself using the C++ libraries.

This new generation GRALE2 consists of a trimmed down set of core libraries that are still written in C++, together with Python bindings to provide the same functionality: pygrale. The idea is that the core code is still written in the fast low-level C++ language, but to make everything more easily useable and flexible, a Python interface is provided. The link between the C++ code and Python could be provided thanks to the Cython project.

The basic idea is to put things that only depend on GSL, SerUt and ErrUt in the core library, and the things that need EATk, and possibly MPI in the inversion library. The Python modules should only link against the core lib, thereby avoiding a possible dependency on MPI. Interaction with e.g. MPI will be done using separate programs, that are communicated with using the subprocess module.

Documentation

Documentation can be generated using Sphinx, or can be viewed online

Installation

The documentation describes how you can use the provided scripts to get your own copy working.

To really do everything yourself, the first step is to compile the GRALE C++ libraries, for which you'll need a few dependencies:

  • Error utilities in ErrUt
  • Serialization utilities in SerUt
  • The evolutionary algorithm toolkit EATk
  • GSL, the GNU Scientific Library

Optionally, an MPI implementation can be very useful to speed up calculations; e.g. with OpenMPI.

When these dependencies are satisfied, you can build the GRALE2 libraries: clone the repository, and use CMake to build and install them.

After these libraries are built and installed, you can proceed to build the Python bindings. To do so, you'll need NumPy as well as Cython. Just enter the pygrale directory and first use the configure.py script to prepare the build and generate a makefile. Then, you can use the make and make install commands to build and install the Python bindings.

The following Python packages and programs will definitely be useful:

  • SciPy is used for the integration needed to calculate angular diameter distances, as well as for some basic triangulation tasks.
  • Astropy is used to read/write FITS files.
  • Shapely is used to add a border to a polygon, when generating null space grids with holes in them for certain images.
  • pycairo and qpsolvers are used in the procedure to extrapolate the lensing potential.
  • When PyQt5 and SIP are available, then the GRALE editor tool will be made available automatically. This package in turn depends on Qt5.
  • Triangulations are made using the triangle program, which allows one to create constrained triangulations.