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 β
To compute :
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 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 withgleeviewsample.py). - To enable
glee -Son.mcfiles, create a symlink:ln -s configfile.mc configfile.mcmc.