Example scripts

The examples directory contains a number of example python scripts that demonstrate ways of using (elements of) this library for various science analysis steps. Each script is a self-contained unit which produces a plot from the simulation data. The scripts are heavily commented to highlight their internal workings. It is a good idea to run and modify (some of) them yourself before using the library for your own scientific goals!

Note

The emphasis of these examples is to demonstrate how to use various parts of the library. The science questions addressed by them are selected to fit with the library aspects illustrated, rather than representing key scientific targets of the simulations. Also note that the plotting part is deliberately kept simple, so these examples should not be regarded as recommendations on how to present scientific data.

Basic examples

These are relatively straightforward, and probably the best ones to try out first.

Name Library/simulation features covered Science aspect
sfr_mstar_plot.py
  • Read/write data from/to HDF5 files
  • Read (full) subhalo catalogue
    (SplitFile)
  • Avoiding the simulation boundary
Plot Mstar - SFR relation
subhalo_map.py

Use SplitFile to

  • read an individual FOF catalogue entry
  • read a (full) subhalo catalogue
Plot subhaloes
around a cluster
select_galaxies.py
  • Read data for all subhaloes
    (SplitFile)
  • Read data for one FOF group
    (SplitFile)
  • Read data from ‘simple’ HDF5 files
Find galaxies matching
a set of criteria
(analogous to a
data base query)
star_density.py
  • Read data for one subhalo
    (SplitFile)
  • Read particles in a small volume
    (ReadRegion)
Plot galaxy image
phase_diagram.py
  • Use SplitFile to
    • read an entire particle catalogue
    • read an individual entry from the
      FOF catalogue
  • Avoiding the simulation boundary
Plot the gas phase
diagram of a simulation

More complex example scripts

These examples are slightly longer and/or more complex than the “basic” examples. In the second column, only features that have not already been covered in the basic examples above are listed.

Name Library/simulation features covered Science aspect
galaxy_stars.py in_subhalo() function to
test particles for subhalo membership
Plot images of a
disrupting galaxy
galaxy_evolution.py
  • Follow one galaxy’s evolution
  • Find all progenitors of a galaxy
    in a given snapshot
Plot Mstar and Zstar
evolution for a galaxy
sf_history.py
  • Use ReadRegion to load particles
    within the resolved simulation region
  • Virtual SubhaloIndex element to
    connect particles to their subhaloes
Plot SF history of
central and satellite
galaxies
snipshot_age.py
  • Working with snipshots
  • Gate class for matching entries
    between two catalogues
Plot stellar age map
of a galaxy at a
specified time
trace_particles.py find_id_indices() function to match
entries between catalogues
(alternative to Gate class)
Phase diagram of gas
destined to sit in the
cluster core
thermal_history.py
  • Use full set of snip- and snapshots
  • Alternative units in SplitFile
    and ReadRegion readers
Path of one particle
across the phase
diagram over time
orbits.py
  • Match subhaloes between HYDRO and
    DM-only simulations
  • Interpolated orbits for very high
    time resolution
Compare the orbit of
a galaxy in HYDRO
and DM-only runs