ytree.data_structures.arbor.Arbor.add_vector_field

Arbor.add_vector_field(name, vector_components=None)[source]

Add vector fields for a set of x,y,z component fields.

This will add a general vector field that returns the combined x, y, z components as a single Nx3 array. A <field>_magnitude field with the quadrature sum of the components is also added.

Parameters:
  • name (string) – The name of the field. Component x,y,z fields must exist.

  • vector_components (list of strings) – Used to explicitly provide the x/y/z component fields. If not given, a naming convention of <name>_<xyz> is assumed. Default: None.

Examples

>>> import ytree
>>> a = ytree.load("tree_0_0_0.dat")
>>> for ax in 'xyz':
>>>     a.add_analysis_field(f"thing_{ax}")
>>> fn = a.save_arbor()
>>> a_new = ytree.load(fn)
>>> a_new.add_vector_field("thing")
>>> print (a_new["thing"])
>>> print (a_new["thing_magnitude"])
>>> import ytree
>>> a = ytree.load("AHF_100_tiny/GIZMO-NewMDCLUSTER_0047.snap_128.parameter")
>>> a.add_vector_field("mean_z", vector_components=["mean_z_gas", "mean_z_star"])