gvec.vtk#
- gvec.vtk.ev2vtk(filename: Path | str, xrds: Dataset, quiet: bool = True)#
Write a GVEC evaluation dataset to a VTS file.
- Parameters:
filename (str) – The name of the output file without the ‘.vts’ extension.
xrds (xr.Dataset) – The dataset containing the evaluation data.
quiet (bool, optional) – If
False, print information on the output file, by defaultTrue.
Notes
The following data / dimensions are expected to be in the dataset: - ‘xyz’ : the dimension name for the cartesian components of grid points - ‘rad’ /’rho’ : the radial dimension name. If not present in xrds, it is added as {“rad”:[0]} - ‘pol’ /’theta’ : the poloidal dimension name. If not present in xrds, it is added as {“pol”:[0]} - ‘tor’ /’zeta’ : the toroidal dimension name. If not present in xrds, it is added as {“tor”:[0]} - ‘pos’ : datarray with the cartesian components of grid points, with dimension ‘xyz’ and at least one of [‘rad’, ‘pol’, ‘tor’]
Scalar variables are dataarrays without the ‘xyz’ dimension, and are broadcasted to the ‘rad’, ‘pol’, ‘tor’ dimensions. Vector variables are dataarrays with the ‘xyz’ dimension, and are broadcasted to the ‘xyz’, ‘rad’, ‘pol’, ‘tor’ dimensions.
If a dataarray (except ‘pos’) does not have the expected dimensions, it is ignored.
Examples
>>> from gvec.vtk import ev2vtk >>> import xarray as xr >>> filename = "my_evaluation" >>> xrds = xr.Dataset({"pos": (["xyz", "rad", "pol", "tor"], np.random.rand(3, 10, 10, 10))}) >>> ev2vtk(filename, xrds)
- gvec.vtk.gframe_to_vtk(file: str | Path, prefix='visu', zeta_visu: ndarray | None = None, theta_visu: ndarray | None = None, box_axis=None, visu_boundary=True, filetype='vts', quiet: bool = True)#
Reads a netcdf file that defines the G-Frame and possibly the boundary X1,X2 in that frame. The file is for example produced by the GVEC quasr script, and then used in GVEC for initialization. Writes vtk-visualization files from the data.
writes file
prefix_axis.filetype: if'axis'group exists infile, provides the origin curve position in 3D and N,B vectors on that curve. On full torus or on givenzeta_visupositionswrites file
prefix_boundary.filetype: if'boundary'group existsfile, provides the boundary surface position in 3D. On one field period, or on givenzeta_visupositionswrites file
prefix_axis_box.filetype: ifbox_axis=[a,b], G-Frame is visualized as a box aroud the axis.
- Parameters:
file (str | path) – netcdf file that contains axis and boundary data. Format as produced by the GVEC quasr script.
prefix (str, optional) – prefix of the output files. Default is
"visu".zeta_visu (numpy.ndarray, optional) – 1d zeta positions of the axis and boundary surface output. If not specified, the ones from the input file are used.
theta_visu (numpy.ndarray, optional) – 1d theta positions of the boundary surface output. If not specified, the ones from the input file are used.
box_axis (list, optional) – if
=[a,b], visualize G-Frame additionally as a box of with distances +a -a in N direction and +b -b in B direction.visu_boundary (bool) – if True, visualize the boundary surface
filetype (str) – can be
"vts"(default, VTK structured format) or"nc"(netcdf)quiet (bool, optional) – If
False, print information on the output files, by defaultTrue.