Other modules

Pre-defined constants

The default cosmological constants in this package are the values derived from 7 year WMAP data. You can define new values using the following functions.

tools21cm.const.set_hubble_h(value)[source]

Define new hubble constant value (little h).

tools21cm.const.set_ns(value)[source]

Define new ns value.

tools21cm.const.set_omega_baryon(value)[source]

Define new omega baryon value.

tools21cm.const.set_omega_lambda(value)[source]

Define new omega lambda value.

tools21cm.const.set_omega_matter(value)[source]

Define new omega matter value.

tools21cm.const.set_sigma_8(value)[source]

Define new sigma_8 value.

For CUBEP3M and C2RAY simulations

Conversion factors

Various values and functions to deal with unit conversions regarding file types

tools21cm.conv.gridmass_to_msol(grid_mass)[source]

Convert a halo mass from simulation grid units to solar masses

Parameters:

gridmass (float or numpy array) – the mass in grid mass units

Returns:

The mass in log10(Msol)

tools21cm.conv.gridpos_to_mpc(gridpos)[source]

Convert a position or length in simulation grid units to Mpc

Parameters:

gridpos (float or numpy array) – the position in simulation grid units

Returns:

The position converted to Mpc with the origin unchanged

tools21cm.conv.gridvel_to_kms(gridvel, z)[source]

Convert a velocity in simulation grid units to km/s

Parameters:
  • gridvel (float or numpy array) – the velocity in simulation grid units

  • z (float or numpy array) – the redshift

Returns:

The velocity in km/s

tools21cm.conv.set_sim_constants(boxsize_cMpc)[source]

This method will set the values of relevant constants depending on the simulation

Parameters:

boxsize_cMpc (float) – the box size in cMpc/h. Valid values are 37, 47, 64, 114, 200, 244, 425 or 500

Returns:

Nothing.

Density file

class tools21cm.density_file.ClumpingFile(filename=None)[source]

A CubeP3M clumping factor file.

Use the read_from_file method to load a clumping factor file, or pass the filename to the constructor.

Some useful attributes of this class are:

  • raw_clumping (numpy array): the clumping factor in simulation units

  • z (float): the redshift of the file (-1 if it couldn’t be determined from the file name)

Methods

write_to_file(filename[, raw_clumping])

Write data to file in the same format as it is read.

read_from_file

write_to_file(filename, raw_clumping=None)[source]

Write data to file in the same format as it is read.

Parameters:
  • filename (string) – the file to write to.

  • raw_clumping (numpy array) – the clumping factor in simulation units

Returns:

Nothing

class tools21cm.density_file.DensityFile(filename=None, old_format=False)[source]

A CubeP3M density file.

Use the read_from_file method to load a density file, or pass the filename to the constructor.

Variables:
  • raw_density (numpy array) – the density in simulation units

  • cgs_density (numpy array) – the baryonic density in g/cm^3

  • z (float) – the redshift of the file (-1 if it couldn’t be determined from the file name)

Methods

write_to_file(filename[, raw_density, ...])

Write data to file in the same format as it is read.

read_from_file

write_to_file(filename, raw_density=None, cgs_density=None, old_format=False)[source]

Write data to file in the same format as it is read.

Parameters:
  • filename (string) – the file to write to.

  • raw_density (numpy array) – the density in simulation units

  • cgs_density (numpy array) – the baryonic density in g/cm^3

  • old_format = False (bool) – whether to use the old-style file format.

Returns:

Nothing

Ionisation rate file

class tools21cm.irate_file.IonRateFile(filename=None, old_format=False, binary_format=False)[source]

A C2Ray IonRates3 file.

Use the read_from_file method to load an IonRates3 file, or pass the filename to the constructor.

Variables:
  • irate (numpy array) – the ionization rate

  • z (float) – the redshift of the file (-1 if it couldn’t be determined from the file name)

Methods

read_from_file(filename[, old_format, ...])

Read data from file.

read_from_file(filename, old_format=False, binary_format=False)[source]

Read data from file.

Parameters:
  • filename (string) – the file to read from.

  • old_format = False (bool) – whether to use the old-style (32 bits) file format.

Returns:

Nothing

Ionisation fraction file

class tools21cm.xfrac_file.XfracFile(filename=None, old_format=False, neutral=False, binary_format=False)[source]

A C2Ray xfrac file.

Use the read_from_file method to load an xfrac file, or pass the filename to the constructor.

Variables:
  • xi (numpy array) – the ionized fraction

  • z (float) – the redshift of the file (-1 if it couldn’t be determined from the file name)

Methods

read_from_file(filename[, old_format, ...])

Read data from file.

write_to_file(filename, xi[, old_format, ...])

Write data to file.

read_from_file(filename, old_format=False, neutral=False, binary_format=False)[source]

Read data from file.

Parameters:
  • filename (string) – the file to read from.

  • old_format = False (bool) – whether to use the old-style (32 bits) file format.

    neutral = False (bool): whether the content is the neutral or ionized fraction binary_format = False (bool): whether the file is in Fortran unformatted or binary (no record separators) format

Returns:

Nothing

write_to_file(filename, xi, old_format=False, neutral=False, binary_format=False)[source]

Write data to file.

Parameters:
  • filename (string) – the file to write to.

  • xi (numpy array) – the ionized fraction

  • old_format = False (bool) – whether to use the old-style (32 bits) file format.

  • neutral = False (bool) – whether to write the neutral or ionized fraction

  • binary_format = False (bool) – whether the file is in Fortran unformatted or binary (no record separators) format

Returns:

Nothing