hyperion.grid.CartesianGrid

class hyperion.grid.CartesianGrid(*args)

A cartesian grid.

The grid can be initialized by passing the x, y, and z coordinates of cell walls:

>>> grid = CartesianGrid(x_wall, y_wall, z_wall)

where x_wall, y_wall, and z_wall are 1-d sequences of wall positions. The number of cells in the resulting grid will be one less in each dimension that the length of these arrays.

CartesianGrid objects may contain multiple quantities (e.g. density, specific energy). To access these, you can specify the name of the quantity as an item:

>>> grid['density']

which is no longer a CartesianGrid object, but a CartesianGridView object. When setting this for the first time, this can be set either to another CartesianGridView object, an external h5py link, or an empty list. For example, the following should work:

>>> grid['density_new'] = grid['density']

CartesianGridView objects allow the specific dust population to be selected as an index:

>>> grid['density'][0]

Which is also a CartesianGridView object. The data can then be accessed with the array attribute:

>>> grid['density'][0].array

which is a 3-d array of the requested quantity.

Methods

set_walls(self, x_wall, y_wall, z_wall)

read(self, group[, quantities])

Read the geometry and physical quantities from a cartesian grid

read_geometry(self, group)

Read in geometry information from a cartesian grid

read_quantities(self, group[, quantities])

Read in physical quantities from a cartesian grid

write(self, group[, quantities, copy, …])

Write out the cartesian grid

write_single_array(self, group, name, array)

Write out a single quantity, checking for consistency with geometry

add_derived_quantity(self, name, function)

to_yt(self[, dust_id])

Convert cartesian grid to a yt object (requires yt)

Methods (detail)

set_walls(self, x_wall, y_wall, z_wall)
read(self, group, quantities='all')

Read the geometry and physical quantities from a cartesian grid

Parameters
grouph5py.Group

The HDF5 group to read the grid from. This group should contain groups named ‘Geometry’ and ‘Quantities’.

quantities‘all’ or list

Which physical quantities to read in. Use ‘all’ to read in all quantities or a list of strings to read only specific quantities.

read_geometry(self, group)

Read in geometry information from a cartesian grid

Parameters
grouph5py.Group

The HDF5 group to read the grid geometry from.

read_quantities(self, group, quantities='all')

Read in physical quantities from a cartesian grid

Parameters
grouph5py.Group

The HDF5 group to read the grid quantities from

quantities‘all’ or list

Which physical quantities to read in. Use ‘all’ to read in all quantities or a list of strings to read only specific quantities.

write(self, group, quantities='all', copy=True, absolute_paths=False, compression=True, wall_dtype=<class 'float'>, physics_dtype=<class 'float'>)

Write out the cartesian grid

Parameters
grouph5py.Group

The HDF5 group to write the grid to

quantities‘all’ or list

Which physical quantities to write out. Use ‘all’ to write out all quantities or a list of strings to write only specific quantities.

copybool

Whether to copy external links, or leave them as links.

absolute_pathsbool

If copy is False, then this indicates whether to use absolute or relative paths for links.

compressionbool

Whether to compress the arrays in the HDF5 file

wall_dtypetype

The datatype to use to write the wall positions

physics_dtypetype

The datatype to use to write the physical quantities

write_single_array(self, group, name, array, copy=True, absolute_paths=False, compression=True, physics_dtype=<class 'float'>)

Write out a single quantity, checking for consistency with geometry

Parameters
grouph5py.Group

The HDF5 group to write the grid to

namestr

The name of the array in the group

arraynp.ndarray

The array to write out

copybool

Whether to copy external links, or leave them as links.

absolute_pathsbool

If copy is False, then this indicates whether to use absolute or relative paths for links.

compressionbool

Whether to compress the arrays in the HDF5 file

wall_dtypetype

The datatype to use to write the wall positions

physics_dtypetype

The datatype to use to write the physical quantities

add_derived_quantity(self, name, function)
to_yt(self, dust_id=0)

Convert cartesian grid to a yt object (requires yt)

This can only be used for regular cartesian grids

Parameters
dust_idint, optional

The ID of the dust population to extract. If not set, this defaults to 0 (the first dust population).

class hyperion.grid.CartesianGridView(grid, quantity)

Methods

append(self, grid)

Used to append quantities from another grid

add(self, grid)

Used to add quantities from another grid

Methods (detail)

append(self, grid)

Used to append quantities from another grid

Parameters
grid3D Numpy array or CartesianGridView instance

The grid to copy the quantity from

add(self, grid)

Used to add quantities from another grid

Parameters
grid3D Numpy array or CartesianGridView instance

The grid to copy the quantity from