yt.data_objects.derived_quantities module

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

Bases: DerivedQuantity

Calculates the angular momentum vector, using gas (grid-based) 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 grid-based 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

  • particle_type (string) – Flag to specify the field type of the particles to use. Useful for particle-based codes where you don’t want to use all of the particles in your calculation. Default: ‘all’

Examples

Find angular momentum vector of galaxy in grid-based isolated galaxy dataset >>> ds = yt.load(“IsolatedGalaxy/galaxy0030/galaxy0030”) … ad = ds.all_data() … print(ad.quantities.angular_momentum_vector()) [-7.50868209e+26 1.06032596e+27 2.19274002e+29] cm**2/s >>> # Find angular momentum vector of gas disk in particle-based dataset >>> ds = yt.load(“FIRE_M12i_ref11/snapshot_600.hdf5”) … _, c = ds.find_max((“gas”, “density”)) … sp = ds.sphere(c, (10, “kpc”)) … search_args = dict(use_gas=False, use_particles=True, particle_type=”PartType0”) … print(sp.quantities.angular_momentum_vector(**search_args)) [4.88104442e+28 7.38463362e+28 6.20030135e+28] cm**2/s

comm = None
count_values(use_gas=True, use_particles=True, particle_type='all')[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, particle_type='all')[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.BulkVelocity(data_source)[source]

Bases: DerivedQuantity

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

  • particle_type (string) – Flag to specify the field type of the particles to use. Useful for particle-based codes where you don’t want to use all of the particles in your calculation. Default: ‘all’

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print(ad.quantities.bulk_velocity())
comm = None
count_values(use_gas=True, use_particles=False, particle_type='nbody')[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, particle_type='nbody')[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.CenterOfMass(data_source)[source]

Bases: DerivedQuantity

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

  • particle_type (string) – Flag to specify the field type of the particles to use. Useful for particle-based codes where you don’t want to use all of the particles in your calculation. Default: ‘all’

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print(ad.quantities.center_of_mass())
comm = None
count_values(use_gas=True, use_particles=False, particle_type='nbody')[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, particle_type='nbody')[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.DerivedQuantity(data_source)[source]

Bases: ParallelAnalysisInterface

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(data_source, *args, **kwargs)[source]

Bases: object

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

Bases: DerivedQuantity

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

  • check_finite (bool) – If True, non-finite values will be explicitly excluded. 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, *, check_finite=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, fields, non_zero, *, check_finite=False)[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.MaxLocation(data_source)[source]

Bases: SampleAtMaxFieldValues

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]

Bases: SampleAtMinFieldValues

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.SampleAtMaxFieldValues(data_source)[source]

Bases: DerivedQuantity

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]

Bases: SampleAtMaxFieldValues

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]

Bases: DerivedQuantity

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

  • particle_type (str) – Particle type to be used for Center of mass calculation when use_particle = True. Default: all

Examples

>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print(ad.quantities.spin_parameter())
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, particle_type='nbody')[source]
reduce_intermediate(values)[source]
class yt.data_objects.derived_quantities.TotalMass(data_source)[source]

Bases: TotalQuantity

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()
>>> print(ad.quantities.total_mass())
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]

Bases: DerivedQuantity

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", "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]

Bases: DerivedQuantity

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", "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.WeightedStandardDeviation(data_source)[source]

Bases: DerivedQuantity

Calculates the weighted standard deviation 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 standard deviation, 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 standard deviation is sqrt( 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_standard_deviation(
...         [("gas", "density"), ("gas", "temperature")], ("gas", "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]