Running and Plotting LightCones

This tutorial follows on from the coeval cube tutorial, and provides an introduction to creating lightcones with 21cmFAST. If you are new to 21cmFAST you should go through the coeval cube tutorial first.

There are two ways of creating lightcones in 21cmFAST: manual and automatic. The manual way involves evolving a coeval simulation through redshift and saving slices of it into a lightcone array. The advantage of this method is that one can precisely choose the redshift nodes to simulate and decide on interpolation methods. However, in this tutorial, we will focus on the single function that is included to do this for you: run_lightcone.

The function takes a few different arguments, most of which will be familiar to you if you’ve gone through the coeval tutorial. All simulation parameters can be passed (i.e. user_params, cosmo_params, flag_options and astro_params). As an alternative to the first two, an InitialConditions and/or PerturbField box can be passed.

Furthermore, the evolution can be managed with the zprime_step_factor and z_heat_max arguments.

Finally, the final minimum redshift of the lightcone is set by the redshift argument, and the maximum redshift of the lightcone is defined by the max_redshift argument (note that this is not the maximum redshift evaluated, which is controlled by z_heat_max, merely the maximum saved into the returned lightcone).

You can specify which 3D quantities are interpolated as lightcones, and which should be saved as global parameters.

Let’s see what it does. We won’t use the spin temperature, just to get a simple toy model:

[1]:
import py21cmfast as p21c
from py21cmfast import plotting
import os

print(f"21cmFAST version is {p21c.__version__}")
21cmFAST version is 3.0.0.dev2
[2]:
lightcone = p21c.run_lightcone(
    redshift = 7.0,
    max_redshift = 12.0,
    user_params = {"HII_DIM":150, "BOX_LEN": 600},
    lightcone_quantities=("brightness_temp", 'density'),
    global_quantities=("brightness_temp", 'density', 'xH_box'),
    direc='_cache'
)
[3]:
plotting.lightcone_sliceplot(lightcone);
../_images/tutorials_lightcones_5_0.png
[4]:
plotting.lightcone_sliceplot(lightcone, "density")
[4]:
(<Figure size 432x288 with 2 Axes>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7f5e93aaa4d0>)
../_images/tutorials_lightcones_6_1.png

Simple!

You can also save lightcones:

[5]:
filename = lightcone.save(direc='_cache')
[6]:
print(os.path.basename(filename))
LightCone_z7.0_da45d92043dfdc0c14f34f3ded434358_r287478667967.h5