add_contour

add_contour#

GridMeshMixin.add_contour(
r,
t,
p,
data,
/,
dataid='Data',
isovalue=None,
**kwargs,
)[source]#

Add an isosurface contour from a 3-D spherical scalar field.

Builds a SphericalMesh, extracts the isosurface at isovalue via pyvista.DataSet.contour(), and adds the resulting surface mesh to the scene.

Parameters:
r, t, pArrayLike

Spherical coordinate arrays. May be 1-D axis vectors or 3-D meshgrids.

dataArrayLike

Scalar field from which the isosurface is extracted.

dataidstr, optional

Name for the scalar array. Default is 'Data'.

isovalueArrayLike | None, optional

Contour value(s) at which to extract the isosurface. Defaults to 0 when None.

**kwargs

Additional keyword arguments forwarded to add_mesh().

Returns:
outpyvista.Actor

The rendered isosurface actor.

Examples

Extract the \(B_r = 0\) isosurface from the full 3-D coronal field. This surface is the polarity inversion boundary shown against a constant-\(r\) background slice of \(B_r\) for context.

>>> from pyvisual import Plot3d
>>> from pyvisual.utils.data import fetch_datasets
>>> from psi_io import read_hdf_data
>>>
>>> datafile = fetch_datasets("cor", "br")
>>> data, r, t, p = read_hdf_data(datafile.cor_br)
>>>
>>> plotter = Plot3d()
>>> plotter.show_axes()
>>> plotter.add_contour(r, t, p, data, color='white')
>>> plotter.add_2d_slice(r[1], t, p, data[...,1], cmap="seismic", clim=(-30, 30))
>>> plotter.show()
../../../../../../_images/pyvisual-core-mixins-GridMeshMixin-add_contour-9306d10a6e01baef_00_00.png