GalSim-developers/GalSim — pull request #146 by barnabytprowe (2012-05-12 00:05:26+00:00)
Title: #101 - basic Multi-Object functionality

We've been developing a scheme for handling user-specified information about multiple objects and getting GalSim to generate these objects.

Currently, we are able to allow users to set galaxy, psf or pixel parameters as either constant, or taken from an ASCII catalog. FITS catalogue reading and handling stochastic distributions (e.g. #98) were de-scoped from Milestone 2 due to the volume of work required to get just constant value / ASCII input handling going! But I think it's fair to say a very large amount of the groundwork is now done.

The configuration and input data for GalSim in Multi-Object mode is handled by a new Python object called a `Config` instance, which wraps around an `AttributeDict` object, based on a pattern provided by Jim. These are like flexible nested dictionaries that allow access to heterogenous data via object attributes - very handy for getting this overall prototype schema off the ground.

As things become more fixed and we understand better how GalSim gets used, we may start to hard code some of the attributes of these structures, to reduce the freedom to mess things up via poorly chosen / specified input.

However, what we currently have demonstrates one vision for a fairly powerful front end to GalSim, and will hopefully be of use as we improve the interface further.

Much of the guts of what happens occurs in `galsim/frontend.py`, and two visions for this structure were developed in parallel on #103 and #101 before being put to an informal vote on #143. Nothing is fixed, and the current scheme (which uses a central dictionary to store the info about what is needed to initialize various sorts of GalSim objects, e.g. `Moffat`, `Sersic` etc.) will likely evolve greatly over time, and will possibly even be swapped out entirely. For now though, it works.

This work has happening in tandem with work on #103 (Multi-object demo script) and so this merge will also bring in a demo script entitled `MultiObjectDemo.py` which runs two scripts...

Script 1 demonstrates how a user might use GalSim as a toolkit for making their own multi-object simulations to generate a single large image.

Script 2 is much shorter, and demonstrates how the `Config` structure can be used to provide the GalSim interpreter functions in `frontend.py` (primarily `BuildGSObject()`) to achieve very similar effects, in tandem with an input catalog read in from `examples/inputs/` (generated using a python script in the same directory).

There are some pieces of code from stalled efforts to establish a more broadly-scoped input system (including the ability to specify values and distributions of parameters from configuration files) from earlier in the week - these are commented with `#UNFINISHED` etc. at the header. These may be used in future, or removed, but for now they are being kept.

Phew, this was a long message - there's been a lot of work done on #101, #102 and #103 in the last few days.

Some of what we wanted for Milestone 2 has slipped into next week, e.g. scripts demonstrating the use of `RealGalaxy` objects that Rachel has been working on, but everybody should be commended for a tremendous effort and thanked for their input.

Comments welcomed.