Module API

mesh_illustris.core module

core codes of the mesh_illustris package.

class mesh_illustris.core.Dataset(datasets, n_chunk)

Bases: object

Dataset class stores a snapshot of simulation.

property datasets

Chunks that store the snapshot of simulation.

Type

list of SingleDataset

property n_chunk

Number of chunks.

Type

int

box(boundary, partType, fields, mdi=None, float32=False)

Load a sub-box of data.

Parameters
  • boundary (numpy.ndarray of scalar) – Boundary of the box, with shape of (3, 2).

  • partType (str or list of str) – Particle types to be loaded.

  • fields (str or list of str) – Particle fields to be loaded.

  • mdi (None or list of int, default to None) – sub-indeces to be loaded. None to load all.

  • float32 (bool, default to False) – Whether to use float32 or not.

Returns

Sub-box of data.

Return type

dict

sphere(center, radius, partType, fields, mdi=None, float32=False)

Load a sub-sphere of data.

Parameters
  • center (numpy.ndarray of scalar) – Center of the sphere, with shape of (3,).

  • radius (scalar) – Radius of the sphere.

  • partType (str or list of str) – Particle types to be loaded.

  • fields (str or list of str) – Particle fields to be loaded.

  • mdi (None or list of int, default to None) – sub-indeces to be loaded. None to load all.

  • float32 (bool, default to False) – Whether to use float32 or not.

Returns

Sub-sphere of data.

Return type

dict

class mesh_illustris.core.SingleDataset(fn, partType, depth=8, index_path=None)

Bases: object

SingleDataset class stores a chunck of snapshot.

property fn

File name to be loaded.

Type

str

property partType

Particle types to be loaded.

Type

str or list of str

property box_size

Box size of the simulation.

Type

scalar

property index

Newly generated or cached index of the Dataset.

Type

dict

box(boundary, partType, fields, mdi=None, float32=True, method='outer')

Slicing method to load a sub-box of data.

Note: The current version only support loading the outer or inner

box of the sub-box. Loading the exact sub-box is not supported.

Parameters
  • boundary (numpy.ndarray of scalar) – Boundary of the box, with shape of (3, 2).

  • partType (str or list of str) – Particle types to be loaded.

  • fields (str or list of str) – Particle fields to be loaded.

  • mdi (None or list of int, default to None) – sub-indeces to be loaded. None to load all.

  • float32 (bool, default to False) – Whether to use float32 or not.

  • method (str, default to "outer") – How to load the box, must be “outer” or “exact” or “inner”.

Returns

Sub-box of data.

Return type

dict

sphere(center, radius, partType, fields, mdi=None, method='outer')

Slicing method to load a sub-sphere of data.

Note: This function is not supported in the current version

Parameters
  • center (numpy.ndarray of scalar) – Center of the sphere, with shape of (3,).

  • radius (scalar) – Radius of the sphere.

  • partType (str or list of str) – Particle types to be loaded.

  • fields (str or list of str) – Particle fields to be loaded.

  • mdi (None or list of int, default to None) – sub-indeces to be loaded. None to load all.

  • float32 (bool, default to False) – Whether to use float32 or not.

  • method (str, default to "outer") – How to load the box, must be “outer” or “exact” or “inner”.

mesh_illustris.il_util module

il_util module defines some commonly used functions for Illustris.

mesh_illustris.il_util.loadFile(fn, partType, fields=None, mdi=None, float32=True, index=None)

Load a subset of particles/cells in one chunk file. This function applies numpy.memmap to minimize memory usage.

Parameters
  • fn (str) – File name to be loaded.

  • partType (str or list of str) – Particle types to be loaded.

  • fields (str or list of str) – Particle fields to be loaded.

  • mdi (None or list of int, default to None) – sub-indeces to be loaded. None to load all.

  • float32 (bool, default to False) – Whether to use float32 or not.

  • index (list of list of int) – List of Fancy indices for slicing.

Returns

Entire or subset of data, depending on whether index == None.

Return type

dict

mesh_illustris.il_util.partTypeNum(partType)

Map common names to numeric particle types.

Parameters

partType (str) – Common names of particle type.

Returns

Numeric particle type.

Return type

int

mesh_illustris.il_util.snapPath(basePath, snapNum, chunkNum=0)

Return path to a chunk file of snapshot.

Parameters
  • basePath (str) – Base path of the simulation data. This path usually ends with “output”.

  • snapNum (int) – Number of the snapshot.

  • chunkNum (int, default to 0) – Number of the chunk.

Returns

Path to a chunk file.

Return type

str

mesh_illustris.loader module

loader module defines a convenient load() function to load snapshots in Illustris or IllustrisTNG.

mesh_illustris.loader.load(basePath, snapNum, partType, depth=8, index_path=None)

Function to load snapshots in Illustris or IllustrisTNG.

Parameters
  • basePath (str) – Base path of the simulation data. This path usually ends with “output”.

  • snapNum (int) – Number of the snapshot.

  • partType (str or list of str) – Particle types to be loaded.

  • depth (int, default to 8) – Depth of mesh. For example, depth = 8 corresponds to the mesh dimension of (2^8, 2^8, 2^8).

  • index_path (str) – Path to store the index files. None to store with the data.

Returns

Structured data.

Return type

Dataset

mesh_illustris.mesh module

mesh module defines the Mesh to tessellate the entire volume.

class mesh_illustris.mesh.Mesh(pos, length, offset, boundary, depth)

Bases: object

Mesh class tessellates the entire volume.

property boundary

Boundary of the box, with shape of (3, 2).

Type

numpy.ndarray of scalar

property depth

Depth of Mesh. For example, depth = 8 corresponds to the Mesh dimension of (2^8, 2^8, 2^8)

Type

int, default to 8

build()

Build index for the points according to the Mesh. The indexing process produces a “rand” and a “mark” variables, which link the index of each point to its location in the Mesh.

Returns

(rank, mark).

Return type

tuple of numpy.ndarray of int