# yt.data_objects.derived_quantities module¶

Quantities that can be derived from Enzo data that may also required additional arguments. (Standard arguments – such as the center of a distribution of points – are excluded here, and left to the EnzoDerivedFields.)

class yt.data_objects.derived_quantities.AngularMomentumVector(data_source)[source]

Calculates the angular momentum vector, using gas and/or particles.

The angular momentum vector is the mass-weighted mean specific angular momentum. Returns a YTArray of the vector.

Parameters: use_gas (bool) – Flag to include gas in the calculation. Gas is ignored if not present. Default: True use_particles (bool) – Flag to include particles in the calculation. Particles are ignored if not present. Default: True

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()

comm = None
count_values(use_gas=True, use_particles=True)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, **kwargs)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.BulkVelocity(data_source)[source]

Calculates the bulk velocity, using gas and/or particles.

The bulk velocity is the mass-weighted mean velocity.

Parameters: use_gas (bool) – Flag to include gas in the calculation. Gas is ignored if not present. Default: True use_particles (bool) – Flag to include particles in the calculation. Particles are ignored if not present. Default: True

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()

comm = None
count_values(use_gas=True, use_particles=False)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, use_gas=True, use_particles=False)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.CenterOfMass(data_source)[source]

Calculates the center of mass, using gas and/or particles.

The center of mass is the mass-weighted mean position.

Parameters: use_gas (bool) – Flag to include gas in the calculation. Gas is ignored if not present. Default: True use_particles (bool) – Flag to include particles in the calculation. Particles are ignored if not present. Default: False

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()

comm = None
count_values(use_gas=True, use_particles=False)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, use_gas=True, use_particles=False)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.DerivedQuantity(data_source)[source]
comm = None
count_values(*args, **kwargs)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, *args, **kwargs)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.DerivedQuantityCollection[source]

Bases: object

keys()[source]
class yt.data_objects.derived_quantities.Extrema(data_source)[source]

Calculates the min and max value of a field or list of fields. Returns a YTArray for each field requested. If one, a single YTArray is returned, if many, a list of YTArrays in order of field list is returned. The first element of each YTArray is the minimum of the field and the second is the maximum of the field.

Parameters: fields – The field or list of fields over which the extrema are to be calculated. non_zero (bool) – If True, only positive values are considered in the calculation. Default: False

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.extrema([("gas", "density"),
...                              ("gas", "temperature")])

comm = None
count_values(fields, non_zero)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, fields, non_zero)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.MaxLocation(data_source)[source]

Calculates the maximum value plus the x, y, and z position of the maximum.

Parameters: field (tuple or string) – The field over which the extrema are to be calculated.

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.max_location(("gas", "density"))

comm = None
count_values(field, sample_fields)
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, field, sample_fields)
reduce_intermediate(values)
class yt.data_objects.derived_quantities.MinLocation(data_source)[source]

Calculates the minimum value plus the x, y, and z position of the minimum.

Parameters: field (tuple or string) – The field over which the extrema are to be calculated.

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.min_location(("gas", "density"))

comm = None
count_values(field, sample_fields)
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, field, sample_fields)
reduce_intermediate(values)
class yt.data_objects.derived_quantities.RegisteredDerivedQuantity(name, b, d)[source]

Bases: type

mro() → list

return a type’s method resolution order

class yt.data_objects.derived_quantities.SampleAtMaxFieldValues(data_source)[source]

Calculates the maximum value and returns whichever fields are asked to be sampled.

Parameters: field (tuple or string) – The field over which the extrema are to be calculated. sample_fields (list of fields) – The fields to sample and return at the minimum value.

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.sample_at_max_field_values(("gas", "density"),
...         ["temperature", "velocity_magnitude"])

comm = None
count_values(field, sample_fields)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, field, sample_fields)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.SampleAtMinFieldValues(data_source)[source]

Calculates the minimum value and returns whichever fields are asked to be sampled.

Parameters: field (tuple or string) – The field over which the extrema are to be calculated. sample_fields (list of fields) – The fields to sample and return at the minimum value.

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.sample_at_min_field_values(("gas", "density"),
...         ["temperature", "velocity_magnitude"])

comm = None
count_values(field, sample_fields)
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, field, sample_fields)
reduce_intermediate(values)
class yt.data_objects.derived_quantities.SpinParameter(data_source)[source]

Calculates the dimensionless spin parameter.

Given by Equation 3 of Peebles (1971, A&A, 11, 377), the spin parameter is defined as

$\lambda = (L * |E|^(1/2)) / (G * M^5/2),$

where L is the total angular momentum, E is the total energy (kinetic and potential), G is the gravitational constant, and M is the total mass.

Parameters: use_gas (bool) – Flag to include gas in the calculation. Gas is ignored if not present. Default: True use_particles (bool) – Flag to include particles in the calculation. Particles are ignored if not present. Default: True

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()

comm = None
count_values(**kwargs)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, use_gas=True, use_particles=True)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.TotalMass(data_source)[source]

Calculates the total mass of the object. Returns a YTArray where the first element is total gas mass and the second element is total particle mass.

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()

comm = None
count_values(fields)
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, fields)
reduce_intermediate(values)
class yt.data_objects.derived_quantities.TotalQuantity(data_source)[source]

Calculates the sum of the field or fields.

Parameters: fields – The field or list of fields to be summed.

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.total_quantity([("gas", "cell_mass")])

comm = None
count_values(fields)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, fields)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.WeightedAverageQuantity(data_source)[source]

Calculates the weight average of a field or fields.

Returns a YTQuantity for each field requested; if one, it returns a single YTQuantity, if many, it returns a list of YTQuantities in order of the listed fields.

Where f is the field and w is the weight, the weighted average is Sum_i(f_i * w_i) / Sum_i(w_i).

Parameters: fields (string / tuple, or list of strings / tuples) – The field or fields of which the average value is to be calculated. weight (string or tuple) – The weight field.

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.weighted_average_quantity([("gas", "density"),
...                                                ("gas", "temperature")],
...                                               ("gas", "cell_mass"))

comm = None
count_values(fields, weight)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, fields, weight)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.WeightedVariance(data_source)[source]

Calculates the weighted variance and weighted mean for a field or list of fields. Returns a YTArray for each field requested; if one, it returns a single YTArray, if many, it returns a list of YTArrays in order of the listed fields. The first element of each YTArray is the weighted variance, and the second element is the weighted mean.

Where f is the field, w is the weight, and <f_w> is the weighted mean, the weighted variance is Sum_i( (f_i - <f_w>)^2 * w_i ) / Sum_i(w_i).

Parameters: fields (string / tuple, or list of strings / tuples) – The field or fields of which the average value is to be calculated. weight (string or tuple) – The weight field.

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.weighted_variance([("gas", "density"),
...                                        ("gas", "temperature")],
...                                       ("gas", "cell_mass"))

comm = None
count_values(fields, weight)[source]
get_dependencies(fields)
num_vals = -1
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

process_chunk(data, fields, weight)[source]
reduce_intermediate(values)[source]
yt.data_objects.derived_quantities.get_position_fields(field, data)[source]