Unstructured mesh base container.
yt.data_objects.unstructured_mesh.
SemiStructuredMesh
(mesh_id, filename, connectivity_indices, connectivity_coords, index)[source]¶Bases: yt.data_objects.unstructured_mesh.UnstructuredMesh
apply_units
(arr, units)¶argmax
(field, axis=None)¶Return the values at which the field is maximized.
This will, in a parallelaware fashion, find the maximum value and then return to you the values at that maximum location that are requested for “axis”. By default it will return the spatial positions (in the natural coordinate system), but it can be any field
Parameters: 


Returns:  
Return type:  A list of YTQuantities as specified by the axis argument. 
Examples
>>> temp_at_max_rho = reg.argmax("density", axis="temperature")
>>> max_rho_xyz = reg.argmax("density")
>>> t_mrho, v_mrho = reg.argmax("density", axis=["temperature",
... "velocity_magnitude"])
>>> x, y, z = reg.argmax("density")
argmin
(field, axis=None)¶Return the values at which the field is minimized.
This will, in a parallelaware fashion, find the minimum value and then return to you the values at that minimum location that are requested for “axis”. By default it will return the spatial positions (in the natural coordinate system), but it can be any field
Parameters: 


Returns:  
Return type:  A list of YTQuantities as specified by the axis argument. 
Examples
>>> temp_at_min_rho = reg.argmin("density", axis="temperature")
>>> min_rho_xyz = reg.argmin("density")
>>> t_mrho, v_mrho = reg.argmin("density", axis=["temperature",
... "velocity_magnitude"])
>>> x, y, z = reg.argmin("density")
blocks
¶chunks
(fields, chunking_style, **kwargs)¶clear_data
()¶Clears out all data from the YTDataContainer instance, freeing memory.
clone
()¶Clone a data object.
This will make a duplicate of a data object; note that the field_parameters may not necessarily be deeplycopied. If you modify the field parameters inplace, it may or may not be shared between the objects, depending on the type of object that that particular field parameter is.
Notes
One use case for this is to have multiple identical data objects that are being chunked over in different orders.
Examples
>>> ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> sp = ds.sphere("c", 0.1)
>>> sp_clone = sp.clone()
>>> sp["density"]
>>> print sp.field_data.keys()
[("gas", "density")]
>>> print sp_clone.field_data.keys()
[]
comm
= None¶convert
(datatype)¶This will attempt to convert a given unit to cgs from code units. It either returns the multiplicative factor or throws a KeyError.
count
(selector)¶count_particles
(selector, x, y, z)¶deposit
(positions, fields=None, method=None, kernel_name='cubic')¶fcoords
¶fcoords_vertex
¶fwidth
¶get_data
(fields=None)¶get_dependencies
(fields)¶get_field_parameter
(name, default=None)¶This is typically only used by derived field functions, but it returns parameters used to generate fields.
get_global_startindex
()¶Return the integer starting index for each dimension at the current level.
has_field_parameter
(name)¶Checks if a field parameter is set.
has_key
(key)¶Checks if a data field already exists.
icoords
¶index
¶integrate
(field, weight=None, axis=None)¶Compute the integral (projection) of a field along an axis.
This projects a field along an axis.
Parameters:  

Returns:  
Return type:  YTProjection 
Examples
>>> column_density = reg.integrate("density", axis="z")
ires
¶keys
()¶max
(field, axis=None)¶Compute the maximum of a field, optionally along an axis.
This will, in a parallelaware fashion, compute the maximum of the given field. Supplying an axis will result in a return value of a YTProjection, with method ‘mip’ for maximum intensity. If the max has already been requested, it will use the cached extrema value.
Parameters:  

Returns:  
Return type:  Either a scalar or a YTProjection. 
Examples
>>> max_temp = reg.max("temperature")
>>> max_temp_proj = reg.max("temperature", axis="x")
max_level
¶mean
(field, axis=None, weight=None)¶Compute the mean of a field, optionally along an axis, with a weight.
This will, in a parallelaware fashion, compute the mean of the given field. If an axis is supplied, it will return a projection, where the weight is also supplied. By default the weight field will be “ones” or “particle_ones”, depending on the field being averaged, resulting in an unweighted average.
Parameters:  

Returns:  
Return type:  Scalar or YTProjection. 
Examples
>>> avg_rho = reg.mean("density", weight="cell_volume")
>>> rho_weighted_T = reg.mean("temperature", axis="y", weight="density")
min
(field, axis=None)¶Compute the minimum of a field.
This will, in a parallelaware fashion, compute the minimum of the given field. Supplying an axis is not currently supported. If the max has already been requested, it will use the cached extrema value.
Parameters:  

Returns:  
Return type:  Scalar. 
Examples
>>> min_temp = reg.min("temperature")
min_level
¶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.
pf
¶profile
(bin_fields, fields, n_bins=64, extrema=None, logs=None, units=None, weight_field='cell_mass', accumulation=False, fractional=False, deposition='ngp')¶Create a 1, 2, or 3D profile object from this data_source.
The dimensionality of the profile object is chosen by the number of
fields given in the bin_fields argument. This simply calls
yt.data_objects.profiles.create_profile()
.
Parameters: 


Examples
Create a 1d profile. Access bin field from profile.x and field data from profile[<field_name>].
>>> ds = load("DD0046/DD0046")
>>> ad = ds.all_data()
>>> profile = ad.profile(ad, [("gas", "density")],
... [("gas", "temperature"),
... ("gas", "velocity_x")])
>>> print (profile.x)
>>> print (profile["gas", "temperature"])
>>> plot = profile.plot()
ptp
(field)¶Compute the range of values (maximum  minimum) of a field.
This will, in a parallelaware fashion, compute the “peaktopeak” of the given field.
Parameters:  field (string or tuple field name) – The field to average. 

Returns:  
Return type:  Scalar 
Examples
>>> rho_range = reg.ptp("density")
save_as_dataset
(filename=None, fields=None)¶Export a data object to a reloadable yt dataset.
This function will take a data object and output a dataset
containing either the fields presently existing or fields
given in the fields
list. The resulting dataset can be
reloaded as a yt dataset.
Parameters: 


Returns:  filename – The name of the file that has been created. 
Return type: 
Examples
>>> import yt
>>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
>>> sp = ds.sphere(ds.domain_center, (10, "Mpc"))
>>> fn = sp.save_as_dataset(fields=["density", "temperature"])
>>> sphere_ds = yt.load(fn)
>>> # the original data container is available as the data attribute
>>> print (sds.data["density"])
[ 4.46237613e32 4.86830178e32 4.46335118e32 ..., 6.43956165e30
3.57339907e30 2.83150720e30] g/cm**3
>>> ad = sphere_ds.all_data()
>>> print (ad["temperature"])
[ 1.00000000e+00 1.00000000e+00 1.00000000e+00 ..., 4.40108359e+04
4.54380547e+04 4.72560117e+04] K
save_object
(name, filename=None)¶Save an object. If filename is supplied, it will be stored in
a shelve
file of that name. Otherwise, it will be stored via
yt.data_objects.api.GridIndex.save_object()
.
select_blocks
(selector)¶select_fcoords
(dobj=None)¶select_fcoords_vertex
(dobj=None)¶select_icoords
(dobj)¶select_particles
(selector, x, y, z)¶selector
¶set_field_parameter
(name, val)¶Here we set up dictionaries that get passed up and down and ultimately to derived fields.
shape
¶std
(field, weight=None)¶Compute the variance of a field.
This will, in a parallelware fashion, compute the variance of the given field.
Parameters:  

Returns:  
Return type:  Scalar 
sum
(field, axis=None)¶Compute the sum of a field, optionally along an axis.
This will, in a parallelaware fashion, compute the sum of the given field. If an axis is specified, it will return a projection (using method type “sum”, which does not take into account path length) along that axis.
Parameters:  

Returns:  
Return type:  Either a scalar or a YTProjection. 
Examples
>>> total_vol = reg.sum("cell_volume")
>>> cell_count = reg.sum("ones", axis="x")
tiles
¶to_dataframe
(fields=None)¶Export a data object to a pandas DataFrame.
This function will take a data object and construct from it and optionally a list of fields a pandas DataFrame object. If pandas is not importable, this will raise ImportError.
Parameters:  fields (list of strings or tuple field names, default None) – If this is supplied, it is the list of fields to be exported into the data frame. If not supplied, whatever fields presently exist will be used. 

Returns:  df – The data contained in the object. 
Return type:  DataFrame 
Examples
>>> dd = ds.all_data()
>>> df1 = dd.to_dataframe(["density", "temperature"])
>>> dd["velocity_magnitude"]
>>> df2 = dd.to_dataframe()
to_glue
(fields, label='yt', data_collection=None)¶Takes specific fields in the container and exports them to Glue (http://www.glueviz.org) for interactive analysis. Optionally add a label. If you are already within the Glue environment, you can pass a data_collection object, otherwise Glue will be started.
write_out
(filename, fields=None, format='%0.16e')¶Write out the YTDataContainer object in a text file.
This function will take a data object and produce a tab delimited text
file containing the fields presently existing and the fields given in
the fields
list.
Parameters: 


Raises: 

Examples
>>> ds = fake_particle_ds()
>>> sp = ds.sphere(ds.domain_center, 0.25)
>>> sp.write_out("sphere_1.txt")
>>> sp.write_out("sphere_2.txt", fields=["cell_volume"])
yt.data_objects.unstructured_mesh.
UnstructuredMesh
(mesh_id, filename, connectivity_indices, connectivity_coords, index)[source]¶Bases: yt.data_objects.data_containers.YTSelectionContainer
apply_units
(arr, units)¶argmax
(field, axis=None)¶Return the values at which the field is maximized.
This will, in a parallelaware fashion, find the maximum value and then return to you the values at that maximum location that are requested for “axis”. By default it will return the spatial positions (in the natural coordinate system), but it can be any field
Parameters: 


Returns:  
Return type:  A list of YTQuantities as specified by the axis argument. 
Examples
>>> temp_at_max_rho = reg.argmax("density", axis="temperature")
>>> max_rho_xyz = reg.argmax("density")
>>> t_mrho, v_mrho = reg.argmax("density", axis=["temperature",
... "velocity_magnitude"])
>>> x, y, z = reg.argmax("density")
argmin
(field, axis=None)¶Return the values at which the field is minimized.
This will, in a parallelaware fashion, find the minimum value and then return to you the values at that minimum location that are requested for “axis”. By default it will return the spatial positions (in the natural coordinate system), but it can be any field
Parameters: 


Returns:  
Return type:  A list of YTQuantities as specified by the axis argument. 
Examples
>>> temp_at_min_rho = reg.argmin("density", axis="temperature")
>>> min_rho_xyz = reg.argmin("density")
>>> t_mrho, v_mrho = reg.argmin("density", axis=["temperature",
... "velocity_magnitude"])
>>> x, y, z = reg.argmin("density")
blocks
¶chunks
(fields, chunking_style, **kwargs)¶clear_data
()¶Clears out all data from the YTDataContainer instance, freeing memory.
clone
()¶Clone a data object.
This will make a duplicate of a data object; note that the field_parameters may not necessarily be deeplycopied. If you modify the field parameters inplace, it may or may not be shared between the objects, depending on the type of object that that particular field parameter is.
Notes
One use case for this is to have multiple identical data objects that are being chunked over in different orders.
Examples
>>> ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> sp = ds.sphere("c", 0.1)
>>> sp_clone = sp.clone()
>>> sp["density"]
>>> print sp.field_data.keys()
[("gas", "density")]
>>> print sp_clone.field_data.keys()
[]
comm
= None¶convert
(datatype)[source]¶This will attempt to convert a given unit to cgs from code units. It either returns the multiplicative factor or throws a KeyError.
fcoords
¶fcoords_vertex
¶fwidth
¶get_data
(fields=None)¶get_dependencies
(fields)¶get_field_parameter
(name, default=None)¶This is typically only used by derived field functions, but it returns parameters used to generate fields.
get_global_startindex
()[source]¶Return the integer starting index for each dimension at the current level.
has_field_parameter
(name)¶Checks if a field parameter is set.
has_key
(key)¶Checks if a data field already exists.
icoords
¶index
¶integrate
(field, weight=None, axis=None)¶Compute the integral (projection) of a field along an axis.
This projects a field along an axis.
Parameters:  

Returns:  
Return type:  YTProjection 
Examples
>>> column_density = reg.integrate("density", axis="z")
ires
¶keys
()¶max
(field, axis=None)¶Compute the maximum of a field, optionally along an axis.
This will, in a parallelaware fashion, compute the maximum of the given field. Supplying an axis will result in a return value of a YTProjection, with method ‘mip’ for maximum intensity. If the max has already been requested, it will use the cached extrema value.
Parameters:  

Returns:  
Return type:  Either a scalar or a YTProjection. 
Examples
>>> max_temp = reg.max("temperature")
>>> max_temp_proj = reg.max("temperature", axis="x")
max_level
¶mean
(field, axis=None, weight=None)¶Compute the mean of a field, optionally along an axis, with a weight.
This will, in a parallelaware fashion, compute the mean of the given field. If an axis is supplied, it will return a projection, where the weight is also supplied. By default the weight field will be “ones” or “particle_ones”, depending on the field being averaged, resulting in an unweighted average.
Parameters:  

Returns:  
Return type:  Scalar or YTProjection. 
Examples
>>> avg_rho = reg.mean("density", weight="cell_volume")
>>> rho_weighted_T = reg.mean("temperature", axis="y", weight="density")
min
(field, axis=None)¶Compute the minimum of a field.
This will, in a parallelaware fashion, compute the minimum of the given field. Supplying an axis is not currently supported. If the max has already been requested, it will use the cached extrema value.
Parameters:  

Returns:  
Return type:  Scalar. 
Examples
>>> min_temp = reg.min("temperature")
min_level
¶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.
pf
¶profile
(bin_fields, fields, n_bins=64, extrema=None, logs=None, units=None, weight_field='cell_mass', accumulation=False, fractional=False, deposition='ngp')¶Create a 1, 2, or 3D profile object from this data_source.
The dimensionality of the profile object is chosen by the number of
fields given in the bin_fields argument. This simply calls
yt.data_objects.profiles.create_profile()
.
Parameters: 


Examples
Create a 1d profile. Access bin field from profile.x and field data from profile[<field_name>].
>>> ds = load("DD0046/DD0046")
>>> ad = ds.all_data()
>>> profile = ad.profile(ad, [("gas", "density")],
... [("gas", "temperature"),
... ("gas", "velocity_x")])
>>> print (profile.x)
>>> print (profile["gas", "temperature"])
>>> plot = profile.plot()
ptp
(field)¶Compute the range of values (maximum  minimum) of a field.
This will, in a parallelaware fashion, compute the “peaktopeak” of the given field.
Parameters:  field (string or tuple field name) – The field to average. 

Returns:  
Return type:  Scalar 
Examples
>>> rho_range = reg.ptp("density")
save_as_dataset
(filename=None, fields=None)¶Export a data object to a reloadable yt dataset.
This function will take a data object and output a dataset
containing either the fields presently existing or fields
given in the fields
list. The resulting dataset can be
reloaded as a yt dataset.
Parameters: 


Returns:  filename – The name of the file that has been created. 
Return type: 
Examples
>>> import yt
>>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
>>> sp = ds.sphere(ds.domain_center, (10, "Mpc"))
>>> fn = sp.save_as_dataset(fields=["density", "temperature"])
>>> sphere_ds = yt.load(fn)
>>> # the original data container is available as the data attribute
>>> print (sds.data["density"])
[ 4.46237613e32 4.86830178e32 4.46335118e32 ..., 6.43956165e30
3.57339907e30 2.83150720e30] g/cm**3
>>> ad = sphere_ds.all_data()
>>> print (ad["temperature"])
[ 1.00000000e+00 1.00000000e+00 1.00000000e+00 ..., 4.40108359e+04
4.54380547e+04 4.72560117e+04] K
save_object
(name, filename=None)¶Save an object. If filename is supplied, it will be stored in
a shelve
file of that name. Otherwise, it will be stored via
yt.data_objects.api.GridIndex.save_object()
.
selector
¶set_field_parameter
(name, val)¶Here we set up dictionaries that get passed up and down and ultimately to derived fields.
shape
¶std
(field, weight=None)¶Compute the variance of a field.
This will, in a parallelware fashion, compute the variance of the given field.
Parameters:  

Returns:  
Return type:  Scalar 
sum
(field, axis=None)¶Compute the sum of a field, optionally along an axis.
This will, in a parallelaware fashion, compute the sum of the given field. If an axis is specified, it will return a projection (using method type “sum”, which does not take into account path length) along that axis.
Parameters:  

Returns:  
Return type:  Either a scalar or a YTProjection. 
Examples
>>> total_vol = reg.sum("cell_volume")
>>> cell_count = reg.sum("ones", axis="x")
tiles
¶to_dataframe
(fields=None)¶Export a data object to a pandas DataFrame.
This function will take a data object and construct from it and optionally a list of fields a pandas DataFrame object. If pandas is not importable, this will raise ImportError.
Parameters:  fields (list of strings or tuple field names, default None) – If this is supplied, it is the list of fields to be exported into the data frame. If not supplied, whatever fields presently exist will be used. 

Returns:  df – The data contained in the object. 
Return type:  DataFrame 
Examples
>>> dd = ds.all_data()
>>> df1 = dd.to_dataframe(["density", "temperature"])
>>> dd["velocity_magnitude"]
>>> df2 = dd.to_dataframe()
to_glue
(fields, label='yt', data_collection=None)¶Takes specific fields in the container and exports them to Glue (http://www.glueviz.org) for interactive analysis. Optionally add a label. If you are already within the Glue environment, you can pass a data_collection object, otherwise Glue will be started.
write_out
(filename, fields=None, format='%0.16e')¶Write out the YTDataContainer object in a text file.
This function will take a data object and produce a tab delimited text
file containing the fields presently existing and the fields given in
the fields
list.
Parameters: 


Raises: 

Examples
>>> ds = fake_particle_ds()
>>> sp = ds.sphere(ds.domain_center, 0.25)
>>> sp.write_out("sphere_1.txt")
>>> sp.write_out("sphere_2.txt", fields=["cell_volume"])