Analyzing AMR output

Analyzing the output from an amr simulation is more difficult because of the complicated grid structures; however a number of tools have been developed to help. First, as pointed out in the section on the output format, since each grid is it's own self-contained HDF file, each grid can be analyzed by itself with any tool that reads HDF (IDL, Transform, etc.). Unfortunately, for simulations with hundreds or thousands of grids this is of little assistance. More practically, here are some other analysis methods, most of which assume that you are doing a 3D simulation (and often that it is a cosmological simulation).
  1. 2D projections - The code has the built-in ability to make two-dimensional projections, at a specified resolution, of a number of quantities (tailored for cosmology) along any axis of a given three-dimensional region. The resulting 2D HDF SDS's can then be imaged with a number of tools, including IDL.
  2. Extractions - A region (generally 3D, but this option also works for 1 and 2-dimensions) can be extracted with a uniform resolution and saved as a single grid. This is useful for other packages developed for single-grid codes. This option is also built into the amr code.
  3. Peakfinder - In the analysis package (amr_mpi/anyl), there is a routine which can find peaks in the baryon or dark-matter distribution, subject to a number of qualifications (such as minimum separation).  [Note: enzohop is recommended for most peak finding].
  4. Hop halo finder - Also in the analysis package is a version of Eisenstein & Hut's hop halo finder, as applied to the dark matter.
  5. Profiles - Radial profile of density and many other quantities can be generated with another analysis routine, given an object's position.
  6. Particle representation - The code also has the ability to convert the grid into a set of particle positions and densities, temperatures, etc. This can then be read into a particle-analysis code.


(Note: in this section we drop the "mpirun -np 1" that is required to run mpi programs.  Note also that all analysis programs only function with one processor -- they are not parallelized.  Finally, the square brackets [] used below imply an optional argument and are not meant to be typed.)

2D projections

The projection is done with the amr code itself and is of the following format:

enzo -p dim [-l level] [-m] [-b point1] [-f point2] amr_filename

an example might be:

enzo -p 1 -l 6 -b 0.4 0.4 0.4 -f 0.6 0.6 0.6 data0015

The -p option, which specifies the dimension along which the projection is to occur, and the amr output_filename are the only arguments required. The projection dimension (dim) is an integer from 0 to 2, and indicates along which dimension the projection occurs. For example, a projection along axis-0 produces an image with y-z axis.

The -l option specifies the resolution of the image, by indicating a level at which the projection will occur. The integer value level is zero-based so -l 0  produces an image with the same resolution as the root grid. Levels larger than the maximum in the output_filename may be used. The default value is 0.

The -m option smooths the image by doing a linear interpolation between coarse-grid points. If this option is not invoked, the result will be pixelated in regions in which the pixels are smaller than the grid cells (although this may be useful information). This option takes somewhat longer. The default is no smoothing.

Finally, there are two ways to specify the three-dimensional region in which the projection is to occur, one of which is shown in the commend-line above. This uses the -b and -f (begin and finish) flags. These flags each take a triplet (in 3D) of floats which specify the the two corners of the projection volume. The units are those of the problem (set by DomainLeftEdge and DomainRightEdge). For cosmology problems, this means numbers that range from 0 to 1. The default is the entire domain.

The other mechanism for specifying the projection volume is to specify coordinate indexes. This is done with the -s and -e flags, each of which take a triplet of integers. The integers refer to index positions (zero-based) within that level. This means the numbers should range between 0 and n*r^l-1 where n is the size of the top grid, r is the refinement factor and l is the level. The advantage of this method is that the size of the region can be precisely set, the disadvantage is the calculation is a bit more difficult. Although these two methods can be mixed (by specifying one corner with one method and the other corner with the other method), it is undefined to specify one corner twice. Finally, the error checking on these values is not great, and specifying a region with negative volume or one that goes off the edge may result in a core dump rather than an error message.

The result is placed in the file amr.project and consists of 2D scientific data sets (HDF format) of the following quantities (subject to change):

If there is a file called "ProjectionParameters" in the same directory, then this file is opened and searched for parameters relating to the generation of the X-ray emission field.  The following parameters (specified with the usual conventions: Parameter = ...) are recognized: XrayLowerCutoffkeV, XrayUpperCutoffkeV and XrayTableFileName.  The first two specify the X-ray band (observed at z=0) to be used, and the last gives the name of an ascii file that contains the X-ray spectral information.  A gzipped version of this file good for bands within the 0.1 - 20 keV range is available in amr_mpi/exe/lookup_metal0.3.data.gz.  If these parameters are specified, then the second field is replaced with integrated emissivity along the long of sight in units of 10^-23 erg/cm^2/s.  Also, see below in the profiling section.


Extractions

The command-line for an extraction is very similar to a projection:

enzo -x  [-l level] [-b point1] [-f point2] amr_filename

The  meaning of the level (-l) and region (-b, -f) flags are the same as for the projection (see above).

The output is a standard grid file and so consists of an HDF file with a number of scientific data sets.  The scientific data sets are named and have dimensional axis.  The units are code units with the exception of temperature, with is in degrees K.  See the file CosmologyGetUnits.C for a definition of code units, or look in the ascii output file (search for lines which start DataCGSConversionFactor = ...).


Peakfinder

The peakfinder is part of the amr_mpi/anyl package (see the downloading instructions), and can be compiled (once the MACHINE_NAME macro in the Makefile is set and enzo itself is compiled) with:

make findpeaks

And should produce the executable amr/anyl/findpeaks.  It is run with the command-line:

findpeaks [-n number] [-m min_density] [-s separation] amr_filename peak_filename

The algorithm reads in the amr output file amr_filename and looks for peaks (a density larger than it's 26 neighbours) in the baryon density distribution.  The result is output as a series of locations (float triplets between 0 and 1) to the file peak_filename, sorted by the peak density.

The -n option takes an integer argument and returns the number largest peaks.  Default: 1

The flag -m tells the algorithm to only check peaks width densities larger than the float value min_density which, for cosmology, is in units of the mean density of non-relativistic mass (at the redshift at which the output occurred).  This option is mostly useful for speeding up the algorithm, since a large value for the minimum density can drastically cut down the number of cells that need to be checked.  Default: 1

The last option, -s,  specified the minimum separation between peaks (the lower density peak is discarded), and the float value separation should be in terms of comoving Mpc/h.  Default: 0

This peakfinder really does just find local peaks -- a halo finder (see below) is probably what you're looking for.


Halofinder

The halo finder is part of the amr_mpi/anyl package.  It uses the hop algorithm (and source code) developed by Daniel Eisenstein and Wayne Hu (astro-ph/9712200) -- thanks to them for making the code available.  The compilation is currently a bit convoluted because hop assumes 4 byte floats.  This means that you must compile everything in single precision; change the PRECISION = r8 macro to PRECISION = r4 (in both amr_mpi/src/Makefile and amr_mpi/anyl/Makefile).  Then compile enzo (make clean first if previously compiled with PRECISION = r8), and then compile enzohop: "cd amr_mpi/anyl; make enzohop".  Run with:

enzohop [-b #] [-f #] [-t #] [-g] [-d] amr_filename

The only required argument, amr_filename, is the name of an amr output file.

The optional flags that specify a region to work on (-b for begin and -f for finish) are as described in the projection section.  Default: the whole region

The next flag (-t) takes a float and specifies the most important threshold used in hop (the outer density definition).  Default: 160

The -g flag indicates that baryon grid points should be converted to particles and passed into hop (along with the dark matter).  This is not recommended.  Finally, the -d flag is the usual debugging flag.

The output is placed into a number of files, only one of which is described here (see hop for the others).  HopAnalysis.out contains a list of the results groups, their particle number, mass and the location of the densest particle.


Profiler

It is often useful to compute azimuthally-averaged radial profiles.  The utility amr_mpi/anyl/enzo_anyl can be used for this.  Compile it the same way as findpeaks (make enzo_anyl), and run with the command-line:

enzo_anyl  amr_filename   anyl_parameter_file

The first argument, amr_filename, is the name of an amr output file, and the second argument is the name of an ascii file which contains some parameters for the analysis routine.  An example of this file should be in amr_mpi/anyl/AnalyzeClusterParameterFile.  The format of the parameters is the same as for the enzo code itself.  The parameters are:

The output is a set of files starting with AnalyzeCluster.  If the CenterListName was set, then they are numbered with a three digit identifier (AnalyzeCluster000, etc.).  Each profile produces for (or more) files, the first contains general information as well as the baryon profile and has no suffix.  Then there are three more which have the suffixes .DarkMatter, .Species and .Inertial, which contain profile relating to the particles, the multiple species (if used) and the inertial tensors of the gas and particles.  Finally, two other disk profiles may be generated if requested (see parameters above).

Each file consists of description information with the pound symbol (i.e. a comment) at the start of the line, and then the profile itself.  The first column is the center of the bin, while the second column is the right edge of the bin, in terms of Mpc (note: not comoving Mpc/h).

Virial information is also included in AnalyzeCluster, (mass, radius, mean velocity within, etc.), and each file contains a line which gives the mean of the profile quantities within the virial radius.


Particle Representation

To turn the grid points into particles, use the command-line:

enzo -o   amr_filename

This will create two HDF files, one called amr.particles.gas and the other amr.particles.dm which contain one-dimension scientific data sets of the "particle" positions, velocities, radii, density, temperature, etc.

This description will be lengthened if interest is expressed in this format.  Note that there is a version which outputs ascii files called dumpgrids (in amr_mpi/anyl).  Again, this is under development and is intended for conversion to other analysis/visualization programs.


last modified: March, 2000