gvec.plotting.plots2d#
- gvec.plotting.plots2d.plot_fourier_on_surface(state, quantity: str = 'mod_B', rho: float = 1.0, ntheta: int = 101, nzeta: int = 101, sfl: Literal['pest', 'boozer'] | None = None, limit: float | None = 1e-15, contour: bool = False, plot_kwargs: dict[str] = {}, **boozer_kwargs)#
Diagnostic plot for plotting the Fourier modes of a given quantitity on a flux surface.
- Parameters:
state (GVEC state object)
quantities (str, optional) – Quantitiy to plot. Default
mod_Brho (float, optional) – The flux surface label(s) to plot. Default is
1.0.ntheta (int, optional) – Resolution in
theta. Default is101nzeta (int, optional) – Resolution in
zeta. Default is101sfl (str, optional) – Plot surfaces in
"boozer","pest"or regular \(\theta-\zeta\) (None) coordinates. Default is"boozer"limit (float, optional) – Cut-off value for the Fourier amplitudes to plot. Default is
1e-15contour (bool, default: False) – If
True, plot filled contours, otherwise plot on a rectangular grid.plot_kwargs (dict, optional) – Any
**kwargsto send to theplt.figure()function. For exampleplot_kwargs={'figsize': (8,8)}. See the matplotlib documentation for a list of kwargs.boozer_kwargs (optional) – Additional keyword arguments to pass to the
get_boozermethod of thestateobject. These can be used to specify the Boozer transform parameters. For example the maximum mode number factorboozer_kwargs={'MNfactor': 3}.
- Return type:
matplotlib.pyplot.figureobject andnumpy.ndarrayofmatplotlib.axis._axis.Axesobject(s).
- gvec.plotting.plots2d.plot_on_flux_surface(state, quantities: str | list[str] = 'mod_B', rho: float | ndarray | list = 1.0, ntheta: int = 51, nzeta: int = 51, subplot_grid: list[int] | None = None, share_contours: bool = False, levels: int | ndarray | list = 10, sfl: Literal['pest', 'boozer'] | None = 'boozer', style: Literal['contour', 'filled-contour'] = 'contour', plot_kwargs: dict = {}, **boozer_kwargs)#
Plot an equilibrium quantity over the two angles \((\vartheta, \zeta)\) of a flux surface at (a) given
rhovalue(s). Alternatively, plot multiplequantitieson a singlerhosurface.- Parameters:
state (GVEC state object)
quantities (str, list[str], optional) – Plot either a single quantitiy on a number of rho surfaces or a number of quantities on a single rho surface. Default
mod_Brho (float, numpy.ndarray, list, optional) – The flux surface label(s) to plot. Default is
1.0.ntheta (int) – Resolution in
theta. Default is11nzeta (int) – Resolution in
zeta. Default is 11subplot_grid (list[int], optional) – The grid shape for the subplots. If
None, grid will be automatically determined. Default isNone.levels (int, numpy.ndarray, optional) – If
intthen chooses number of levels in the contour plot. If annumpy.ndarrayorlistthen plots contours at given values. Default is10sfl (str, optional) – Plot surfaces in
"boozer","pest"or regular \((\theta,\zeta)\) ("None") coordinates. Default is"boozer"style (str, optional) – Use
"contour"(False) or"filled-contour"(True) in plotting. Default is"filled-contour"(filled contour).plot_kwargs (dict, optional) –
Any
**kwargsto send to theplt.figure()function. For exampleplot_kwargs={'figsize': (8,8)}. See the matplotlib documentation for a list of kwargs.boozer_kwargs (optional) – Additional keyword arguments to pass to the
get_boozermethod of thestateobject. These can be used to specify the Boozer transform parameters. For example the maximum mode number factorboozer_kwargs={'MNfactor': 3}.
- Return type:
matplotlib.pyplot.figureobject andnumpy.ndarrayofmatplotlib.axis._axis.Axesobject(s).
- gvec.plotting.plots2d.plot_poloidal_plane(state, quantity: None | str = 'mod_B', rho: int | ndarray | list[float] = 21, ntheta: int = 51, zeta: int | float | ndarray | list[float] | None = None, subplot_grid: list[int] | None = None, share_axis: bool = False, rho_contours: int = 4, rho_contours_color: str | None = None, theta_contours: int = 8, theta_contours_color: str | None = None, sfl: Literal['pest'] | None = 'pest', levels: int = 10, colorbar_bounds: tuple = (None, None), colorbar_scale: Literal['linear', 'log'] = 'linear', plot_kwargs: dict = {})#
Plot a poloidal plane with some equilibrium quantity on it. Defaults to plotting \(|B|\)
- Parameters:
state (GVEC state object)
quantity (str, optional) – The quantity to plot. Default is
"mod_B". IfNone, no contours are plotted.rho (int, optional) – The radial resolution of the slices. Either by number, equally space, (
int), or values (np.ndarray). Default is21ntheta (int, optional) – The poloidal resolution of the slices. Default is
51zeta (int, float, ndarray, optional) – The number of equally spaced slices (
int), the specificzetavalue (float) or values (np.ndarray). Default isNone. Note: If None andn=0thenzeta=1, otherwisezeta=9.subplot_grid (list[int], None, optional) – The grid shape for the subplots. If
None, grid will be automatically determined. Default isNone.share_axis (bool) – If
True, all subplots will share theirX1andX2axis positions. DefaultFalserho_contours (int, optional) – The number of
rhocontours to plot. If0, no contours are plotted. Default4rho_contours_color (str, optional) – The color of the
rhocontours. Default"white"theta_contours (int, optional) – The number of
thetacontours to plot. If0, no contours are plotted. Default8theta_contours_color (str, optional) – The color of the
thetacontours. Default"white"sfl (
"pest"orNone, optional) – Plot thethetacontours orpestcontours (\(\theta^\star\)). Default"pest".levels (int, optional) – Choose number of levels in the contour plot. Default is
10colorbar_bounds (tuple, optional) – The bounds for the color scale of the plotted quantity, as a tuple of (min, max). Default is (None,None), then the bound is determined from the minimum and maximum of the plotted quantity. If only one is set to None, then that bound is determined from the plotted quantity.
colorbar_scale (str, optional) – Scale of the colorbar, either
"linear"or"log"for logarithmic scaling. Default is"linear".plot_kwargs (dict, optional) –
Any
**kwargsto send to theplt.figure()function. For exampleplot_kwargs={'figsize': (8,8)}. See the matplotlib documentation for a list of kwargs.
- Returns:
matplotlib.pyplot.figureobject andnumpy.ndarrayofmatplotlib.axis._axis.Axesobject(s).Remark
——
If you want to plot a new quantity that is not in the gvec list of quantities (Before calling the plotting, define a function that adds the new quantity to the dataset
ds, and use a decorator to register it. The decorator contains a list of required existing quantities and attributes of the new quantity (like the symbol), and the function defines how to compute it from the required quantities. Once the quantity is registered, you can use it for plotting.)Here an example
>>> @gvec.core.compute.register(
… requirements=(“mod_B”,”mu0”),
… attrs=dict(
… long_name=”magnetic pressure”,
… symbol=r”|B|^2/(2mu_0)”,
… ),
>>> )
>>> def magnetic_pressure(ds)
… ds[“magnetic_pressure”] = ds.mod_B**2/(2*ds.mu0)
You can nest this and register a second quantity that uses the previously registered in its requirements.