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.
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
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
- 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.
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