yt.data_objects.level_sets.clump_handling module

class yt.data_objects.level_sets.clump_handling.Clump(data, field, parent=None, clump_info=None, validators=None, base=None, contour_key=None, contour_id=None)[source]

Bases: yt.utilities.tree_container.TreeContainer

add_info_item(info_item, *args, **kwargs)[source]

Adds an entry to clump_info list and tells children to do the same.

add_validator(validator, *args, **kwargs)[source]

Add a validating function to determine whether the clump should be kept.

clear_clump_info()[source]

Clears the clump_info array and passes the instruction to its children.

find_children(min_val, max_val=None)[source]
property leaves
pass_down(operation)[source]

Performs an operation on a clump with an exec and passes the instruction down to clump children.

save_as_dataset(filename=None, fields=None)[source]

Export clump tree to a reloadable yt dataset. This function will take a clump object and output a dataset containing the fields given in the fields list and all info items. The resulting dataset can be reloaded as a yt dataset.

Parameters
  • filename (str, optional) – The name of the file to be written. If None, the name will be a combination of the original dataset and the clump index.

  • fields (list of strings or tuples, optional) – If this is supplied, it is the list of fields to be saved to disk.

Returns

filename – The name of the file that has been created.

Return type

str

Examples

>>> import yt
>>> from yt.data_objects.level_sets.api import Clump, find_clumps
>>> ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> data_source = ds.disk(
...     [0.5, 0.5, 0.5], [0.0, 0.0, 1.0], (8, "kpc"), (1, "kpc")
... )
>>> field = ("gas", "density")
>>> step = 2.0
>>> c_min = 10 ** np.floor(np.log10(data_source[field]).min())
>>> c_max = 10 ** np.floor(np.log10(data_source[field]).max() + 1)
>>> master_clump = Clump(data_source, field)
>>> master_clump.add_info_item("center_of_mass")
>>> master_clump.add_validator("min_cells", 20)
>>> find_clumps(master_clump, c_min, c_max, step)
>>> fn = master_clump.save_as_dataset(
...     fields=[("gas", "density"), ("all", "particle_mass")]
... )
>>> new_ds = yt.load(fn)
>>> print(ds.tree["clump", "cell_mass"])
1296926163.91 Msun
>>> print(ds.tree["grid", "density"])
[  2.54398434e-26   2.46620353e-26   2.25120154e-26 ...,   1.12879234e-25
   1.59561490e-25   1.09824903e-24] g/cm**3
>>> print(ds.tree["all", "particle_mass"])
[  4.25472446e+38   4.25472446e+38   4.25472446e+38 ...,   2.04238266e+38
   2.04523901e+38   2.04770938e+38] g
>>> print(ds.tree.children[0]["clump", "cell_mass"])
909636495.312 Msun
>>> print(ds.leaves[0]["clump", "cell_mass"])
3756566.99809 Msun
>>> print(ds.leaves[0]["grid", "density"])
[  6.97820274e-24   6.58117370e-24   7.32046082e-24   6.76202430e-24
   7.41184837e-24   6.76981480e-24   6.94287213e-24   6.56149658e-24
   6.76584569e-24   6.94073710e-24   7.06713082e-24   7.22556526e-24
   7.08338898e-24   6.78684331e-24   7.40647040e-24   7.03050456e-24
   7.12438678e-24   6.56310217e-24   7.23201662e-24   7.17314333e-24] g/cm**3
set_default_clump_info()[source]

Defines default entries in the clump_info array.

yt.data_objects.level_sets.clump_handling.add_contour_field(ds, contour_key)[source]
yt.data_objects.level_sets.clump_handling.find_clumps(clump, min_val, max_val, d_clump)[source]