APIs
Public
Types
Batsrus.Data
— TypePrimary data storage type
Functions
Batsrus.convertIDLtoVTK
— MethodconvertIDLtoVTK(filename; dir=".", gridType=1, verbose=false)
Convert 3D BATSRUS *.out to VTK. If gridType==1
, it converts to the rectilinear grid; if gridType==2
, it converts to the structured grid. If filename
does not end with "out", it tries to find the ".info" and ".tree" file with the same name tag and generates 3D unstructured VTU file.
Batsrus.convertTECtoVTU
— FunctionconvertTECtoVTU(head, data, connectivity, filename="out")
Convert unstructured Tecplot data to VTK. Note that if using voxel type data in VTK, the connectivity sequence is different from Tecplot. Note that the 3D connectivity sequence in Tecplot is the same with the hexahedron
type in VTK, but different with the voxel
type. The 2D connectivity sequence is the same as the quad
type, but different with the pixel
type. For example, in 3D the index conversion is:
# PLT to VTK voxel index_ = [1 2 4 3 5 6 8 7]
for i = 1:2
connectivity = swaprows!(connectivity, 4*i-1, 4*i)
end
Batsrus.cutdata
— Methodcutdata(data, var; plotrange=[-Inf,Inf,-Inf,Inf], dir="x", sequence=1)
Get 2D plane cut in orientation dir
for var
out of 3D box data
within plotrange
. The returned 2D data lies in the sequence
plane from - to + in dir
.
Batsrus.cutplot
— Functioncutplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir="x", sequence=1,
level=20)
2D plane cut contourf of 3D box data.
Batsrus.getConnectivity
— MethodGet cell connectivity list.
Batsrus.getvar
— MethodReturn variable data from string var
.
Batsrus.getvars
— Methodgetvars(data::Data, Names::Vector) -> Dict
Return variables' data as a dictionary from string vector. See also: getvar
.
Batsrus.plotdata
— Methodplotdata(data, func, kwargs)
Plot the variable from SWMF output.
plotdata(data, "p", plotmode="contbar")
plotdata(data, "p", plotmode="grid")
plotdata(data, func, plotmode="trimesh",plotrange=plotrange, plotinterval=0.2)
Input arguments
data::Data
: output data.func::String
: variables for plotting.plotmode::String
: (optional) type of plotting ["cont","contbar"]...plotrange::Vector
: (optional) range of plotting.plotinterval
: (optional) interval for interpolation.level
: (optional) level of contour.innermask
: (optional) Bool for masking a circle at the inner boundary.dir
: (optional) 2D cut plane orientation from 3D outputs ["x","y","z"].sequence
: (optional) sequence of plane from - to + in that direction.multifigure
: (optional) 1 for multifigure display, 0 for subplots.verbose
: (optional) display additional information.density
: (optional) density for streamlines.stride
: (optional) quiver strides in number of cells.
Right now this can only deal with 2D plots or 3D cuts. Full 3D plots may be supported in the future.
Batsrus.plotlogdata
— Methodplotlogdata(data, head, func; plotmode="line")
Plot information from log file.
Input arguments
data::Array
: output data.head::NamedTuple
: header info.func::String
: variables for plotting.plotmode::String
: type of plotting ["line","scatter"].
Batsrus.readdata
— Methodreaddata(filenameIn; dir=".", npict=1, verbose=false)
Read data from BATSRUS output files. Stores the npict
snapshot from an ascii or binary data file into the arrays of coordinates x
and data w
. Filename can be provided with wildcards.
Examples
data = readdata("1d_raw*")
Batsrus.readhead
— MethodReturn header from info file. Currently only designed for 2D and 3D.
Batsrus.readlogdata
— MethodRead information from log file.
Batsrus.readtecdata
— Methodreadtecdata(filename; verbose=false)
Return header, data and connectivity from BATSRUS Tecplot outputs. Both 2D and 3D binary and ASCII formats are supported.
Examples
filename = "3d_ascii.dat"
head, data, connectivity = readtecdata(filename)
Batsrus.readtree
— MethodReturn BATL tree structure.
Batsrus.showhead
— Functionshowhead(file, filehead)
Displaying file header information.
Batsrus.showhead
— Methodshowhead(data)
showhead(io, data)
Display file information of data
.
Batsrus.streamslice
— Functionstreamslice(data::Data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir="x",
sequence=1; kwargs...)
Plot streamlines on 2D slices of 3D box data. Variable names in var
string must be separated with ;
.
Batsrus.subsurface
— Methodsubsurface(x, y, data, limits)
subsurface(x, y, u, v, limits)
Extract subset of 2D surface dataset. See also: subvolume
.
Batsrus.subvolume
— Methodsubvolume(x, y, z, data, limits)
subvolume(x, y, z, u, v, w, limits)
Extract subset of 3D dataset in ndgrid format. See also: subsurface
.
PyPlot.contour
— Functioncontour(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],
plotinterval=0.1, innermask=false, kwargs...)
Wrapper over contour
in matplotlib.
PyPlot.contourf
— Functioncontourf(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],
plotinterval=0.1, innermask=false, kwargs...)
Wrapper over contourf
in matplotlib.
PyPlot.plot
— Functionplot(data, var, ax=nothing; kwargs...)
Wrapper over plot
in matplotlib.
PyPlot.plot_surface
— Methodplot_surface(data, var; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,
innermask=false, kwargs...)
Wrapper over plot_surface
in matplotlib.
PyPlot.plot_trisurf
— Functionplot_trisurf(data::Data, var::String, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf],
kwargs...)
Wrapper over plot_trisurf
in matplotlib.
PyPlot.quiver
— Functionquiver(data, var, ax=nothing; stride=10, kwargs...)
Wrapper over quiver
in matplotlib. Only supports Cartesian grid for now.
PyPlot.scatter
— Functionscatter(data, var, ax=nothing; kwargs...)
Wrapper over scatter
in matplotlib.
PyPlot.streamplot
— Functionstreamplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,
kwargs...)
Wrapper over streamplot
in matplotlib. streamplot
does not have **kwargs in the API, but it supports density
, color
, and some other keywords.
PyPlot.tricontourf
— Functiontricontourf(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,
kwargs...)
Wrapper over tricontourf
in matplotlib.
Private
Batsrus.FileList
— TypeType for the file information.
Batsrus.Head
— TypeBATSRUS output standalone header information.
Batsrus.allocateBuffer
— MethodCreate buffer for x and w.
Batsrus.create_pvd
— Methodcreate_pvd(filepattern)
Generate PVD file for a time series collection of VTK data.
Example
create_pvd("*.vtu)
Batsrus.fillCellNeighbors!
— MethodfillCellNeighbors!(batl, iCell_G, DiLevelNei_III, iNodeNei_III, nBlock_P)
Fill neighbor cell indexes for the given block. The faces, edges, and vertices are ordered from left (-) to right (+) in x-y-z sequentially. Vertices: Edges: (10,11 ignored) 7 ––- 8 . –4– .
- . - . 7 . 8 .
5 ––- 6 . . –3– . 12 . . . . . . . . . 3 ––- 4 9 . –2– . . - . - . 5 . 6 1 ––- 2 . –1– . Only tested for 3D.
Batsrus.find_grid_block
— Methodfindgridblock(batl, xyz_D)
Return processor local block index that contains a point. Input location should be given in Cartesian coordinates.
Batsrus.find_neighbor_for_anynode
— MethodFind neighbors for any node in the tree. Only for Cartesian now.
Batsrus.find_tree_node
— Methodfindtreenode(batl, Coord_D)
Find the node that contains a point. The point coordinates should be given in generalized coordinates normalized by the domain size.
Batsrus.findindex
— MethodFind variable index in data.
Batsrus.getSibling
— MethodReturn sibling index (1-8) for the given block node matrix.
Batsrus.getascii!
— MethodRead ascii format data.
Batsrus.getbinary!
— MethodRead binary format data.
Batsrus.getdata
— MethodPrepare 2D data arrays for passing to plotting functions.
Batsrus.getfilehead
— Methodgetfilehead(fileID, type) -> NameTuple
Obtain the header information from BATSRUS output file of type
linked to fileID
.
Input arguments
fileID::IOStream
: file identifier.type::String
: file type in ["ascii", "real4", "binary", "log"].
Batsrus.getfilesize
— MethodReturn the size in bytes for one snapshot.
Batsrus.getfiletype
— MethodObtain file type.
Batsrus.ibits
— MethodLogical shifts as the Fortran instrinsic function.
Batsrus.meshgrid
— MethodGenerating consistent 2D arrays for passing to plotting functions.
Batsrus.nodeToGlobalBlock
— MethodReturn global block index for the node.
Batsrus.order_children!
— Methodorder_children!(iNode)
Recursively apply Morton ordering for nodes below a root block. Store result into iNodeMortonI and iMortonNodeA using the iMorton index.
Batsrus.order_tree
— Methodorder_tree(batl)
Return maximum AMR level in the used block and the Morton curve order. Set iNodeMorton_I indirect index arrays according to
- root node order
- Morton ordering for each root node
Batsrus.set_colorbar
— FunctionSet colorbar norm and ticks.
Batsrus.setunits
— Methodsetunits(filehead, type; distance=1.0, mp=1.0, me=1.0)
Set the units for the output files. If type is given as "SI", "CGS", "NORMALIZED", "PIC", "PLANETARY", "SOLAR", set typeunit = type
, otherwise try to guess from the fileheader. Based on typeunit
set units for distance [xSI], time [tSI], density [rhoSI], pressure [pSI], magnetic field [bSI] and current density [jSI] in SI units. Distance unit [rplanet | rstar], ion and electron mass in [amu] can be set with optional distance
, mp
and me
.
Also calculate convenient constants ti0, cs0 ... for typical formulas. This function is currently not used anywhere!
Batsrus.subdata
— Methodsubdata(data, xind, yind, sz)
subdata(data, xind, yind, zind, sz)
Return the sliced data based on indexes xind
and yind
of size sz
.
Batsrus.swaprows!
— MethodReturn matrix X with swapped rows i and j.