Note
Go to the end to download the full example code.
1-D Line Slices#
This example demonstrates add_1d_slice()
— the method for rendering a line slice along a single spherical coordinate
axis.
Exactly two of r, t, p must be size-1 arrays, fixing those
coordinates. The one array with more than one element defines the slice
direction; pyvisual infers the varying axis automatically and renders the
result as a polyline colored by the supplied data array.
The two most common 1-D slice orientations in solar physics are the longitudinal profile (varying \(\phi\) at fixed \(r\) and :math:` heta`) and the meridional profile (varying :math:` heta` at fixed \(r\) and \(\phi\)).
import numpy as np
from pyvisual import Plot3d
Longitudinal Profile#
Fix the radius at \(r = 1\,R_\odot\) and the colatitude at the equatorial plane (\(\theta = \pi/2\)), then sweep longitude \(\phi\) from 0 to \(2\pi\). The synthetic data mimics a low-order multipole radial field \(B_r \propto \sin(2\phi)\).
r = np.array([1.0])
t = np.array([np.pi / 2])
p = np.linspace(0, 2 * np.pi, 360)
data = np.sin(2 * p) * np.cos(p / 2)
plotter = Plot3d(off_screen=True, window_size=(500, 500))
plotter.show_axes()
plotter.add_sun()
plotter.add_1d_slice(r, t, p, data,
cmap='seismic', clim=(-1, 1), line_width=5)
plotter.show()

Meridional Profile#
Fix the radius at \(r = 2\,R_\odot\) and the longitude at \(\phi = 0\), then sweep colatitude \(\theta\) from pole to pole. A dipole-like \(B_r \propto \cos\theta\) profile changes sign at the equatorial plane, as expected for a pure dipole field.

Total running time of the script: (0 minutes 0.914 seconds)