File classes

Each type of data file is represented by a class. There are classes for ionization fraction, density, velocity and halos. These are all documented below.

class c2raytools.XfracFile(filename=None, old_format=False)

A C2Ray xfrac file.

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

Some useful attributes of this class are:
  • xi (numpy array): the ionized fraction
  • z (float): the redshift of the file (-1 if it couldn’t be determined from the file name)
read_from_file(filename, old_format=False)

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
class c2raytools.DensityFile(filename=None, old_format=False)

A CubeP3M density file.

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

Some useful attributes of this class are:

  • 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)
read_from_file(filename, old_format=False)

Read data from file.

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

  • old_format = False (bool): whether to use the old-style

    file format.

Returns:
Nothing
class c2raytools.VelocityFile(filename=None)

A CubeP3M velocity/momentum file.

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

Some useful attributes of this class are:

  • raw_velocity (numpy array): the velocity in simulation units
  • z (float): the redshift of the file (-1 if it couldn’t be determined from the file name)

To get the velocity in km/s, use get_kms_from_density

get_kms_from_density(density)

Get the velocity in kms. Since the file stores momentum rather than velocity, we need the density for this.

Parameters:
  • density (string, DensityFile object or numpy array): the density

    or a file to read the density from.

Returns:
A numpy array with the same dimensions as the simulation box, containing the velocity in km/s.
read_from_file(filename)

Read data from file. Sets the instance variables self.raw_velocity and self.kmsrho8

Parameters:
  • filename (string): the file to read from.
Returns:
Nothing
class c2raytools.HaloList(filename=None, min_select_mass=0.0, max_select_mass=None, max_select_number=-1, startline=0)

A class that holds information about a large number of halos, as read from a halo list file. Contains methods to select halos based on different criteria. This file is very slow if you need to read a large number of halos.

TODO: write a better implementation of this class.

read_from_file(filename, min_select_mass=0.0, max_select_mass=None, max_select_number=-1, startline=0)

Read a halo list.

Parameters:
  • filename (string): The file to read from

  • min_select_mass = 0.0 (float): The lower threshold mass in solar masses.

    Only halos above this mass will be read.

  • max_select_mass = None (float): The upper threshold mass in solar masses.

    Only halos below this mass will be read. If None, there is no limit.

  • max_select_number = -1 (int): The max number of halos to read. If -1, there

    is no limit.

  • startline = 0 (int): The line in the file where reading will start.

Returns:
True if all the halos were read. False otherwise.

Previous topic

Tutorial

Next topic

Visualizing data

This Page