synthesizer.load_data.load_eagle

A submodule for loading EAGLE data into Synthesizer.

The EAGLE hdf5 data loading scripts have been taken from the eagle_io package (https://github.com/flaresimulations/eagle_IO/). This has been to make the call as self-contained as possible.

Functions

synthesizer.load_data.load_eagle.apply_CGSUnits_conversion(filename, dataset, dat, verbose=True)[source]

Apply CGS conversion to the dataset.

Parameters:
  • filename (str) – filename to read from

  • dataset (str) – dataset to read attribute

  • dat (array) – dataset array to apply conversion

  • verbose (bool) – verbose condition

Return type:

ndarray[tuple[int, ...], dtype[Any]]

Returns:

Numpy array of the dataset converted to CGS units

synthesizer.load_data.load_eagle.apply_PhotUnits(filename, dataset, dat, verbose=True)[source]

Apply photometric units to the dataset.

Parameters:
  • filename (str) – filename to read from

  • dataset (str) – dataset to read attribute

  • dat (array) – dataset array to apply conversion

  • verbose (bool) – verbose condition

Return type:

unyt_array[unyt_quantity]

Returns:

Unyt array of the dataset in the photometric units

synthesizer.load_data.load_eagle.apply_hfreeUnits_conversion(filename, dataset, dat, verbose=True)[source]

Read the required dataset from the eagle hdf5 file.

Parameters:
  • filename (str) – filename to read from

  • dataset (str) – dataset to read attribute

  • dat (array) – dataset array to apply conversion

  • verbose (bool) – verbose condition

Return type:

ndarray[tuple[int, ...], dtype[Any]]

Returns:

Numpy array of the dataset converted to h free units

synthesizer.load_data.load_eagle.apply_physicalUnits_conversion(filename, dataset, dat, verbose=True)[source]

Apply physical conversion to the dataset.

Parameters:
  • filename (str) – filename to read from

  • dataset (str) – dataset to read attribute

  • dat (array) – dataset array to apply conversion

  • verbose (bool) – verbose condition

Return type:

ndarray[tuple[int, ...], dtype[Any]]

Returns:

Numpy array of the dataset converted to physical units

synthesizer.load_data.load_eagle.assign_galaxy_prop(ii, zed, boxl, aperture, grpno, sgrpno, cop, s_grpno, s_sgrpno, s_imasses, s_masses, s_ages, s_Zsmooth, s_coords, s_hsml, s_oxygen, s_hydrogen, s_velocities, g_grpno, g_sgrpno, g_masses, g_Zsmooth, g_sfr, g_coords, g_hsml, verbose, s_kwargs={}, g_kwargs={})[source]

Load stellar and gas particle data into synthesizer galaxy object.

Parameters:
  • ii (int) – galaxy number

  • zed (float) – redshift

  • boxl (float) – simulation box side length

  • aperture (float) – aperture to use from centre of potential

  • grpno (array) – Group numbers in this chunk

  • sgrpno (array) – Subgroup numbers in this chunk

  • cop (array) – centre of potential of subhalos in this chunk

  • s_grpno (array) – Stellar particle group numbers

  • s_sgrpno (array) – Stellar particle subgroup numbers

  • s_imasses (np.ndarray) – Stellar particle initial masses in Msun

  • s_masses (np.ndarray) – Stellar particle current masses in Msun

  • s_ages (np.ndarray) – Stellar particle ages in Gyr

  • s_Zsmooth (np.ndarray) – Stellar particle smoothed metallicity

  • s_coords (np.ndarray) – Stellar particle coordinates in pMpc

  • s_hsml (np.ndarray) – Stellar particle smoothing length in pMpc

  • s_oxygen (np.ndarray) – Stellar particle abundance in oxygen

  • s_hydrogen (np.ndarray) – Stellar particle abundance in hydrogen

  • s_velocities (np.ndarray) – Stellar Velocities

  • g_grpno (np.ndarray) – Gas particle group number

  • g_sgrpno (np.ndarray) – Gas particle subgroup number

  • g_masses (np.ndarray) – Gas particle masses in Msun

  • g_Zsmooth (np.ndarray) – Gas particle smoothed metallicity

  • g_sfr (np.ndarray) – Gas particle instantaneous SFR in Msun/yr

  • g_coords (ndarray[tuple[int, ...], dtype[float32]]) – (np.ndarray): Gas particle coordinates in pMpc

  • g_hsml (np.ndarray) – Gas particle smoothing length in pMpc

  • verbose (bool) – Are we talking?

  • s_kwargs (dict) – kwargs for stars

  • g_kwargs (dict) – kwargs for gas

Return type:

Galaxy

Returns:

Galaxy

synthesizer galaxy object

synthesizer.load_data.load_eagle.get_age(scale_factors, z, args, numThreads=4)[source]

Convert scale factor to z.

Parameters:
  • scale_factors (array) – scale factor of the star particle

  • z (float) – redshift

  • args (namedtuple) – parser arguments passed on to this job

  • numThreads (int) – number of threads to use

Return type:

ndarray[tuple[int, ...], dtype[Any]]

Returns:

array of ages of the star particles in years

synthesizer.load_data.load_eagle.get_files(fileType, directory, tag)[source]

Fetch filename for the different eagle outputs for reading.

Parameters:
  • fileType (str) – type of file in the eagle outputs

  • directory (str) – eagle data file location

  • tag (string) – snapshot tag to load

Return type:

List[str]

Returns:

array of files to read

synthesizer.load_data.load_eagle.get_star_formation_time(scale_factor)[source]

Convert scale factor to z.

Parameters:

scale_factor (float) – scale factor of the star particle

Return type:

float

Returns:

age of the star particle in years

synthesizer.load_data.load_eagle.load_EAGLE(fileloc, args, tot_chunks=1535, verbose=False)[source]

Load EAGLE required EAGLE galaxy properties.

Parameters:
  • fileloc (string) – eagle data file location

  • args (namedtuple) – parser arguments passed on to this job

  • tot_chunks (int) – total number of files to process

  • verbose (bool) – Are we talking?

Return type:

List[Union[Galaxy, Never]]

Returns:

a dictionary of Galaxy objects with stars and gas components

synthesizer.load_data.load_eagle.load_EAGLE_shm(chunk, fileloc, tag, s_len, g_len, args, numThreads=1, dtype='float32', tot_chunks=1535, verbose=False)[source]

Load EAGLE required EAGLE galaxy properties.

Note, this function will use a memory mapped array to read in the data from the hdf5 files. This is much faster than reading in the data directly from the hdf5 files.

Parameters:
  • chunk (int) – file number to process

  • fileloc (string) – eagle data file location

  • tag (string) – snapshot tag to load

  • s_len (int) – total number of star particles

  • g_len (int) – total number of gas particles

  • args (namedtuple) – parser arguments passed on to this job

  • numThreads (int) – number of threads to use

  • dtype (numpy object) – data type of the array in memory

  • tot_chunks (int) – total number of files to process

  • verbose (bool) – Are we talking?

Return type:

List[Union[Galaxy, Never]]

Returns:

a dictionary of Galaxy objects with stars and gas components

synthesizer.load_data.load_eagle.np_shm_read(name, array_shape, dtype)[source]

Read the required numpy memmap array.

Parameters:
  • name (str) – location of the memmap

  • array_shape (tuple) – shape of the memmap array

  • dtype (str) – data type of the memmap array

Return type:

ndarray[tuple[int, ...], dtype[Any]]

Returns:

Required eagle array from numpy memmap location

synthesizer.load_data.load_eagle.read_array(ftype, directory, tag, dataset, numThreads=1, noH=False, physicalUnits=False, CGS=False, photUnits=False, verbose=True)[source]

Read the required dataset from the eagle hdf5 file.

Parameters:
  • ftype (str) – eagle file type to read

  • directory (str) – location of the eagle simulation directory

  • tag (str) – snapshot tag to read

  • dataset (str) – name of the dataset to read

  • numThreads (int) – number threads to use

  • noH (bool) – remove any reduced Hubble factors

  • physicalUnits (bool) – return in physical units

  • CGS (bool) – return in CGS units

  • photUnits (bool) – return in photometric units

  • verbose (bool) – verbose condition

Return type:

Union[ndarray[tuple[int, ...], dtype[Any]], unyt_array[unyt_quantity]]

Returns:

Numpy/unyt array from eagle hdf5 filetype

synthesizer.load_data.load_eagle.read_hdf5(filename, dataset)[source]

Read the required dataset from the eagle hdf5 file.

Parameters:
  • filename (str) – name of the hdf5 file

  • dataset (str) – name of the dataset to extract

Return type:

ndarray[tuple[int, ...], dtype[Any]]

Returns:

Numpy array of the required hdf5 dataset

synthesizer.load_data.load_eagle.read_header(ftype, directory, tag, dataset)[source]

Read the required header dataset from the eagle hdf5 file.

Ftype (str):

eagle file type to read

directory (str):

location of the eagle simulation directory

tag (str):

snapshot tag to read

dataset (str):

name of the dataset to read

Return type:

ndarray[tuple[int, ...], dtype[Any]]

Returns:

Reads in required eagle hdf5 header data