interpol

Module containing EfitData class for handling all interpolation related computations.

class INGRID.interpol.EfitData(rmin=0.0, rmax=1.0, nr=10, zmin=0.0, zmax=2.0, nz=20, rcenter=1.6955, bcenter=- 2.1094041, rlimiter=None, zlimiter=None, rmagx=0.0, zmagx=0.0, name='unnamed', parent=None)

Bases: object

Structure to store the rectangular grid of psi data. It uses cylindrical coordinates, where R and Z are similar to the cartesian x and y. The phi components goes away due to the symmetry of a tokamak.

Parameters
  • rmin (float, optional) – left boundary of the grid

  • rmax (float, optional) – right boundary

  • nr (int, optional) – number of grid points in the R direction

  • zmin (float, optional) – bottom boundary for the grid

  • zmax (float, optional) – top boundary

  • nz (int, optional) – number of grid points in the Z direction

  • name (str, optional) – Specify the title of the figure the data will be plotted on.

Gradient(xy: tuple) numpy.ndarray

Combines the first partial derivatives to solve the system for maximum, minimum, and saddle locations.

Parameters

xy (array-like) – Contains x and y. Ex: xy = (x0, y0).

Returns

F (array) – Vector function to be used in find root.

Hessian(xy: tuple) numpy.ndarray

Compute the Hessian at a point.

Parameters

xy (array-like) – Contains x and y. Ex: xy = (x0, y0).

Returns

H (array) – Numpy array of shape (2, 2) representing the Hessian at xy.

PlotLevel(level: float = 1.0, color: str = 'red', label: str = '', linestyles: str = 'solid', refined: bool = True, refine_factor: int = 10) None

Plot a psi level and provide it a label.

This function is useful for management of psi boundaries such as ‘psi_pf’, ‘psi_core’, etc and ensuring the contour will be properly replotted (no duplicate of same label).

Parameters
  • level (float, optional) – Psi level to plot. Default to 1.0 (separatrix of normalized psi)

  • color (str, optional) – Color to pass to matplotlib contour function

  • label (str, optional) – Label to associate with the psi level

  • linestyles (str, optional) – Line style to pass to matplotlib contour function

  • refined (bool, optional) – Plot level with hi-resolution cubic spline representation

  • refine_factor (int, optional) – Refinement factor for to be passed to SciPy zoom method

PsiFunction(xy)
clear_plot()
get_psi(r0, z0, tag='v')

find grid cell encompassing (r0,z0) note: grid is the crude grid. Uses Bicubic Interpolation to calculate the exact value at the point. Useful for finding information inbetween grid points.

Parameters
  • r0 (float) – R coordinate of the point of interest

  • z0 (float) – Z coordinate of same point.

  • tag (str, optional) – tag is the type of derivative we want: v, vr, vz, vrz if nothing is provided, it assumes no derivative (v).

Returns

float – Value of psi or its derviative at the coordinate specified.

init_bivariate_spline(r: numpy.ndarray, z: numpy.ndarray, v: numpy.ndarray) None

Initialize scipy.interpolate.RectBivariateSpline object for Bicubic interpolation.

Sets class member v to crude EFIT grid.

Parameters
  • r (array-like) – 1-D array of r coordinates in strictly ascending order.

  • z (array-like) – 1-D array of z coordinates in strictly ascending order.

  • v (array-like) – 2-D array of EFIT data with shape (r.shape, z.shape)

plot_data(nlevs: int = 30, interactive: bool = True, fig: Optional[object] = None, ax: Optional[object] = None, view_mode: str = 'filled', refined: bool = True, refine_factor: int = 10)

Plot the EFIT data.

Visualizes eqdsk file with either contour lines or filled contours.

Parameters
  • nlev (int, optional) – number of levels we want to be plotted

  • interactive (bool, optional) – Set matplotlib interactive mode on or off

  • fig (object, optional) – Matplotlib figure handle

  • ax (object, optional) – Matplotlib axes handle

  • view_mode (str, optional) – Represent EFIT data with standard contour lines or filled contour lines. String value of ‘filled’ enables filled contours, whereas ‘lines’ omits filling of contours.

  • refined (bool, optional) – Plot level with hi-resolution cubic spline representation

  • refine_factor (int, optional) – Refinement factor for to be passed to SciPy zoom method

plot_levels(level=1.0, color='red')

This function is useful if you need to quickly see where a particular line of constant psi is. It in’t able to store points of intersection, and cannot be generalized. If you need just a segment of psi, use the draw_lines method in the line tracing class.

Parameters
  • level (float, optional) – Value of psi you wish to see

  • color (str, optional) – color of the line.