yt.lagos Physical and Derived Data Objects

yt.lagos.BaseDataTypes Data Containers and Physical Objects

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 AMRCoveringGrid.

Each of these implements the same primary protocol - all data values can be accessed dictionary-style:

>>> object["Density"]
>>> object["Density"].max()

For more information about objects, see Object Methodology and Using and Manipulating Objects and Fields.

Base Classes

class yt.lagos.AMRData(pf, fields, **kwargs)

Generic AMRData 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 StaticOutput 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 AMRData 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.
save_object(name, filename=None)
Save an object. If filename is supplied, it will be stored in a shelve file of that name. Otherwise, it will be stored via yt.lagos.AMRHierarchy.save_object().
set_field_parameter(name, val)
Here we set up dictionaries that get passed up and down and ultimately to derived fields.
class yt.lagos.AMR1DData(pf, fields, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMRData, yt.lagos.BaseDataTypes.GridPropertiesMixin

clear_data()
Clears out all data from the AMRData 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.
save_object(name, filename=None)
Save an object. If filename is supplied, it will be stored in a shelve file of that name. Otherwise, it will be stored via yt.lagos.AMRHierarchy.save_object().
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.AMR2DData(axis, fields, pf=None, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMRData, yt.lagos.BaseDataTypes.GridPropertiesMixin, yt.lagos.ParallelTools.ParallelAnalysisInterface

Prepares the AMR2DData, normal to axis. If axis is 4, we are not aligned with any axis.

clear_data()
Clears out all data from the AMRData 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.
save_object(name, filename=None)
Save an object. If filename is supplied, it will be stored in a shelve file of that name. Otherwise, it will be stored via yt.lagos.AMRHierarchy.save_object().
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.AMR3DData(center, fields, pf=None, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMRData, yt.lagos.BaseDataTypes.GridPropertiesMixin

Returns an instance of AMR3DData, 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 AMRData 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.
cut_region(field_cuts)
Return an InLineExtractedRegion, where the grid cells are cut on the fly with a set of field_cuts.
extract_connected_sets(field, num_levels, min_val, max_val, log_space=True, cumulative=True, cache=False)
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.
extract_region(indices)
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.

save_object(name, filename=None)
Save an object. If filename is supplied, it will be stored in a shelve file of that name. Otherwise, it will be stored via yt.lagos.AMRHierarchy.save_object().
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 AMR3DData.

1D Data Containers

Each of these inherits from AMR1DData, and so has all the member functions defined there.

class yt.lagos.AMROrthoRayBase(axis, coords, fields=None, pf=None, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR1DData

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.AMRSliceBase(axis, coord, fields=None, center=None, pf=None, node_name=False, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR2DData

AMRSlice 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.AMRCuttingPlaneBase(normal, center, fields=None, node_name=None, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR2DData

AMRCuttingPlane 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.AMRProjBase(axis, field, weight_field=None, max_level=None, center=None, pf=None, source=None, node_name=None, field_cuts=None, serialize=True, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR2DData

AMRProj 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.AMRSphereBase(center, radius, fields=None, pf=None, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR3DData

A sphere of points

The most famous of all the data objects, we define it via a center and a radius.

class yt.lagos.AMRRegionBase(center, left_edge, right_edge, fields=None, pf=None, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR3DData

AMRRegions 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.AMRCylinderBase(center, normal, radius, height, fields=None, pf=None, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR3DData

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.AMRGridCollection(center, grid_list, fields=None, pf=None, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR3DData

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.AMRCoveringGridBase(level, left_edge, right_edge, dims, fields=None, pf=None, num_ghost_zones=0, use_pbar=True, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR3DData

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.AMRSmoothedCoveringGridBase(*args, **kwargs)
Bases: yt.lagos.BaseDataTypes.AMRCoveringGridBase
class yt.lagos.ExtractedRegionBase(base_region, indices, force_refresh=True, **kwargs)

Bases: yt.lagos.BaseDataTypes.AMR3DData

ExtractedRegions are arbitrarily defined containers of data, useful for things like selection along a baryon field.

yt.lagos.DerivedQuantities 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. For more information, see Derived Quantities.

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._BulkVelocity(data)
This function returns the mass-weighted average velocity 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._Extrema(data, fields)

This function returns the extrema of a set of fields

Parameter:fields – A field name, or a list of field names
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._MaxLocation(data, field)
This function returns the location of the maximum of a set of fields.
yt.lagos.DerivedQuantities._ParticleSpinParameter(data)
This function returns the spin parameter for the baryons, but it uses the particles in calculating enclosed mass.
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._TotalQuantity(data, fields)

This function sums up a given field over the entire region

Parameter:fields – The fields to sum up
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.FieldInfoContainer Derived Field Objects

class yt.lagos.FieldInfoContainer

This is a generic field container. It contains a list of potential derived fields, all of which know how to act on a data object and return a value. This object handles converting units as well as validating the availability of a given field.

add_field(name, function=None, **kwargs)
Add a new field, along with supplemental metadata, to the list of available fields. This respects a number of arguments, all of which are passed on to the constructor for DerivedField.
keys()
Return all the field names this object knows about.
class yt.lagos.EnzoFieldContainer
This is a container for Enzo-specific fields.
class yt.lagos.OrionFieldContainer
All Orion-specific fields are stored in here.
class yt.lagos.DerivedField(name, function, convert_function=None, units='', projected_units='', take_log=True, validators=None, particle_type=False, vector_field=False, display_field=True, not_in_all=False, display_name=None, projection_conversion='cm')

This is the base class used to describe a cell-by-cell derived field.

Parameters:
  • name – is the name of the field.
  • function – is a function handle that defines the field
  • convert_function – must convert to CGS, if it needs to be done
  • units – is a mathtext-formatted string that describes the field
  • projected_units – if we display a projection, what should the units be?
  • take_log – describes whether the field should be logged
  • validators – is a list of FieldValidator objects
  • particle_type – is this field based on particles?
  • vector_field – describes the dimensionality of the field
  • display_field – governs its appearance in the dropdowns in reason
  • not_in_all – is used for baryon fields from the data that are not in all the grids
  • display_name – a name used in the plots
  • projection_conversion – which unit should we multiply by in a projection?
check_available(data)
This raises an exception of the appropriate type if the set of validation mechanisms are not met, and otherwise returns True.
get_dependencies(*args, **kwargs)
This returns a list of names of fields that this field depends on.
get_label(projected=False)
Return a data label for the given field, inluding units.
get_projected_units()
Return a string describing the units if the field has been projected.
get_source()
Return a string containing the source of the function (if possible.)
get_units()
Return a string describing the units.
class yt.lagos.ValidateParameter(parameters)
This validator ensures that the parameter file has a given parameter.
class yt.lagos.ValidateDataField(field)
This validator ensures that the output file has a given data field stored in it.
class yt.lagos.ValidateProperty(prop)
This validator ensures that the data object has a given python attribute.
class yt.lagos.ValidateSpatial(ghost_zones=0, fields=None)
This validator ensures that the data handed to the field is of spatial nature – that is to say, 3-D.
class yt.lagos.ValidateGridType
This validator ensures that the data handed to the field is an actual grid patch, not a covering grid of any kind.

yt.lagos.Profiles Profiling

Profiling in yt is a means of generating arbitrary histograms – for instance, phase diagrams, radial profiles, and even more complicated 3D examinations.

class yt.lagos.BinnedProfile1D(data_source, n_bins, bin_field, lower_bound, upper_bound, log_space=True, lazy_reader=False, left_collect=False)

Bases: yt.lagos.Profiles.BinnedProfile

A ‘Profile’ produces either a weighted (or unweighted) average or a straight sum of a field in a bin defined by another field. In the case of a weighted average, we have: p_i = sum( w_i * v_i ) / sum(w_i)

We accept a data_source, which will be binned into n_bins by the field bin_field between the lower_bound and the upper_bound. These bins may or may not be equally divided in log_space, and the lazy_reader flag controls whether we use a memory conservative approach.

add_fields(fields, weight='CellMassMsun', accumulation=False)
We accept a list of fields which will be binned if weight is not None and otherwise summed. accumulation determines whether or not they will be accumulated from low to high along the appropriate axes.
class yt.lagos.BinnedProfile2D(data_source, x_n_bins, x_bin_field, x_lower_bound, x_upper_bound, x_log, y_n_bins, y_bin_field, y_lower_bound, y_upper_bound, y_log, lazy_reader=False, left_collect=False)

Bases: yt.lagos.Profiles.BinnedProfile

A ‘Profile’ produces either a weighted (or unweighted) average or a straight sum of a field in a bin defined by two other fields. In the case of a weighted average, we have: p_i = sum( w_i * v_i ) / sum(w_i)

We accept a data_source, which will be binned into x_n_bins by the field x_bin_field between the x_lower_bound and the x_upper_bound and then again binned into y_n_bins by the field y_bin_field between the y_lower_bound and the y_upper_bound. These bins may or may not be equally divided in log-space as specified by x_log and y_log, and the lazy_reader flag controls whether we use a memory conservative approach.

add_fields(fields, weight='CellMassMsun', accumulation=False)
We accept a list of fields which will be binned if weight is not None and otherwise summed. accumulation determines whether or not they will be accumulated from low to high along the appropriate axes.
write_out(filename, format='%0.16e')
Write out the values of x,y,v in ascii to filename for every field in the profile. Optionally a format can be specified.
class yt.lagos.BinnedProfile3D(data_source, x_n_bins, x_bin_field, x_lower_bound, x_upper_bound, x_log, y_n_bins, y_bin_field, y_lower_bound, y_upper_bound, y_log, z_n_bins, z_bin_field, z_lower_bound, z_upper_bound, z_log, lazy_reader=False)

Bases: yt.lagos.Profiles.BinnedProfile

add_fields(fields, weight='CellMassMsun', accumulation=False)
We accept a list of fields which will be binned if weight is not None and otherwise summed. accumulation determines whether or not they will be accumulated from low to high along the appropriate axes.
store_profile(name, force=False)
By identifying the profile with a fixed, user-input name we can store it in the serialized data section of the hierarchy file. force governs whether or not an existing profile with that name will be overwritten.
class yt.lagos.StoredBinnedProfile3D(pf, name)

Bases: yt.lagos.Profiles.BinnedProfile3D

Given a pf parameterfile and the name of a stored profile, retrieve it into a read-only data structure.

yt.lagos.ContourFinder Contour Finding

Typically this is done via the extract_connected_sets() on a data object. However, you can call it manually, as is done in the clump finding scripts.

yt.lagos.identify_contours(data_source, field, min_val, max_val, cached_fields=None)
Given a data_source, we will search for topologically connected sets in field between min_val and max_val.
class yt.lagos.GridConsiderationQueue(white_list, priority_func=None)
This class exists to serve the contour finder. It ensures that we can create a cascading set of queue dependencies, and if a grid is touched again ahead of time we can bump it to the top of the queue again. It like has few uses.

yt.lagos.HaloFinding Halo Finding

yt now includes the HOP algorithm and implementation from the Enzo source distribution, with some modifications by both Stephen Skory and Matthew Turk.

yt.lagos.HaloFinder
alias of HOPHaloFinder
class yt.lagos.HaloList(data_source, dm_only=True)

Run hop on data_source with a given density threshold. If dm_only is set, only run it on the dark matter particles, otherwise on all particles. Returns an iterable collection of HopGroup items.

write_out(filename)
Write out standard HOP information to filename.
class yt.lagos.Halo(halo_list, id, indices=None)

A data source that returns particle information about the members of a HOP-identified halo.

bulk_velocity()
Returns the mass-weighted average velocity.
center_of_mass()
Calculate and return the center of mass.
get_sphere(center_of_mass=True)
Returns an EnzoSphere centered on either the point of maximum density or the center_of_mass, with the maximum radius of the halo.
maximum_density()
Return the HOP-identified maximum density.
maximum_density_location()
Return the location HOP identified as maximally dense.
maximum_radius(center_of_mass=True)
Returns the maximum radius in the halo for all particles, either from the point of maximum density or from the (default) center_of_mass.
total_mass()
Returns the total mass in solar masses of the halo.

The specific halo finding algorithm can be specified by selecting the appropriate HaloFinder object. By default, HOP is used.

class yt.lagos.HOPHaloFinder(pf, threshold=160, dm_only=True, padding=0.02)
class yt.lagos.FOFHaloFinder(pf, link=0.20000000000000001, dm_only=True, padding=0.02)

Comments

Feel free to leave comments! If you've got a GMail account, you can use https://www.google.com/accounts/o8/id as your OpenID URL.
comments powered by Disqus