Data Containers
yt provides a number of data containers, defined such that they satisfy a
logical need. Each of these provides only the finest-resolution cells, unless
an option is available to restrict the levels from which they draw, as is the
case with EnzoCoveringGrid.
Each of these implements the same primary protocol - all data values can be
access dictionary-style:
>>> object["Density"]
>>> object["Density"].max()
And so on. For more information, see the
the tutorial topic on basic objects.
Base Containers
-
class yt.lagos.EnzoData(pf, fields, **kwargs)
Generic EnzoData container. By itself, will attempt to
generate field, read fields (method defined by derived classes)
and deal with passing back and forth field parameters.
Typically this is never called directly, but only due to inheritance.
It associates a EnzoStaticOutput with the class,
sets its initial set of fields, and the remainder of the arguments
are passed as field_parameters.
-
clear_data()
- Clears out all data from the EnzoData instance, freeing memory.
-
convert(datatype)
- This will attempt to convert a given unit to cgs from code units.
It either returns the multiplicative factor or throws a KeyError.
-
get_field_parameter(name, default=None)
- This is typically only used by derived field functions, but
it returns parameters used to generate fields.
-
has_field_parameter(name)
- Checks if a field parameter is set.
-
has_key(key)
- Checks if a data field already exists.
-
set_field_parameter(name, val)
- Here we set up dictionaries that get passed up and down and ultimately
to derived fields.
-
class yt.lagos.Enzo1DData(pf, fields, **kwargs)
Bases: yt.lagos.BaseDataTypes.EnzoData, yt.lagos.BaseDataTypes.GridPropertiesMixin
-
clear_data()
- Clears out all data from the EnzoData instance, freeing memory.
-
convert(datatype)
- This will attempt to convert a given unit to cgs from code units.
It either returns the multiplicative factor or throws a KeyError.
-
get_field_parameter(name, default=None)
- This is typically only used by derived field functions, but
it returns parameters used to generate fields.
-
has_field_parameter(name)
- Checks if a field parameter is set.
-
has_key(key)
- Checks if a data field already exists.
-
select_grids(level)
- Return all grids on a given level.
-
set_field_parameter(name, val)
- Here we set up dictionaries that get passed up and down and ultimately
to derived fields.
-
class yt.lagos.Enzo2DData(axis, fields, pf=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.EnzoData, yt.lagos.BaseDataTypes.GridPropertiesMixin
Prepares the Enzo2DData, normal to axis. If axis is 4, we are not
aligned with any axis.
-
clear_data()
- Clears out all data from the EnzoData instance, freeing memory.
-
convert(datatype)
- This will attempt to convert a given unit to cgs from code units.
It either returns the multiplicative factor or throws a KeyError.
-
get_data(fields=None)
- Iterates over the list of fields and generates/reads them all.
-
get_field_parameter(name, default=None)
- This is typically only used by derived field functions, but
it returns parameters used to generate fields.
-
has_field_parameter(name)
- Checks if a field parameter is set.
-
has_key(key)
- Checks if a data field already exists.
-
interpolate_discretize(LE, RE, field, side, log_spacing=True)
- This returns a uniform grid of points between LE and RE,
interpolated using the nearest neighbor method, with side points on a
side.
-
select_grids(level)
- Return all grids on a given level.
-
set_field_parameter(name, val)
- Here we set up dictionaries that get passed up and down and ultimately
to derived fields.
-
class yt.lagos.Enzo3DData(center, fields, pf=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.EnzoData, yt.lagos.BaseDataTypes.GridPropertiesMixin
Returns an instance of Enzo3DData, or prepares one. Usually only
used as a base class. Note that center is supplied, but only used
for fields and quantities that require it.
-
clear_data()
- Clears out all data from the EnzoData instance, freeing memory.
-
convert(datatype)
- This will attempt to convert a given unit to cgs from code units.
It either returns the multiplicative factor or throws a KeyError.
- This function will create a set of contour objects, defined
by having connected cell structures, which can then be
studied and used to ‘paint’ their source grids, thus enabling
them to be plotted.
- Return an ExtractedRegion where the points contained in it are defined
as the points in this data object with the given indices.
-
get_field_parameter(name, default=None)
- This is typically only used by derived field functions, but
it returns parameters used to generate fields.
-
has_field_parameter(name)
- Checks if a field parameter is set.
-
has_key(key)
- Checks if a data field already exists.
-
paint_grids(field, value, default_value=None)
This function paints every cell in our dataset with a given value.
If default_value is given, the other values for the given in every grid
are discarded and replaced with default_value. Otherwise, the field is
mandated to ‘know how to exist’ in the grid.
Note that this only paints the cells in the dataset, so cells in grids
with child cells are left untouched.
-
select_grids(level)
- Return all grids on a given level.
-
set_field_parameter(name, val)
- Here we set up dictionaries that get passed up and down and ultimately
to derived fields.
-
class yt.lagos.FakeGridForParticles(grid)
- Mock up a grid to insert particle positions and radii
into for purposes of confinement in an Enzo3DData.
1D Data Containers
Each of these inherits from Enzo1DData, and so has all the
member functions defined there.
-
class yt.lagos.EnzoOrthoRayBase(axis, coords, fields=None, pf=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo1DData
Dimensionality is reduced to one, and an ordered list of points at an
(x,y) tuple along axis are available.
2D Data Containers
-
class yt.lagos.EnzoSliceBase(axis, coord, fields=None, center=None, pf=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo2DData
EnzoSlice is an orthogonal slice through the data, taking all the points
at the finest resolution available and then indexing them. It is more
appropriately thought of as a slice ‘operator’ than an object,
however, as its field and coordinate can both change.
Slice along axisHow do I specify an axis?, at the coordinate coord.
Optionally supply fields.
-
reslice(coord)
- Change the entire dataset, clearing out the current data and slicing at
a new location. Not terribly useful except for in-place plot changes.
-
shift(val)
- Moves the slice coordinate up by either a floating point value, or an
integer number of indices of the finest grid.
-
class yt.lagos.EnzoCuttingPlaneBase(normal, center, fields=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo2DData
EnzoCuttingPlane is an oblique plane through the data,
defined by a normal vector and a coordinate. It attempts to guess
an ‘up’ vector, which cannot be overridden, and then it pixelizes
the appropriate data onto the plane without interpolation.
The Cutting Plane slices at an oblique angle, where we use
the normal vector and the center to define the viewing plane.
The ‘up’ direction is guessed at automatically.
-
class yt.lagos.EnzoProjBase(axis, field, weight_field=None, max_level=None, center=None, pf=None, source=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo2DData
EnzoProj is a projection of a field along an axis. The field
can have an associated weight_field, in which case the values are
multiplied by a weight before being summed, and then divided by the sum
of that weight.
3D Data Containers
-
class yt.lagos.EnzoSphereBase(center, radius, fields=None, pf=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo3DData
A sphere of points
The most famous of all the data objects, we define it via a
center and a radius.
-
class yt.lagos.EnzoRegionBase(center, left_edge, right_edge, fields=None, pf=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo3DData
EnzoRegions are rectangular prisms of data.
We create an object with a set of three left_edge coordinates,
three right_edge coordinates, and a center that need not be the
center.
-
class yt.lagos.EnzoCylinderBase(center, normal, radius, height, fields=None, pf=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo3DData
We can define a cylinder (or disk) to act as a data object.
By providing a center, a normal, a radius and a height we
can define a cylinder of any proportion. Only cells whose centers are
within the cylinder will be selected.
-
class yt.lagos.EnzoGridCollection(center, grid_list, fields=None, connection_pool=True, pf=None, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo3DData
An arbitrary selection of grids, within which we accept all points.
By selecting an arbitrary grid_list, we can act on those grids.
Child cells are not returned.
-
class yt.lagos.EnzoCoveringGrid(level, left_edge, right_edge, dims, fields=None, pf=None, num_ghost_zones=0, use_pbar=True, **kwargs)
Bases: yt.lagos.BaseDataTypes.Enzo3DData
Covering grids represent fixed-resolution data over a given region.
In order to achieve this goal – for instance in order to obtain ghost
zones – grids up to and including the indicated level are included.
No interpolation is done (as that would affect the ‘power’ on small
scales) on the input data.
The data object returned will consider grids up to level in
generating fixed resolution data between left_edge and right_edge
that is dims (3-values) on a side.
-
flush_data(field=None)
- Any modifications made to the data in this object are pushed back
to the originating grids, except the cells where those grids are both
below the current level and have child cells.
-
class yt.lagos.EnzoSmoothedCoveringGrid(*args, **kwargs)
- Bases: yt.lagos.BaseDataTypes.EnzoCoveringGrid
Bases: yt.lagos.BaseDataTypes.Enzo3DData
ExtractedRegions are arbitrarily defined containers of data, useful
for things like selection along a baryon field.
Derived Quantities
All of these are accessed via the .quantities[] object, and feeding it the
function name without the leading underscore. For instance:
my_sphere.quantities["TotalMass"]()
They all accept the lazy_reader option, which governs whether the
calculation is performed out of core or not.
-
yt.lagos.DerivedQuantities._TotalMass(data)
- This function takes no arguments and returns the sum of cell masses and
particle masses in the object.
-
yt.lagos.DerivedQuantities._CenterOfMass(data)
- This function takes no arguments and returns the location of the center
of mass of the non-particle data in the object.
-
yt.lagos.DerivedQuantities._WeightedAverageQuantity(data, field, weight)
This function returns an averaged quantity.
Parameters: |
- field – The field to average
- weight – The field to weight by
|
-
yt.lagos.DerivedQuantities._BulkVelocity(data)
- This function returns the mass-weighted average velocity in the object.
-
yt.lagos.DerivedQuantities._AngularMomentumVector(data)
- This function returns the mass-weighted average angular momentum vector.
-
yt.lagos.DerivedQuantities._BaryonSpinParameter(data)
- This function returns the spin parameter for the baryons, but it uses
the particles in calculating enclosed mass.
-
yt.lagos.DerivedQuantities._IsBound(data, truncate=True, include_thermal_energy=False)
This returns whether or not the object is gravitationally bound
Parameters: |
- truncate – Should the calculation stop once the ratio of
gravitational:kinetic is 1.0?
- include_thermal_energy – Should we add the energy from ThermalEnergy
on to the kinetic energy to calculate
binding energy?
|
-
yt.lagos.DerivedQuantities._Extrema(data, fields)
This function returns the extrema of a set of fields
Parameters: |
- fields – A field name, or a list of field names
|