Within the past week, I have completely redesigned GSnap’s command line interface to allow more flexibility. I also added a configuration file reader which allows certain settings to be stored in a configuration file. The previous command interface was implemented one option at a time as I developed the code. It used a very inelegant collection of “if else if” statements, the commands needed to be entered in a very specific order, and there was no way of easily combining several flags. In other words, the interface wasn’t very useful and the code was a mess. I could have used the GNU GetOpt (the C++ equivalent of GNU getopt) to improve the interface, but I ended up writing my own command line parser that outwardly functions in the same way as getopt. I did this partially because I wanted to have the experience of writing such a parser and partially because I wanted to comply with two of my self-imposed guidelines:
- GSnap should be maximally platform-independent.
- Additional libraries (beyond the Qt Framework and standard C++ library) should be used only when they
- greatly contribute to the functionality or performance of the code and
- cannot be easily implemented in a few hours of coding.
Among other things, the new interface allows me to create interpolated snapshots of arbitrary combinations of particle types from arbitrary directions. Here’s an example of a particularly complicated command that the new interface can interpret:
gsnap -It 101110 –frames 2 –theta 0.55 –phi 0.1 –beg snapshot_510 –end snapshot_511 -c 10 0 0 –out snap_510
Translation:
-I specifies that we want gnsap to output interpolated images (rather than interpolated snapshots)
-t 101110 specifies that particle types 0, 2, 3, and 4 will be included in the images.
–frames 2 specifies that two intermediate interpolated images will be created.
–theta 0.55 –phi 0.1 indicate the viewing direction in spherical coordinates.
–beg snapshot_510 and –end snapshot_511 indicate that the two end-point snapshots that will be used in the interpolation are snapshot_510 and snapshot_511, where snapshot_510 is to be interpreted as the earlier of the two snapshots.
–out snap_510 specifies that the base name of the interpolated images is snap_510. The two output images will be named snap_510.1.png and snap_510.2.png.
-c 10 0 0 indicates that the frame should be centered on x = 10 kpc, and y = z = 0 kpc before being rotated and viewed from the theta, phi direction.
Except for the flags that require an input value, these command line arguments can be entered in any order. For instance, this is an equivalent, valid command:
gsnap –out snap_510 -t 101110 -Ic 10 0 0 –phi 0.1 –end snapshot_511 –frames 2 –theta 0.55 –beg snapshot_510
The new interface, combined with a Python script, will allow GSnap to create video frames that include rotation and zoom while the simulation evolves with time.