Skip to main content

glee.py Wrapper

Overview​

glee.py is a Python implementation used to handle GLEE configuration files that include Python extensionsβ€”cases where the standard glee tool cannot modify the contents directly. It replicates some core capabilities of glee (e.g. glee -S, glee -c) for compatibility.

To see available options:

glee.py -h
usage: glee.py [-h] [-v VERBOSE]
{minimise,save,chi2,analyse,predict,simulate,mcmc,plot} ...

Optional Arguments​

  • -h, --help: Show help message and exit.
  • -v VERBOSE, --verbose VERBOSE: Set verbosity level.

Commands and Examples​

Compute Ο‡2\chi^2​

To compute Ο‡2\chi^2:

glee.py chi2 test1

Example output:

chi2      = 7.740541487e+01 / dof -77
src_chi2 = 1.909509592e+04 / dof -5
img_chi2 = 3.461758943e+04 / dof -16
...
ext_chi2 = 7.740541487e+01 / dof -77

To compute a specific Ο‡2\chi^2 type (by number or name):

glee.py chi2 -c 128 test1
glee.py chi2 -c ext src -- test1

Save FITS Data​

glee.py save -n 50 test1

This creates test1.fits containing: x, y, alpha1, alpha2, kappa, gamma1, gamma2.

Options:

  • -z SOURCE_Z: Source redshift multilens plane data.
  • -r REGION: Region to save [x1:x2,y1:y2].
  • -n NAXIS: NAXIS of FITS file (e.g. naxis1,naxis2).
  • -d / -R: Save only deflection or residual kappa.

Analyse & Predict​

Analyse predicted vs observed image positions:

glee.py analyse test1

Predict image positions and print to terminal (for use in new configs):

glee.py predict test1

Optimisation and Sampling​

Scipy & Global Optimisers​

You can run standard Scipy optimisers or stochastic methods:

# Basinhopping
glee.py basinhopping --options '{"niter":10, "T":1000}' test1

# Differential Evolution
glee.py differential_evolution --options '{"maxiter":10, "strategy":"best1bin"}' test1

# SHGO
glee.py shgo --options '{"iters":10, "n":100}' test1

# Dual Annealing
glee.py dual_annealing --options '{"maxiter":10, "initial_temp":1000}' test1

# Standard Minimise (e.g. Powell, BFGS)
glee.py minimise --method Powell --options '{"maxiter":100, "disp":True, "xtol":1e-6}' --output outputconfig inputconfig

MCMC (Markov Chain Monte Carlo)​

GLEE uses the Metropolis-Hastings algorithm for standard MCMC.

glee.py mcmc configfile

To use a covariance matrix for the proposal distribution, generate it first using glee -h filename.

Parallel Sampling with emcee​

You can utilize the emcee library for parallel, ensemble-based MCMC sampling:

mpiexec -f hosts_emcee -n 21 gleeemcee.py \
--walkers 200 \
--samples 1000 \
--burnin 1000 \
configfile
  • Produces configfile.mc (viewable with gleeviewsample.py).
  • To enable glee -S on .mc files, create a symlink: ln -s configfile.mc configfile.mcmc.