yt.frontends.stream.data_structures.load_uniform_grid

yt.frontends.stream.data_structures.load_uniform_grid(data, domain_dimensions, length_unit=None, bbox=None, nprocs=1, sim_time=0.0, mass_unit=None, time_unit=None, velocity_unit=None, magnetic_unit=None, periodicity=(True, True, True), geometry='cartesian')[source]

Load a uniform grid of data into yt as a StreamHandler.

This should allow a uniform grid of data to be loaded directly into yt and analyzed as would any others. This comes with several caveats:

  • Units will be incorrect unless the unit system is explicitly specified.
  • Some functions may behave oddly, and parallelism will be disappointing or non-existent in most cases.
  • Particles may be difficult to integrate.

Particle fields are detected as one-dimensional fields. The number of particles is set by the “number_of_particles” key in data.

Parameters:

data : dict

This is a dict of numpy arrays or (numpy array, unit spec) tuples. The keys are the field names.

domain_dimensions : array_like

This is the domain dimensions of the grid

length_unit : string

Unit to use for lengths. Defaults to unitless.

bbox : array_like (xdim:zdim, LE:RE), optional

Size of computational domain in units specified by length_unit. Defaults to a cubic unit-length domain.

nprocs: integer, optional :

If greater than 1, will create this number of subarrays out of data

sim_time : float, optional

The simulation time in seconds

mass_unit : string

Unit to use for masses. Defaults to unitless.

time_unit : string

Unit to use for times. Defaults to unitless.

velocity_unit : string

Unit to use for velocities. Defaults to unitless.

magnetic_unit : string

Unit to use for magnetic fields. Defaults to unitless.

periodicity : tuple of booleans

Determines whether the data will be treated as periodic along each axis

geometry : string or tuple

“cartesian”, “cylindrical”, “polar”, “spherical”, “geographic” or “spectral_cube”. Optionally, a tuple can be provided to specify the axis ordering – for instance, to specify that the axis ordering should be z, x, y, this would be: (“cartesian”, (“z”, “x”, “y”)). The same can be done for other coordinates, for instance: (“spherical”, (“theta”, “phi”, “r”)).

Examples

>>> bbox = np.array([[0., 1.0], [-1.5, 1.5], [1.0, 2.5]])
>>> arr = np.random.random((128, 128, 128))
>>> data = dict(density = arr)
>>> ds = load_uniform_grid(data, arr.shape, length_unit='cm',
                           bbox=bbox, nprocs=12)
>>> dd = ds.all_data()
>>> dd['Density']

#FIXME YTArray[123.2856, 123.854, ..., 123.456, 12.42] (code_mass/code_length^3)

>>> data = dict(density = (arr, 'g/cm**3'))
>>> ds = load_uniform_grid(data, arr.shape, 3.03e24, bbox=bbox, nprocs=12)
>>> dd = ds.all_data()
>>> dd['Density']

#FIXME YTArray[123.2856, 123.854, ..., 123.456, 12.42] (g/cm**3)