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_B

  • rho (float, optional) – The flux surface label(s) to plot. Default is 1.0.

  • ntheta (int, optional) – Resolution in theta. Default is 101

  • nzeta (int, optional) – Resolution in zeta. Default is 101

  • sfl (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-15

  • contour (bool, default: False) – If True, plot filled contours, otherwise plot on a rectangular grid.

  • plot_kwargs (dict, optional) – Any **kwargs to send to the plt.figure() function. For example plot_kwargs={'figsize': (8,8)}. See the matplotlib documentation for a list of kwargs.

  • boozer_kwargs (optional) – Additional keyword arguments to pass to the get_boozer method of the state object. These can be used to specify the Boozer transform parameters. For example the maximum mode number factor boozer_kwargs={'MNfactor': 3}.

Return type:

matplotlib.pyplot.figure object and numpy.ndarray of matplotlib.axis._axis.Axes object(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 rho value(s). Alternatively, plot multiple quantities on a single rho surface.

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_B

  • rho (float, numpy.ndarray, list, optional) – The flux surface label(s) to plot. Default is 1.0.

  • ntheta (int) – Resolution in theta. Default is 11

  • nzeta (int) – Resolution in zeta. Default is 11

  • subplot_grid (list[int], optional) – The grid shape for the subplots. If None, grid will be automatically determined. Default is None.

  • levels (int, numpy.ndarray, optional) – If int then chooses number of levels in the contour plot. If an numpy.ndarray or list then plots contours at given values. Default is 10

  • sfl (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 **kwargs to send to the plt.figure() function. For example plot_kwargs={'figsize': (8,8)}. See the matplotlib documentation for a list of kwargs.

  • boozer_kwargs (optional) – Additional keyword arguments to pass to the get_boozer method of the state object. These can be used to specify the Boozer transform parameters. For example the maximum mode number factor boozer_kwargs={'MNfactor': 3}.

Return type:

matplotlib.pyplot.figure object and numpy.ndarray of matplotlib.axis._axis.Axes object(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". If None, no contours are plotted.

  • rho (int, optional) – The radial resolution of the slices. Either by number, equally space, (int), or values (np.ndarray). Default is 21

  • ntheta (int, optional) – The poloidal resolution of the slices. Default is 51

  • zeta (int, float, ndarray, optional) – The number of equally spaced slices (int), the specific zeta value (float) or values (np.ndarray). Default is None. Note: If None and n=0 then zeta=1, otherwise zeta=9.

  • subplot_grid (list[int], None, optional) – The grid shape for the subplots. If None, grid will be automatically determined. Default is None.

  • share_axis (bool) – If True, all subplots will share their X1 and X2 axis positions. Default False

  • rho_contours (int, optional) – The number of rho contours to plot. If 0, no contours are plotted. Default 4

  • rho_contours_color (str, optional) – The color of the rho contours. Default "white"

  • theta_contours (int, optional) – The number of theta contours to plot. If 0, no contours are plotted. Default 8

  • theta_contours_color (str, optional) – The color of the theta contours. Default "white"

  • sfl ("pest" or None, optional) – Plot the theta contours or pest contours (\(\theta^\star\)). Default "pest".

  • levels (int, optional) – Choose number of levels in the contour plot. Default is 10

  • colorbar_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 **kwargs to send to the plt.figure() function. For example plot_kwargs={'figsize': (8,8)}. See the matplotlib documentation for a list of kwargs.

Returns:

  • matplotlib.pyplot.figure object and numpy.ndarray of matplotlib.axis._axis.Axes object(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.