yt.data_objects.derived_quantities.WeightedAverageQuantity — The yt Project 3.2-dev documentation

# yt.data_objects.derived_quantities.WeightedAverageQuantity

class `yt.data_objects.derived_quantities.` `WeightedAverageQuantity`(data_source)

  Calculates the weight average of a field or 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 : field or list of fields The field or fields of which the average value is to be calculated. weight : field 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"))

  Attributes

  Methods