meraxes

meraxes.galaxy_history

Generate the full (first progenitor line) history of a galaxy.

dragons.meraxes.galaxy_history.galaxy_history(fname, gal_id, snapshot, future_snapshot=-1, pandas=False, props=None)[source]

Read in the full first progenitor history of a galaxy at a given final snapshot.

Parameters:
  • fname (str) – Full path to input hdf5 master file.

  • gal_id (int) – Unique ID of the target galaxy.

  • snapshot (int) – Snapshot at which the history is to be traced from.

  • props (list) – A list of galaxy properties requested. (default: All properties)

  • future_snapshot (int) – Also read in the future of the galaxy object up to this snapshot. (default: -1 [don’t read in future])

  • pandas (bool) – Return panads dataframe. (default = False)

Returns:

  • history (ndarray or DataFrame) – The requested first progenitor history. If future=True then the ndarray includes the future of this object.

  • merged_snapshot (int) – If future_snapshot != -1 then the snapshot at which the galaxy merged into another is also returned. If merged_snapshot = -1 then the galaxy remains until future_snapshot.

meraxes.io

Routines for reading Meraxes output files.

dragons.meraxes.io.check_for_global_xH(fname, xH, tol=0.1)[source]

Check a Meraxes output file for the presence of a particular global neutral fraction.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • xH (float) – Neutral fraction value

  • tol (float) – +- tolerance on neutral fraction value present. An error will be thrown of no redshift within this tollerance is found.

Returns:

  • snapshot (int) – Closest snapshot

  • redshift (float) – Closest corresponding redshift

  • xH (float) – Closest corresponding redshift

dragons.meraxes.io.check_for_redshift(fname, redshift, tol=0.1)[source]

Check a Meraxes output file for the presence of a particular redshift.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • redshift (float) – Redshift value

  • tol (float) – +- tolerance on redshift value present. An error will be thrown of no redshift within this tollerance is found.

Returns:

  • snapshot (int) – Closest snapshot

  • redshift (float) – Closest corresponding redshift

dragons.meraxes.io.grab_redshift(fname, snapshot)[source]

Quickly grab the redshift value of a single snapshot from a Meraxes HDF5 file.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • snapshot (int) – Snapshot for which the redshift is to grabbed

Returns:

redshift – Corresponding redshift value

Return type:

float

dragons.meraxes.io.grab_unsampled_snapshot(fname, snapshot)[source]

Quickly grab the unsampled snapshot value of a single snapshot from a Meraxes HDF5 file.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • snapshot (int) – Snapshot for which the unsampled value is to be grabbed

Returns:

redshift – Corresponding unsampled snapshot value

Return type:

float

dragons.meraxes.io.list_grids(spec, fname, snapshot)[source]

List the available grids from a Meraxes HDF5 output file.

Parameters:
  • spec (int) – Specify the grid you want to read. 0 -> Reionization grid 1 -> Metal grid

  • fname (str) – Full path to input hdf5 master file

  • snapshot (int) – Snapshot for which the grids are to be listed.

Returns:

grids – A list of the available grids

Return type:

list

dragons.meraxes.io.read_descendant_indices(fname, snapshot, pandas=False)[source]

Read the Descendant indices from the Meraxes HDF5 file.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • snapshot (int) – Snapshot from which the descendant dataset is to be read from.

  • pandas (bool) – Return a pandas series instead of a numpy array. (default = False)

Returns:

desc_ind – NextProgenitor indices

Return type:

array

dragons.meraxes.io.read_firstprogenitor_indices(fname, snapshot, pandas=False)[source]

Read the FirstProgenitor indices from the Meraxes HDF5 file.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • snapshot (int) – Snapshot from which the progenitors dataset is to be read from.

  • pandas (bool) – Return a pandas series instead of a numpy array. (default = False)

Returns:

fp_ind – FirstProgenitor indices

Return type:

array or series

dragons.meraxes.io.read_gals(fname, snapshot=None, props=None, sim_props=False, pandas=False, table=False, h=None, indices=None)[source]

Read in a Meraxes hdf5 output file.

Reads in the default type of HDF5 file generated by the code.

Parameters:
  • fname (str) – Full path to input hdf5 master file.

  • snapshot (int) – The snapshot to read in. (default: last present snapshot - usually z=0)

  • props (list) – A list of galaxy properties requested. (default: All properties)

  • sim_props (bool) – Output some simulation properties as well. (default = False)

  • pandas (bool) – Ouput a pandas DataFrame instead of an astropy table. (default = False)

  • table (bool) – Output an astropy Table instead of a numpy ndarray. (default = False)

  • h (float) – Hubble constant (/100) to scale the galaxy properties to. If None then no scaling is made unless set_little_h was previously called. (default = None)

  • indices (list or array) – Indices of galaxies to be read. If None then read all galaxies. (default = None)

Returns:

  • An ndarray with the requested galaxies and properties.

  • If sim_props==True then output is a tuple of form (galaxies, sim_props)

dragons.meraxes.io.read_git_info(fname)[source]

Read the git diff and ref saved in the master file.

Parameters:

fname (str) – Full path to input hdf5 master file.

Returns:

  • ref (str) – git ref of the model

  • diff (str) – git diff of the model

dragons.meraxes.io.read_global_J_21(fname, snapshot)[source]

Read the volume weighted global J_21 from the Meraxes output.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • snapshot (int or list) – Snapshot(s) from which the global J_21 is to be read from.

Returns:

global_J_21 – Global J_21 value(s)

Return type:

float or ndarray

dragons.meraxes.io.read_global_xH(fname, snapshot, weight='volume')[source]

Read global xH from the Meraxes HDF5 file.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • snapshot (int or list) – Snapshot(s) from which the global xH is to be read from.

  • weight (str) – ‘volume’ -> volume weighted ‘mass’ -> mass weighted

Returns:

global_xH – Global xH value(s)

Return type:

float or ndarray

dragons.meraxes.io.read_grid(spec, fname, snapshot, name, h=None, h_scaling={})[source]

Read a grid from the Meraxes HDF5 file.

Parameters:
  • spec (int) – Specify the grid you want to read. 0 -> Reionization grid 1 -> Metal grid

  • fname (str) – Full path to input hdf5 master file

  • snapshot (int) – Snapshot from which the grid is to be read from.

  • name (str) – Name of the requested grid

  • h (float) – Hubble constant (/100) to scale the galaxy properties to. If None then no scaling is made unless set_little_h was previously called. (default = None)

  • h_scaling (dict) – Dictionary of grid names (keys) and associated Hubble constant scalings (values) as lambda functions. e.g. | h_scaling = {“MassLikeGrid” : lambda x, h: x/h,}

Returns:

The requested grid

Return type:

ndarray

dragons.meraxes.io.read_input_params(fname, h=None, raw=False)[source]

Read in the input parameters from a Meraxes hdf5 output file.

Parameters:
  • fname (str) – Full path to input hdf5 master file.

  • h (float) – Hubble constant (/100) to scale the galaxy properties to. If None then no scaling is made unless set_little_h was previously called. (default = None)

  • raw (bool) – Don’t augment with extra useful quantities. (default = False)

Returns:

All run properties.

Return type:

dict

dragons.meraxes.io.read_nextprogenitor_indices(fname, snapshot, pandas=False)[source]

Read the NextProgenitor indices from the Meraxes HDF5 file.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • snapshot (int) – Snapshot from which the progenitors dataset is to be read from.

  • pandas (bool) – Return a pandas series instead of a numpy array. (default = False)

Returns:

np_ind – NextProgenitor indices

Return type:

array

dragons.meraxes.io.read_ps(fname, snapshot)[source]

Read 21cm power spectrum from the Meraxes HDF5 file.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • snapshot (int) – Snapshot from which the power spectrum is to be read from.

Returns:

  • kval (array) – k value (Mpc^-1)

  • ps (array) – power value (should be dimensionless but actually might be power density i.e. with units [Mpc^-3])

  • pserr (array) – error

dragons.meraxes.io.read_snaplist(fname, h=None)[source]

Read in the list of available snapshots from the Meraxes hdf5 file.

Parameters:
  • fname (str) – Full path to input hdf5 master file.

  • h (float) – Hubble constant (/100) to scale the galaxy properties to. If None then no scaling is made unless set_little_h was previously called. (default = None)

Returns:

  • snaps (array) – snapshots

  • redshifts (array) – redshifts

  • lt_times (array) – light travel times (Myr)

dragons.meraxes.io.read_units(fname)[source]

Read in the units and hubble conversion information from a Meraxes hdf5 output file.

Parameters:

fname (str) – Full path to input hdf5 master file.

Returns:

units – A dict containing all units (Hubble conversions are stored with key HubbleConversions).

Return type:

dict

dragons.meraxes.io.set_little_h(h=None)[source]

Set the value of little h to be used by all future meraxes.io calls where applicable.

Parameters:

h (float or str) – Little h value. If a filename is passed as a string, then little h will be set to the simulation value read from that file. (default: None)

Returns:

h – Little h value.

Return type:

float

meraxes.reion

Routines for reionisation related calculations.

dragons.meraxes.reion.electron_optical_depth(fname, volume_weighted=False)[source]

Calculate the electron Thomson scattering optical depth from a Meraxes + 21cmFAST run. Note that this implementation assumes that the simulation volume is fully ionised before the final snapshot stored in the input file.

Parameters:
  • fname (str) – Full path to input hdf5 master file

  • volume_weighted (bool) – This option is just for testing purposes as it can take a long time to mass weight the neutral fraction depending on the grid size. The optical depth obtained is often very similar to the correctly mass weighted value, however, this should not be used to final results.

Returns:

  • z_list (ndarray) – Redshifts of each snapshot read in the input simulation.

  • scattering_depth (ndarray) – Thomson scattering depth integrated between z=0 and each snapshot of the input simulation.

meraxes.plots