yt.data_objects.construction_data_containers.YTSmoothedCoveringGridBase.extract_isocontours

YTSmoothedCoveringGridBase.extract_isocontours(field, value, filename=None, rescale=False, sample_values=None)

This identifies isocontours on a cell-by-cell basis, with no consideration of global connectedness, and returns the vertices of the Triangles in that isocontour.

This function simply returns the vertices of all the triangles calculated by the marching cubes algorithm; for more complex operations, such as identifying connected sets of cells above a given threshold, see the extract_connected_sets function. This is more useful for calculating, for instance, total isocontour area, or visualizing in an external program (such as MeshLab.)

Parameters:

field : string

Any field that can be obtained in a data object. This is the field which will be isocontoured.

value : float

The value at which the isocontour should be calculated.

filename : string, optional

If supplied, this file will be filled with the vertices in .obj format. Suitable for loading into meshlab.

rescale : bool, optional

If true, the vertices will be rescaled within their min/max.

sample_values : string, optional

Any field whose value should be extracted at the center of each triangle.

Returns:

verts : array of floats

The array of vertices, x,y,z. Taken in threes, these are the triangle vertices.

samples : array of floats

If sample_values is specified, this will be returned and will contain the values of the field specified at the center of each triangle.

References

[R6]Marching Cubes: http://en.wikipedia.org/wiki/Marching_cubes

Examples

This will create a data object, find a nice value in the center, and output the vertices to “triangles.obj” after rescaling them.

>>> dd = ds.all_data()
>>> rho = dd.quantities["WeightedAverageQuantity"](
...     "Density", weight="CellMassMsun")
>>> verts = dd.extract_isocontours("Density", rho,
...             "triangles.obj", True)