From 19c254d9dd7432b667d9498c2b56ac9241ff5ec2 Mon Sep 17 00:00:00 2001 From: zeptodoctor <44736852+zeptodoctor@users.noreply.github.com> Date: Mon, 20 Nov 2023 03:20:06 +0000 Subject: [PATCH] build based on cfcec4b --- dev/index.html | 2 +- dev/man/examples/index.html | 2 +- dev/man/internal/index.html | 30 +++++++++++++++--------------- dev/man/log/index.html | 2 +- dev/search/index.html | 2 +- dev/search_index.js | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dev/index.html b/dev/index.html index 70af6f6..07b8385 100644 --- a/dev/index.html +++ b/dev/index.html @@ -4,4 +4,4 @@ pkg> add Batsrus

Benchmark

Data loading speed of a 2.4GB 3D binary file, 317MB 3D binary file, and 65KB 2D binary file on Macbook Pro with quad core 2.2 GHz Intel i7 and 16 GB 1600 MHz DDR3:

2.4GBtmax [s]tmean [s]
Julia2.731.32
Python1.351.34
IDL6.186.08
MATLAB16.0210.60
317MBtmean [ms]
Julia180.8
Python179.5
IDL453.5
MATLAB698.4
65KBtmean [μs]
Julia163.36
Python4390.95
IDL1970.29
MATLAB19273.25

The Julia, IDL, and MATLAB version all shares the same kernel design. The timings are obtained for Julia v1.3.1, Python 3.7.6 + Numpy 1.18.1, IDL 8.5, and MATLAB R2018b. For dynamic languages with JIT, the first time when function gets executed is also the slowest due to runtime compilation, as can be seen from tmax in the tables. spacepy reaches the same level of performance as Batsruls.jl because of the well-optimized numpy library written in C. However, for small data sizes Batsrus.jl is much faster than packages written in other languages.

Calling From Python

In Python, you can easily take advantage of this package with the aid of PyJulia. After the installation, in the Python REPL:

from julia import Batsrus
 dir = 'test'
 file = '1d__raw_2_t25.60000_n00000258.out'
-data = Batsrus.load(file, dir=dir)

There you have it! Enjoy!

Python dependency

PyPlot package backend may be affected by the settings of PyJulia dependencies. If you want to set it back properly, you need to recompile the PyCall package in Julia.

Developers

This package inherits the ideas and code structures from its predecessor in IDL (developed by Gábor Tóth) and MATLAB.

Batsrus.jl is developed and maintained by Hongyang Zhou.

Acknowledgments

+data = Batsrus.load(file, dir=dir)

There you have it! Enjoy!

Python dependency

PyPlot package backend may be affected by the settings of PyJulia dependencies. If you want to set it back properly, you need to recompile the PyCall package in Julia.

Developers

This package inherits the ideas and code structures from its predecessor in IDL (developed by Gábor Tóth) and MATLAB.

Batsrus.jl is developed and maintained by Hongyang Zhou.

Acknowledgments

diff --git a/dev/man/examples/index.html b/dev/man/examples/index.html index 9fe0e2a..a16d221 100644 --- a/dev/man/examples/index.html +++ b/dev/man/examples/index.html @@ -101,4 +101,4 @@ x1, z1 = trace2d_eul(bx, bz, xs, zs, x, z, ds=0.1, maxstep=1000, gridType="ndgrid") plot(x1,z1,"--") end -axis("equal")

Currently the select_seeds function uses pseudo random number generator that produces the same seeds every time.

+axis("equal")

Currently the select_seeds function uses pseudo random number generator that produces the same seeds every time.

diff --git a/dev/man/internal/index.html b/dev/man/internal/index.html index 5c4e98a..01de607 100644 --- a/dev/man/internal/index.html +++ b/dev/man/internal/index.html @@ -1,18 +1,18 @@ -Internal · Batsrus.jl

APIs

Public

Types

Functions

Batsrus.convertIDLtoVTKMethod
convertIDLtoVTK(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.

source
Batsrus.convertTECtoVTUFunction
convertTECtoVTU(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: the 3D connectivity sequence in Tecplot is the same as 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]
+Internal · Batsrus.jl

APIs

Public

Types

Functions

Batsrus.convertIDLtoVTKMethod
convertIDLtoVTK(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.

source
Batsrus.convertTECtoVTUFunction
convertTECtoVTU(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: the 3D connectivity sequence in Tecplot is the same as 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
source
Batsrus.cutdataMethod
cutdata(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.

source
Batsrus.cutplotFunction
cutplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir="x", sequence=1,
-   level=20)

2D plane cut contourf of 3D box data.

source
Batsrus.getvarsMethod
getvars(data::BATLData, Names::Vector) -> Dict

Return variables' data as a dictionary from string vector. See also: getvar.

source
Batsrus.loadMethod
load(filenameIn; dir=".", npict=1, verbose=false)

Read 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 = load("1d_raw*")
source
Batsrus.plotdataMethod
plotdata(data, func, args, 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::BATLData: BATSRUS data to be visualized.
  • 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.

source
Batsrus.plotlogdataMethod
plotlogdata(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"].
source
Batsrus.readtecdataMethod
readtecdata(file; verbose=false)

Return header, data and connectivity from BATSRUS Tecplot outputs. Both 2D and 3D binary and ASCII formats are supported.

Examples

file = "3d_ascii.dat"
-head, data, connectivity = readtecdata(file)
source
Batsrus.streamsliceFunction
streamslice(data::BATLData, 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 ;.

source
Batsrus.subvolumeMethod
subvolume(x, y, z, data, limits)
-subvolume(x, y, z, u, v, w, limits)

Extract subset of 3D dataset in ndgrid format. See also: subsurface.

source
PyPlot.contourFunction
contour(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],
-   plotinterval=0.1, innermask=false, kwargs...)

Wrapper over contour in matplotlib.

source
PyPlot.contourfFunction
contourf(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],
-   plotinterval=0.1, innermask=false, kwargs...)

Wrapper over contourf in matplotlib.

source
PyPlot.plotFunction
plot(data, var, ax=nothing; kwargs...)

Wrapper over plot in matplotlib.

source
PyPlot.plot_surfaceMethod
plot_surface(data, var; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,
-   innermask=false, kwargs...)

Wrapper over plot_surface in matplotlib.

source
PyPlot.plot_trisurfFunction
plot_trisurf(data::BATLData, var::String, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf],
-   kwargs...)

Wrapper over plot_trisurf in matplotlib.

source
PyPlot.quiverFunction
quiver(data, var, ax=nothing; stride=10, kwargs...)

Wrapper over quiver in matplotlib. Only supports Cartesian grid for now.

source
PyPlot.scatterFunction
scatter(data, var, ax=nothing; kwargs...)

Wrapper over scatter in matplotlib.

source
PyPlot.streamplotFunction
streamplot(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.

source
PyPlot.tricontourfFunction
tricontourf(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,
-   kwargs...)

Wrapper over tricontourf in matplotlib.

source

Private

Batsrus.create_pvdMethod
create_pvd(filepattern)

Generate PVD file for a time series collection of VTK data.

Example

create_pvd("*.vtu)
source
Batsrus.fillCellNeighbors!Method
fillCellNeighbors!(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.

source
Batsrus.find_grid_blockMethod
find_grid_block(batl, xyz_D)

Return processor local block index that contains a point. Input location should be given in Cartesian coordinates.

source
Batsrus.find_tree_nodeMethod
find_tree_node(batl, Coord_D)

Find the node that contains a point. The point coordinates should be given in generalized coordinates normalized by the domain size.

source
Batsrus.getfileheadMethod
getfilehead(fileID::IoStream, filelist::FileList) -> NameTuple

Obtain the header information from BATSRUS output file of type linked to fileID.

Input arguments

  • fileID::IOStream: file identifier.
  • filelist::FileList: file information.
source
Batsrus.order_children!Method
order_children!(batl::Batl, iNode, iMorton::Int, iNodeMorton_I::Vector{Int32})

Recursively apply Morton ordering for nodes below a root block. Store result into iNodeMortonI and iMortonNodeA using the iMorton index.

source
Batsrus.order_treeMethod
order_tree(batl)

Return maximum AMR level in the used block and the Morton curve order. Set iNodeMorton_I indirect index arrays according to

  1. root node order
  2. Morton ordering for each root node
source
Batsrus.setunitsMethod
setunits(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!

source
Batsrus.subdataMethod
subdata(data, xind, yind, sz)
-subdata(data, xind, yind, zind, sz)

Return the sliced data based on indexes xind and yind of size sz.

source
+end
source
Batsrus.cutdataMethod
cutdata(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.

source
Batsrus.cutplotFunction
cutplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir="x", sequence=1,
+   level=20)

2D plane cut contourf of 3D box data.

source
Batsrus.getvarsMethod
getvars(data::BATLData, Names::Vector) -> Dict

Return variables' data as a dictionary from string vector. See also: getvar.

source
Batsrus.loadMethod
load(filenameIn; dir=".", npict=1, verbose=false)

Read 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 = load("1d_raw*")
source
Batsrus.plotdataMethod
plotdata(data, func, args, kwargs...)

Plot the variable from SWMF output.

plotdata(data, "p", plotmode="contbar")

plotdata(data, "p", plotmode="grid")

plotdata(data, func, plotmode="trimesh", plotrange=[-1.0, 1.0, -1.0, 1.0], plotinterval=0.2)

Arguments

  • bd::BATLData: BATSRUS data to be visualized.
  • func::String: variables for plotting.

Keywords

  • plotmode::String: type of plotting ["cont","contbar"]...
  • plotrange::Vector: range of plotting.
  • plotinterval: interval for interpolation.
  • level: level of contour.
  • innermask: Bool for masking a circle at the inner boundary.
  • dir: 2D cut plane orientation from 3D outputs ["x","y","z"].
  • sequence: sequence of plane from - to + in that direction.
  • multifigure: 1 for multifigure display, 0 for subplots.
  • verbose: display additional information.
  • density: density for streamlines.
  • stride: 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.

source
Batsrus.plotlogdataMethod
plotlogdata(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"].
source
Batsrus.readtecdataMethod
readtecdata(file; verbose=false)

Return header, data and connectivity from BATSRUS Tecplot outputs. Both 2D and 3D binary and ASCII formats are supported.

Examples

file = "3d_ascii.dat"
+head, data, connectivity = readtecdata(file)
source
Batsrus.streamsliceFunction
streamslice(data::BATLData, 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 ;.

source
Batsrus.subsurfaceMethod
subsurface(x, y, data, limits)
+subsurface(x, y, u, v, limits)

Extract subset of 2D surface dataset in ndgrid format. See also: subvolume.

source
Batsrus.subvolumeMethod
subvolume(x, y, z, data, limits)
+subvolume(x, y, z, u, v, w, limits)

Extract subset of 3D dataset in ndgrid format. See also: subsurface.

source
PyPlot.contourFunction
contour(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],
+   plotinterval=0.1, innermask=false, kwargs...)

Wrapper over contour in matplotlib.

source
PyPlot.contourfFunction
contourf(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],
+   plotinterval=0.1, innermask=false, kwargs...)

Wrapper over contourf in matplotlib.

source
PyPlot.plotFunction
plot(data, var, ax=nothing; kwargs...)

Wrapper over plot in matplotlib.

source
PyPlot.plot_surfaceMethod
plot_surface(data, var; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,
+   innermask=false, kwargs...)

Wrapper over plot_surface in matplotlib.

source
PyPlot.plot_trisurfFunction
plot_trisurf(data::BATLData, var::String, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf],
+   kwargs...)

Wrapper over plot_trisurf in matplotlib.

source
PyPlot.quiverFunction
quiver(data, var, ax=nothing; stride=10, kwargs...)

Wrapper over quiver in matplotlib. Only supports Cartesian grid for now.

source
PyPlot.scatterFunction
scatter(data, var, ax=nothing; kwargs...)

Wrapper over scatter in matplotlib.

source
PyPlot.streamplotFunction
streamplot(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.

source
PyPlot.tricontourfFunction
tricontourf(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,
+   kwargs...)

Wrapper over tricontourf in matplotlib.

source

Private

Batsrus.create_pvdMethod
create_pvd(filepattern)

Generate PVD file for a time series collection of VTK data.

Example

create_pvd("*.vtu)
source
Batsrus.fillCellNeighbors!Method
fillCellNeighbors!(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.

source
Batsrus.find_grid_blockMethod
find_grid_block(batl, xyz_D)

Return processor local block index that contains a point. Input location should be given in Cartesian coordinates.

source
Batsrus.find_tree_nodeMethod
find_tree_node(batl, Coord_D)

Find the node that contains a point. The point coordinates should be given in generalized coordinates normalized by the domain size.

source
Batsrus.getfileheadMethod
getfilehead(fileID::IoStream, filelist::FileList) -> NameTuple

Obtain the header information from BATSRUS output file of type linked to fileID.

Input arguments

  • fileID::IOStream: file identifier.
  • filelist::FileList: file information.
source
Batsrus.order_children!Method
order_children!(batl::Batl, iNode, iMorton::Int, iNodeMorton_I::Vector{Int32})

Recursively apply Morton ordering for nodes below a root block. Store result into iNodeMortonI and iMortonNodeA using the iMorton index.

source
Batsrus.order_treeMethod
order_tree(batl)

Return maximum AMR level in the used block and the Morton curve order. Set iNodeMorton_I indirect index arrays according to

  1. root node order
  2. Morton ordering for each root node
source
Batsrus.setunitsMethod
setunits(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!

source
Batsrus.subdataMethod
subdata(data, xind, yind, sz)
+subdata(data, xind, yind, zind, sz)

Return the sliced data based on indexes xind and yind of size sz.

source
diff --git a/dev/man/log/index.html b/dev/man/log/index.html index 7a84d0b..21e6f13 100644 --- a/dev/man/log/index.html +++ b/dev/man/log/index.html @@ -1,4 +1,4 @@ Log · Batsrus.jl

Development Log

All the workflows here is not restricted to one type of model output. After being familiar with new ideas and new models, one can easily make use of existing samples and create reader of their own. Because of the embarrassing parallelism nature of postprocessing, it is quite easy to take advantage of parallel approaches to process the data.

For the plotting, streamline tracing and particle tracing, a common problem is the grid and related interpolation process. Now I have FieldTracer.jl and TestParticle.jl designed specifically for these tasks.

Test Data

If you don't have SWMF data at hand, Batsrus.jl provides some test data for you to begin with.

using LazyArtifacts
 
-datapath = artifact"testdata" # where you can find multiple test data files

These are also used in the standard test. These will be automatically downloaded from batsrus_data if you run the package test locally.

VTK AMR Grid Structure

vtkOverlappingAMR implements a somewhat strict Berger-Collela AMR scheme:

  1. All grids are Cartesian.
  2. Grids at the same level do not overlap.
  3. The refinement ratios, RL, between adjacent levels are integer (typically 2 or 4) and uniform within the same level.
  4. Grid cells are never partially refined; i.e., each cell is refined to four quads in 2D or eight hexahedra in 3D.

Or in other words,

  • Refinement ratio across levels is constant.
  • Each block at levels > 0 need to be covered 100% by one parent block of

previous level.

  • Some other restriction about what happens at the boundary.

You can directly use vtkUniformGridAMR, which does not impose any restrictions. Most filters should work for this class - there just wouldn't be any specialized filters such as the dual-grid contour / clip ones for the vtkOverlappingAMR.

The vtkAMRInformation documentation consists only of

  • Refinement ratio between AMR levels
  • Grid spacing for each level
  • The file block index for each block parent child information, if requested

sample_2DAMR Sample 2D AMR Dataset with two levels and refinement ratio, RL=4. The root level (L0) consists of a single grid shown in black wireframe while the next level (L1) consists of two grids, depicted in green wireframe and red wireframe respectively. The two grids at L1 are projected from the root level to illustrate that the cells underneath are “hidden.”

In VTK, the collection of AMR grids is stored in a vtkHierarchicalBoxDataSet data-structure. Each grid, G(Li,k), is represented by a vtkUniformGrid data structure where the unique key pair (Li,k) denotes the corresponding level (Li) and the grid index within the level (k) with respect to the underlying hierarchical structure. An array historically known as IBLANK, stored as a cell attribute in vtkUniformGrid, denotes whether a cell is hidden or not. The blanking array is subsequently used by the mapper to hide lower resolution cells accordingly when visualizing the dataset.

To enable the execution of data queries without loading the entire dataset in memory, metadata information is employed. The metadata stores a minimal set of geometric information for each grid in the AMR hierarchy. Specifically, the AMR metadata, B(Li,k), corresponding to the grid G(Li,k), is represented using a vtkAMRBox object and it consists of the following information:

  1. N={Nx, Ny, Nz} — the cell dimensions of the grid (since the data is cell-centered)
  2. The grid spacing at level L, hL={hx,hy,hz}
  3. The grid level Li and grid index k
  4. The global dataset origin, X=(X0, Y0, Z0), i.e., the minimum origin from all grids in level L0
  5. The LoCorner and HiCorner, which describe the low and high corners of the rectangular region covered by the corresponding grid in a virtual integer lattice with the same spacing (h) that covers the entire domain.

sample_2DAMR

Given the metadata information stored in the AMR box of each grid, the refinement ratio at each level can be easily computed using relationship (1) from Table 1. Further, the cartesian bounds the corresponding grid covers and the number of points and cells is also available (see relationships 2-4 in Table 1). Notably, geometric queries such as determining which cell contains a given point, or if a grid intersects a user-supplied slice plane, can be answered using just the metadata.

There is a vtkAMRDualExtractionFilter, which constructs a dual-mesh (i.e., the mesh constructed by connecting the cell-centers) over the computational domain. If we can directly tell ParaView that the mesh we have is a dual-mesh, then the initial trial with multi-block data may work directly.

AMRGaussianPulseSource

See Multi-Resolution Rendering with Overlapping AMR for the implementation of C++ reader in VTK.

+datapath = artifact"testdata" # where you can find multiple test data files

These are also used in the standard test. These will be automatically downloaded from batsrus_data if you run the package test locally.

VTK AMR Grid Structure

vtkOverlappingAMR implements a somewhat strict Berger-Collela AMR scheme:

  1. All grids are Cartesian.
  2. Grids at the same level do not overlap.
  3. The refinement ratios, RL, between adjacent levels are integer (typically 2 or 4) and uniform within the same level.
  4. Grid cells are never partially refined; i.e., each cell is refined to four quads in 2D or eight hexahedra in 3D.

Or in other words,

previous level.

You can directly use vtkUniformGridAMR, which does not impose any restrictions. Most filters should work for this class - there just wouldn't be any specialized filters such as the dual-grid contour / clip ones for the vtkOverlappingAMR.

The vtkAMRInformation documentation consists only of

sample_2DAMR Sample 2D AMR Dataset with two levels and refinement ratio, RL=4. The root level (L0) consists of a single grid shown in black wireframe while the next level (L1) consists of two grids, depicted in green wireframe and red wireframe respectively. The two grids at L1 are projected from the root level to illustrate that the cells underneath are “hidden.”

In VTK, the collection of AMR grids is stored in a vtkHierarchicalBoxDataSet data-structure. Each grid, G(Li,k), is represented by a vtkUniformGrid data structure where the unique key pair (Li,k) denotes the corresponding level (Li) and the grid index within the level (k) with respect to the underlying hierarchical structure. An array historically known as IBLANK, stored as a cell attribute in vtkUniformGrid, denotes whether a cell is hidden or not. The blanking array is subsequently used by the mapper to hide lower resolution cells accordingly when visualizing the dataset.

To enable the execution of data queries without loading the entire dataset in memory, metadata information is employed. The metadata stores a minimal set of geometric information for each grid in the AMR hierarchy. Specifically, the AMR metadata, B(Li,k), corresponding to the grid G(Li,k), is represented using a vtkAMRBox object and it consists of the following information:

  1. N={Nx, Ny, Nz} — the cell dimensions of the grid (since the data is cell-centered)
  2. The grid spacing at level L, hL={hx,hy,hz}
  3. The grid level Li and grid index k
  4. The global dataset origin, X=(X0, Y0, Z0), i.e., the minimum origin from all grids in level L0
  5. The LoCorner and HiCorner, which describe the low and high corners of the rectangular region covered by the corresponding grid in a virtual integer lattice with the same spacing (h) that covers the entire domain.

sample_2DAMR

Given the metadata information stored in the AMR box of each grid, the refinement ratio at each level can be easily computed using relationship (1) from Table 1. Further, the cartesian bounds the corresponding grid covers and the number of points and cells is also available (see relationships 2-4 in Table 1). Notably, geometric queries such as determining which cell contains a given point, or if a grid intersects a user-supplied slice plane, can be answered using just the metadata.

There is a vtkAMRDualExtractionFilter, which constructs a dual-mesh (i.e., the mesh constructed by connecting the cell-centers) over the computational domain. If we can directly tell ParaView that the mesh we have is a dual-mesh, then the initial trial with multi-block data may work directly.

AMRGaussianPulseSource

See Multi-Resolution Rendering with Overlapping AMR for the implementation of C++ reader in VTK.

diff --git a/dev/search/index.html b/dev/search/index.html index 5aae8ed..f1d19b8 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · Batsrus.jl

Loading search...

    +Search · Batsrus.jl

    Loading search...

      diff --git a/dev/search_index.js b/dev/search_index.js index 4b681b0..579cdf2 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"man/examples/#Examples-1","page":"Example","title":"Examples","text":"","category":"section"},{"location":"man/examples/#IDL-format-output-loader-1","page":"Example","title":"IDL format output loader","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Read data","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"file = \"1d_bin.out\";\ndata = load(file);\ndata = load(file, verbose=true);\ndata = load(file, npict=1);\ndata = load(file, dir=\".\");","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"3D structured spherical coordinates","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"file = \"3d_structured.out\";\ndata = load(file, verbose=false);","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"log file","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"logfilename = \"shocktube.log\";\nhead, data = readlogdata(logfilename)","category":"page"},{"location":"man/examples/#Derived-variables-1","page":"Example","title":"Derived variables","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"v = getvars(data, [\"Bx\", \"By\", \"Bz\"])\nB = @. sqrt(v[\"Bx\"]^2 + v[\"By\"]^2 + v[\"Bz\"]^2)","category":"page"},{"location":"man/examples/#Output-format-conversion-1","page":"Example","title":"Output format conversion","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"We can convert 2D/3D BATSRUS outputs *.dat to VTK formats. It uses the VTK XML format writer writeVTK to generate files for Paraview and Tecplot. The default converted filename is out.vtu.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"ASCII Tecplot file (supports both tec and tcp) and binary Tecplot file (set DOSAVETECBINARY=TRUE in BATSRUS PARAM.in):","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"file = \"x=0_mhd_1_n00000050.dat\"\n#file = \"3d_ascii.dat\"\n#file = \"3d_bin.dat\"\nhead, data, connectivity = readtecdata(file)\nconvertTECtoVTU(head, data, connectivity)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"3D structured IDL file (gridType=1 returns rectilinear vtr file, gridType=2 returns structured vts file):","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"file3d_structured.out\"\nconvertIDLtoVTK(file, gridType=1)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"3D unstructured IDL file together with header and tree file:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"filetag = \"3d_var_1_n00002500\"\nconvertIDLtoVTK(filetag)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"note: Note\nThe file suffix should not be provided for this to work correctly!","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Multiple files:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Batsrus, Glob\nfilenamesIn = \"3d*.dat\"\ndir = \".\"\nfilenames = Vector{String}(undef,0)\nfilesfound = glob(filenamesIn, dir)\nfilenames = vcat(filenames, filesfound)\ntec = readtecdata.(filenames) # head, data, connectivity\nfor (i, outname) in enumerate(filenames)\n convertTECtoVTU(tec[i][1], tec[i][2], tec[i][3], outname[1:end-4])\nend","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"If each individual file size is large, consider using:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Batsrus, Glob\nfilenamesIn = \"3d*.dat\"\ndir = \".\"\nfilenames = Vector{String}(undef,0)\nfilesfound = glob(filenamesIn, dir)\nfilenames = vcat(filenames, filesfound)\nfor (i, outname) in enumerate(filenames)\n head, data, connectivity = readtecdata(outname)\n convertTECtoVTU(head, data, connectivity, outname[1:end-4])\nend","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Multiple files in parallel:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Distributed\n@everywhere using Batsrus, Glob\n\nfilenamesIn = \"cut*.dat\"\ndir = \".\"\nfilenames = Vector{String}(undef,0)\nfilesfound = glob(filenamesIn, dir)\nfilenames = vcat(filenames, filesfound)\n\n@sync @distributed for outname in filenames\n println(\"filename=$(outname)\")\n head, data, connectivity = readtecdata(outname)\n convertTECtoVTU(head, data, connectivity, outname[1:end-4])\nend","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"More examples can be found in examples.","category":"page"},{"location":"man/examples/#Data-visualization-1","page":"Example","title":"Data visualization","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"We provide plot recipes for Plots.jl and wrappers for PyPlot.jl.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"The recipes for Plots.jl will work on all functions given the correct dimensions, e.g.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Plots\nplot(data, \"p\")\ncontourf(data, \"Mx\", xlabel=\"x\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"See the official documentation for Plots.jl for more information.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"On the other hand, most common 1D and 2D plotting functions are wrapped over their Matplotlib equivalences through PyPlot.jl. To trigger the wrapper, using PyPlot. Check out the documentation for more details.","category":"page"},{"location":"man/examples/#Quick-exploration-of-data-1","page":"Example","title":"Quick exploration of data","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"A general plotdata function is provided for quick visualizations using Matplotlib.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"1D binary","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"p\", plotmode=\"line\")\nplotdata(data, \"p\", plotmode=\"linegrid\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"2D Cartesian (structured)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"p bx;by\", plotmode=\"contbar streamover\")\nplotdata(data, \"p bx;by\", plotmode=\"contbar quiverover\")\nplotdata(data, \"p bx;by\", plotmode=\"contbar streamover\", density=2.0)\nplotdata(data, \"p\", plotmode=\"grid\")\nplotdata(data, \"p\", plotmode=\"contbar\", plotrange=[-50., 50., -1., 1.])\nplotdata(data, \"p\", plotmode=\"contbar\")\nplotdata(data, \"p\", plotmode=\"contbarlog\")\nplotdata(data, \"p\", plotmode=\"surfbar\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"2D unstructured","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"rho\", plotmode=\"contbar\")\nplotdata(data, \"rho\", plotmode=\"trimesh\")\nplotdata(data, \"rho\", plotmode=\"tricont\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"2D structured spherical coordinates","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"rho\", plotmode=\"contbar\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"3D box","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"bx\", plotmode=\"contbar\", dir=\"y\", sequence=1, level=20)\nplotdata(data, \"bx\", plotmode=\"contbar\", dir=\"y\", plotrange=[-1.4,-1.1,0.70,0.78])\nusing PyPlot\nplt.axis(\"scaled\")\n\nsubplot(2,2,(1,3))\ncutplot(data, \"Ex\"; dir=\"y\", sequence=128, plotrange)","category":"page"},{"location":"man/examples/#Finding-indexes-1","page":"Example","title":"Finding indexes","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"To get the index of a certain quantity, e.g. electron number density","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"ρe_= findfirst(x->x==\"rhoS0\", data.head.wnames)","category":"page"},{"location":"man/examples/#Multiple-dispatch-for-Matplotlib-functions-1","page":"Example","title":"Multiple dispatch for Matplotlib functions","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Using the same plotting functions as in Matplotlib is allowed, and actually recommended. Some plotting functions can be directly called as shown below, which allows for more control from the user. using PyPlot to import the full capability of the package, etc. adding colorbar, changing line colors, setting colorbar range with clim.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"line plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plot(data, \"p\", linewidth=2, color=\"green\")\nc = plot(data, \"p\")\nplt.setp(c, linestyle=\"--\", linewidth=2);","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"scatter plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"scatter(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"contour","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"# 2D contour\ncontour(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"filled contour","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"contourf(data, \"p\")\ncontourf(data, \"p\", levels, plotrange=[-10,10,-Inf,Inf], plotinterval=0.1)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"surface plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plot_surface(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"triangle surface plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plot_trisurf(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"triangle filled contour plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"tricontourf(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"streamline","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"streamplot(data, \"bx;bz\")\nstreamplot(data, \"bx;bz\", density=2.0, color=\"k\", plotinterval=1.0, plotrange=[-10,10,-Inf,Inf])","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"quiver (currently only for Cartesian grid)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"quiver(data, \"ux;uy\", stride=50)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"streamline + contourf","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Batsrus, PyPlot\n\nfile = \"y*out\"\ndata = load(file)\n\nDN = matplotlib.colors.DivergingNorm\nset_cmap(\"RdBu_r\")\n\ncontourf(data, \"uxS0\", 50, plotrange=[-3,3,-3,3], plotinterval=0.05, norm=DN(0))\ncolorbar()\nstreamplot(data, \"uxS0;uzS0\", density=2.0, color=\"g\", plotrange=[-3,3,-3,3])\nxlabel(\"x\"); ylabel(\"y\"); title(\"Ux [km/s]\")\n\ncontourf(data,\"uxS0\", 50, plotinterval=0.05, norm=DN(0))\ncolorbar()\naxis(\"scaled\")\nxlabel(\"x\"); ylabel(\"y\"); title(\"uxS0\")","category":"page"},{"location":"man/examples/#Tracing-1","page":"Example","title":"Tracing","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"The built-in streamplot function in Matplotlib is not satisfactory for accurately tracing. Instead we recommend FieldTracer.jl for tracing fieldlines and streamlines.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"An example of tracing in a 2D cut and plot the field lines over contour:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Batsrus, PyPlot\n\nfile = \"y=0_var_1_t00000000_n00000000.out\"\ndata = load(file, dir=\"test\")\n\nbx = data.w[:,:,5]\nbz = data.w[:,:,7]\nx = data.x[:,1,1]\nz = data.x[1,:,2]\n\nseeds = select_seeds(x, z; nSeed=100) # randomly select the seeding points\n\nfor i = 1:size(seeds)[2]\n xs = seeds[1,i]\n zs = seeds[2,i]\n # Tracing in both direction. Check the document for more options.\n x1, z1 = trace2d_eul(bx, bz, xs, zs, x, z, ds=0.1, maxstep=1000, gridType=\"ndgrid\")\n plot(x1,z1,\"--\")\nend\naxis(\"equal\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Currently the select_seeds function uses pseudo random number generator that produces the same seeds every time.","category":"page"},{"location":"#Batsrus.jl-1","page":"Home","title":"Batsrus.jl","text":"","category":"section"},{"location":"#Overview-1","page":"Home","title":"Overview","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"note: Note\nThis package is still under development, so be careful for any future breaking changes!","category":"page"},{"location":"#","page":"Home","title":"Home","text":"BATSRUS and SWMF data reading, converting, visualizing and analyzing in Julia.","category":"page"},{"location":"#","page":"Home","title":"Home","text":"This package provides the following functionalities:","category":"page"},{"location":"#","page":"Home","title":"Home","text":"simulation data reader\nrun log plots\n2D/3D region cut from the whole data\nphase space distribution plots\ninterpolation from unstructured to structured data\ndata format conversion to VTK\nsimulation data visualization","category":"page"},{"location":"#","page":"Home","title":"Home","text":"The ultimate goal is to build a convenient tool of reading and analyzing simulation outputs which is easy to install and easy to use.","category":"page"},{"location":"#","page":"Home","title":"Home","text":"tip: Ready to use?\nFeel free to contact the author for any help or collaboration!","category":"page"},{"location":"#Installation-1","page":"Home","title":"Installation","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"Install VisAna from the julia REPL prompt with","category":"page"},{"location":"#","page":"Home","title":"Home","text":"using Pkg\nPkg.add(\"Batsrus\")","category":"page"},{"location":"#","page":"Home","title":"Home","text":"Or in the Pkg REPL","category":"page"},{"location":"#","page":"Home","title":"Home","text":"julia> ]\npkg> add Batsrus","category":"page"},{"location":"#Benchmark-1","page":"Home","title":"Benchmark","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"Data loading speed of a 2.4GB 3D binary file, 317MB 3D binary file, and 65KB 2D binary file on Macbook Pro with quad core 2.2 GHz Intel i7 and 16 GB 1600 MHz DDR3:","category":"page"},{"location":"#","page":"Home","title":"Home","text":"2.4GB tmax [s] tmean [s]\nJulia 2.73 1.32\nPython 1.35 1.34\nIDL 6.18 6.08\nMATLAB 16.02 10.60","category":"page"},{"location":"#","page":"Home","title":"Home","text":"317MB tmean [ms]\nJulia 180.8\nPython 179.5\nIDL 453.5\nMATLAB 698.4","category":"page"},{"location":"#","page":"Home","title":"Home","text":"65KB tmean [μs]\nJulia 163.36\nPython 4390.95\nIDL 1970.29\nMATLAB 19273.25","category":"page"},{"location":"#","page":"Home","title":"Home","text":"The Julia, IDL, and MATLAB version all shares the same kernel design. The timings are obtained for Julia v1.3.1, Python 3.7.6 + Numpy 1.18.1, IDL 8.5, and MATLAB R2018b. For dynamic languages with JIT, the first time when function gets executed is also the slowest due to runtime compilation, as can be seen from tmax in the tables. spacepy reaches the same level of performance as Batsruls.jl because of the well-optimized numpy library written in C. However, for small data sizes Batsrus.jl is much faster than packages written in other languages.","category":"page"},{"location":"#Calling-From-Python-1","page":"Home","title":"Calling From Python","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"In Python, you can easily take advantage of this package with the aid of PyJulia. After the installation, in the Python REPL:","category":"page"},{"location":"#","page":"Home","title":"Home","text":"from julia import Batsrus\ndir = 'test'\nfile = '1d__raw_2_t25.60000_n00000258.out'\ndata = Batsrus.load(file, dir=dir)","category":"page"},{"location":"#","page":"Home","title":"Home","text":"There you have it! Enjoy!","category":"page"},{"location":"#","page":"Home","title":"Home","text":"warning: Python dependency\nPyPlot package backend may be affected by the settings of PyJulia dependencies. If you want to set it back properly, you need to recompile the PyCall package in Julia.","category":"page"},{"location":"#Developers-1","page":"Home","title":"Developers","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"This package inherits the ideas and code structures from its predecessor in IDL (developed by Gábor Tóth) and MATLAB.","category":"page"},{"location":"#","page":"Home","title":"Home","text":"Batsrus.jl is developed and maintained by Hongyang Zhou.","category":"page"},{"location":"#Acknowledgments-1","page":"Home","title":"Acknowledgments","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"All the nice guys who share their codes!","category":"page"},{"location":"man/internal/#APIs-1","page":"Internal","title":"APIs","text":"","category":"section"},{"location":"man/internal/#Public-1","page":"Internal","title":"Public","text":"","category":"section"},{"location":"man/internal/#Types-1","page":"Internal","title":"Types","text":"","category":"section"},{"location":"man/internal/#","page":"Internal","title":"Internal","text":"Modules = [Batsrus]\nPrivate = false\nOrder = [:type]","category":"page"},{"location":"man/internal/#Batsrus.BATLData","page":"Internal","title":"Batsrus.BATLData","text":"Primary BATLData storage type\n\n\n\n\n\n","category":"type"},{"location":"man/internal/#Functions-1","page":"Internal","title":"Functions","text":"","category":"section"},{"location":"man/internal/#","page":"Internal","title":"Internal","text":"Modules = [Batsrus]\nPrivate = false\nOrder = [:function]","category":"page"},{"location":"man/internal/#Batsrus.convertIDLtoVTK-Tuple{AbstractString}","page":"Internal","title":"Batsrus.convertIDLtoVTK","text":"convertIDLtoVTK(filename; dir=\".\", gridType=1, verbose=false)\n\nConvert 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.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.convertTECtoVTU","page":"Internal","title":"Batsrus.convertTECtoVTU","text":"convertTECtoVTU(head, data, connectivity, filename=\"out\")\n\nConvert unstructured Tecplot data to VTK. Note that if using voxel type data in VTK, the connectivity sequence is different from Tecplot: the 3D connectivity sequence in Tecplot is the same as 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:\n\n# PLT to VTK voxel index_ = [1 2 4 3 5 6 8 7]\nfor i = 1:2\n connectivity = swaprows!(connectivity, 4*i-1, 4*i)\nend\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.cutdata-Tuple{BATLData, AbstractString}","page":"Internal","title":"Batsrus.cutdata","text":"cutdata(data, var; plotrange=[-Inf,Inf,-Inf,Inf], dir=\"x\", sequence=1)\n\nGet 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.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.cutplot","page":"Internal","title":"Batsrus.cutplot","text":"cutplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir=\"x\", sequence=1,\n level=20)\n\n2D plane cut contourf of 3D box data.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.getConnectivity-Tuple{Batl}","page":"Internal","title":"Batsrus.getConnectivity","text":"Get cell connectivity list.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getvar-Tuple{BATLData, Any}","page":"Internal","title":"Batsrus.getvar","text":"Return variable data from string var.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getvars-Union{Tuple{T}, Tuple{BATLData, Vector{T}}} where T<:AbstractString","page":"Internal","title":"Batsrus.getvars","text":"getvars(data::BATLData, Names::Vector) -> Dict\n\nReturn variables' data as a dictionary from string vector. See also: getvar.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.load-Tuple{AbstractString}","page":"Internal","title":"Batsrus.load","text":"load(filenameIn; dir=\".\", npict=1, verbose=false)\n\nRead 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.\n\nExamples\n\ndata = load(\"1d_raw*\")\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.plotdata-Tuple{BATLData, AbstractString}","page":"Internal","title":"Batsrus.plotdata","text":"plotdata(data, func, args, kwargs...)\n\nPlot the variable from SWMF output.\n\nplotdata(data, \"p\", plotmode=\"contbar\")\n\nplotdata(data, \"p\", plotmode=\"grid\")\n\nplotdata(data, func, plotmode=\"trimesh\",plotrange=plotrange, plotinterval=0.2)\n\nInput arguments\n\ndata::BATLData: BATSRUS data to be visualized.\nfunc::String: variables for plotting.\nplotmode::String: (optional) type of plotting [\"cont\",\"contbar\"]...\nplotrange::Vector: (optional) range of plotting.\nplotinterval: (optional) interval for interpolation.\nlevel: (optional) level of contour.\ninnermask: (optional) Bool for masking a circle at the inner boundary.\ndir: (optional) 2D cut plane orientation from 3D outputs [\"x\",\"y\",\"z\"].\nsequence: (optional) sequence of plane from - to + in that direction.\nmultifigure: (optional) 1 for multifigure display, 0 for subplots.\nverbose: (optional) display additional information.\ndensity: (optional) density for streamlines.\nstride: (optional) quiver strides in number of cells.\n\nRight now this can only deal with 2D plots or 3D cuts. Full 3D plots may be supported in the future.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.plotlogdata-Tuple{Any, NamedTuple, AbstractString}","page":"Internal","title":"Batsrus.plotlogdata","text":"plotlogdata(data, head, func; plotmode=\"line\")\n\nPlot information from log file.\n\nInput arguments\n\ndata::Array: output data.\nhead::NamedTuple: header info.\nfunc::String: variables for plotting.\nplotmode::String: type of plotting [\"line\",\"scatter\"].\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.readhead-Tuple{Any}","page":"Internal","title":"Batsrus.readhead","text":"Return header from info file. Currently only designed for 2D and 3D.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.readlogdata-Tuple{AbstractString}","page":"Internal","title":"Batsrus.readlogdata","text":"Read information from log file.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.readtecdata-Tuple{AbstractString}","page":"Internal","title":"Batsrus.readtecdata","text":"readtecdata(file; verbose=false)\n\nReturn header, data and connectivity from BATSRUS Tecplot outputs. Both 2D and 3D binary and ASCII formats are supported.\n\nExamples\n\nfile = \"3d_ascii.dat\"\nhead, data, connectivity = readtecdata(file)\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.readtree-Tuple{Any}","page":"Internal","title":"Batsrus.readtree","text":"Return BATL tree structure.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.showhead","page":"Internal","title":"Batsrus.showhead","text":"showhead(file, filehead)\n\nDisplaying file header information.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.showhead-Tuple{BATLData}","page":"Internal","title":"Batsrus.showhead","text":"showhead(data)\nshowhead(io, data)\n\nDisplay file information of data.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.streamslice","page":"Internal","title":"Batsrus.streamslice","text":"streamslice(data::BATLData, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir=\"x\",\n sequence=1; kwargs...)\n\nPlot streamlines on 2D slices of 3D box data. Variable names in var string must be separated with ;.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.subsurface-NTuple{4, Any}","page":"Internal","title":"Batsrus.subsurface","text":"subsurface(x, y, data, limits)\nsubsurface(x, y, u, v, limits)\n\nExtract subset of 2D surface dataset. See also: subvolume.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.subvolume-NTuple{5, Any}","page":"Internal","title":"Batsrus.subvolume","text":"subvolume(x, y, z, data, limits)\nsubvolume(x, y, z, u, v, w, limits)\n\nExtract subset of 3D dataset in ndgrid format. See also: subsurface.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#PyPlot.contour","page":"Internal","title":"PyPlot.contour","text":"contour(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],\n plotinterval=0.1, innermask=false, kwargs...)\n\nWrapper over contour in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.contourf","page":"Internal","title":"PyPlot.contourf","text":"contourf(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],\n plotinterval=0.1, innermask=false, kwargs...)\n\nWrapper over contourf in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.plot","page":"Internal","title":"PyPlot.plot","text":"plot(data, var, ax=nothing; kwargs...)\n\nWrapper over plot in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.plot_surface-Tuple{BATLData, AbstractString}","page":"Internal","title":"PyPlot.plot_surface","text":"plot_surface(data, var; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,\n innermask=false, kwargs...)\n\nWrapper over plot_surface in matplotlib.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#PyPlot.plot_trisurf","page":"Internal","title":"PyPlot.plot_trisurf","text":"plot_trisurf(data::BATLData, var::String, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf],\n kwargs...)\n\nWrapper over plot_trisurf in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.quiver","page":"Internal","title":"PyPlot.quiver","text":"quiver(data, var, ax=nothing; stride=10, kwargs...)\n\nWrapper over quiver in matplotlib. Only supports Cartesian grid for now.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.scatter","page":"Internal","title":"PyPlot.scatter","text":"scatter(data, var, ax=nothing; kwargs...)\n\nWrapper over scatter in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.streamplot","page":"Internal","title":"PyPlot.streamplot","text":"streamplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,\n kwargs...)\n\nWrapper over streamplot in matplotlib. streamplot does not have **kwargs in the API, but it supports density, color, and some other keywords.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.tricontourf","page":"Internal","title":"PyPlot.tricontourf","text":"tricontourf(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,\n kwargs...)\n\nWrapper over tricontourf in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#","page":"Internal","title":"Internal","text":"Modules = [UnitfulBatsrus]\nPrivate = false\nOrder = [:function]","category":"page"},{"location":"man/internal/#Private-1","page":"Internal","title":"Private","text":"","category":"section"},{"location":"man/internal/#","page":"Internal","title":"Internal","text":"Modules = [Batsrus]\nPublic = false","category":"page"},{"location":"man/internal/#Batsrus.FileList","page":"Internal","title":"Batsrus.FileList","text":"Type for the file information.\n\n\n\n\n\n","category":"type"},{"location":"man/internal/#Batsrus.Head","page":"Internal","title":"Batsrus.Head","text":"BATSRUS output standalone header information.\n\n\n\n\n\n","category":"type"},{"location":"man/internal/#Batsrus.allocateBuffer-Tuple{NamedTuple, DataType}","page":"Internal","title":"Batsrus.allocateBuffer","text":"Create buffer for x and w.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.create_pvd-Tuple{String}","page":"Internal","title":"Batsrus.create_pvd","text":"create_pvd(filepattern)\n\nGenerate PVD file for a time series collection of VTK data.\n\nExample\n\ncreate_pvd(\"*.vtu)\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.fillCellNeighbors!-Tuple{Batl, Vararg{Any, 4}}","page":"Internal","title":"Batsrus.fillCellNeighbors!","text":"fillCellNeighbors!(batl, iCell_G, DiLevelNei_III, iNodeNei_III, nBlock_P)\n\nFill neighbor cell indexes for the given block. The faces, edges, and vertices are ordered from left (-) to right (+) in x-y-z sequentially.\n\nVertices: Edges: (10,11 ignored)\n\n7 ––- 8 . –4– .\n\n. - . 7 . 8 .\n\n5 ––- 6 . . –3– . 12 . . . . . . . . . 3 ––- 4 9 . –2– . . - . - . 5 . 6 1 ––- 2 . –1– .\n\nOnly tested for 3D.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.find_grid_block-Tuple{Batl, Any}","page":"Internal","title":"Batsrus.find_grid_block","text":"find_grid_block(batl, xyz_D)\n\nReturn processor local block index that contains a point. Input location should be given in Cartesian coordinates.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.find_neighbor_for_anynode-Tuple{Batl, Int64}","page":"Internal","title":"Batsrus.find_neighbor_for_anynode","text":"Find neighbors for any node in the tree. Only for Cartesian now.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.find_tree_node-Tuple{Batl, Any}","page":"Internal","title":"Batsrus.find_tree_node","text":"find_tree_node(batl, Coord_D)\n\nFind the node that contains a point. The point coordinates should be given in generalized coordinates normalized by the domain size.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.findindex-Tuple{BATLData, AbstractString}","page":"Internal","title":"Batsrus.findindex","text":"Find variable index in data.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getSibling-Tuple{Any, Any}","page":"Internal","title":"Batsrus.getSibling","text":"Return sibling index (1-8) for the given block node matrix.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getascii!-Tuple{Any, Any, IOStream, NamedTuple}","page":"Internal","title":"Batsrus.getascii!","text":"Read ascii format data.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getbinary!-Tuple{Any, Any, IOStream, NamedTuple}","page":"Internal","title":"Batsrus.getbinary!","text":"Read binary format data.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getdata-Tuple{BATLData, AbstractString, Any, Any}","page":"Internal","title":"Batsrus.getdata","text":"Prepare 2D data arrays for passing to plotting functions.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getfilehead-Tuple{IOStream, Batsrus.FileList}","page":"Internal","title":"Batsrus.getfilehead","text":"getfilehead(fileID::IoStream, filelist::FileList) -> NameTuple\n\nObtain the header information from BATSRUS output file of type linked to fileID.\n\nInput arguments\n\nfileID::IOStream: file identifier.\nfilelist::FileList: file information.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getfilesize-Tuple{IOStream, Symbol, Int32}","page":"Internal","title":"Batsrus.getfilesize","text":"Return the size in bytes for one snapshot.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getfiletype-Tuple{String, String}","page":"Internal","title":"Batsrus.getfiletype","text":"Obtain file type.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.ibits-Tuple{Any, Any, Any}","page":"Internal","title":"Batsrus.ibits","text":"Logical shifts as the Fortran instrinsic function.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.meshgrid-Tuple{Any, Any}","page":"Internal","title":"Batsrus.meshgrid","text":"Generating consistent 2D arrays for passing to plotting functions.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.nodeToGlobalBlock-Tuple{Batl, Int32, Any}","page":"Internal","title":"Batsrus.nodeToGlobalBlock","text":"Return global block index for the node.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.order_children!-Tuple{Batl, Int32, Int64, Vector{Int32}}","page":"Internal","title":"Batsrus.order_children!","text":"order_children!(batl::Batl, iNode, iMorton::Int, iNodeMorton_I::Vector{Int32})\n\nRecursively apply Morton ordering for nodes below a root block. Store result into iNodeMortonI and iMortonNodeA using the iMorton index.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.order_tree-Tuple{Batl}","page":"Internal","title":"Batsrus.order_tree","text":"order_tree(batl)\n\nReturn maximum AMR level in the used block and the Morton curve order. Set iNodeMorton_I indirect index arrays according to\n\nroot node order\nMorton ordering for each root node\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.set_colorbar","page":"Internal","title":"Batsrus.set_colorbar","text":"Set colorbar norm and ticks.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.setunits-Tuple{Any, Any}","page":"Internal","title":"Batsrus.setunits","text":"setunits(filehead, type; distance=1.0, mp=1.0, me=1.0)\n\nSet 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.\n\nAlso calculate convenient constants ti0, cs0 ... for typical formulas. This function is currently not used anywhere!\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.subdata-NTuple{4, Any}","page":"Internal","title":"Batsrus.subdata","text":"subdata(data, xind, yind, sz)\nsubdata(data, xind, yind, zind, sz)\n\nReturn the sliced data based on indexes xind and yind of size sz.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.swaprows!-Tuple{Matrix, Int64, Int64}","page":"Internal","title":"Batsrus.swaprows!","text":"Return matrix X with swapped rows i and j.\n\n\n\n\n\n","category":"method"},{"location":"man/log/#Development-Log-1","page":"Log","title":"Development Log","text":"","category":"section"},{"location":"man/log/#","page":"Log","title":"Log","text":"All the workflows here is not restricted to one type of model output. After being familiar with new ideas and new models, one can easily make use of existing samples and create reader of their own. Because of the embarrassing parallelism nature of postprocessing, it is quite easy to take advantage of parallel approaches to process the data.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"For the plotting, streamline tracing and particle tracing, a common problem is the grid and related interpolation process. Now I have FieldTracer.jl and TestParticle.jl designed specifically for these tasks.","category":"page"},{"location":"man/log/#Test-Data-1","page":"Log","title":"Test Data","text":"","category":"section"},{"location":"man/log/#","page":"Log","title":"Log","text":"If you don't have SWMF data at hand, Batsrus.jl provides some test data for you to begin with.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"using LazyArtifacts\n\ndatapath = artifact\"testdata\" # where you can find multiple test data files","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"These are also used in the standard test. These will be automatically downloaded from batsrus_data if you run the package test locally.","category":"page"},{"location":"man/log/#VTK-AMR-Grid-Structure-1","page":"Log","title":"VTK AMR Grid Structure","text":"","category":"section"},{"location":"man/log/#","page":"Log","title":"Log","text":"vtkOverlappingAMR implements a somewhat strict Berger-Collela AMR scheme:","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"All grids are Cartesian.\nGrids at the same level do not overlap.\nThe refinement ratios, RL, between adjacent levels are integer (typically 2 or 4) and uniform within the same level.\nGrid cells are never partially refined; i.e., each cell is refined to four quads in 2D or eight hexahedra in 3D.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Or in other words,","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Refinement ratio across levels is constant.\nEach block at levels > 0 need to be covered 100% by one parent block of","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"previous level.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Some other restriction about what happens at the boundary.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"You can directly use vtkUniformGridAMR, which does not impose any restrictions. Most filters should work for this class - there just wouldn't be any specialized filters such as the dual-grid contour / clip ones for the vtkOverlappingAMR.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"The vtkAMRInformation documentation consists only of","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Refinement ratio between AMR levels\nGrid spacing for each level\nThe file block index for each block parent child information, if requested","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"(Image: sample_2DAMR) Sample 2D AMR Dataset with two levels and refinement ratio, RL=4. The root level (L0) consists of a single grid shown in black wireframe while the next level (L1) consists of two grids, depicted in green wireframe and red wireframe respectively. The two grids at L1 are projected from the root level to illustrate that the cells underneath are “hidden.”","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"In VTK, the collection of AMR grids is stored in a vtkHierarchicalBoxDataSet data-structure. Each grid, G(Li,k), is represented by a vtkUniformGrid data structure where the unique key pair (Li,k) denotes the corresponding level (Li) and the grid index within the level (k) with respect to the underlying hierarchical structure. An array historically known as IBLANK, stored as a cell attribute in vtkUniformGrid, denotes whether a cell is hidden or not. The blanking array is subsequently used by the mapper to hide lower resolution cells accordingly when visualizing the dataset.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"To enable the execution of data queries without loading the entire dataset in memory, metadata information is employed. The metadata stores a minimal set of geometric information for each grid in the AMR hierarchy. Specifically, the AMR metadata, B(Li,k), corresponding to the grid G(Li,k), is represented using a vtkAMRBox object and it consists of the following information:","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"N={Nx, Ny, Nz} — the cell dimensions of the grid (since the data is cell-centered)\nThe grid spacing at level L, hL={hx,hy,hz}\nThe grid level Li and grid index k\nThe global dataset origin, X=(X0, Y0, Z0), i.e., the minimum origin from all grids in level L0\nThe LoCorner and HiCorner, which describe the low and high corners of the rectangular region covered by the corresponding grid in a virtual integer lattice with the same spacing (h) that covers the entire domain.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"(Image: sample_2DAMR)","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Given the metadata information stored in the AMR box of each grid, the refinement ratio at each level can be easily computed using relationship (1) from Table 1. Further, the cartesian bounds the corresponding grid covers and the number of points and cells is also available (see relationships 2-4 in Table 1). Notably, geometric queries such as determining which cell contains a given point, or if a grid intersects a user-supplied slice plane, can be answered using just the metadata.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"There is a vtkAMRDualExtractionFilter, which constructs a dual-mesh (i.e., the mesh constructed by connecting the cell-centers) over the computational domain. If we can directly tell ParaView that the mesh we have is a dual-mesh, then the initial trial with multi-block data may work directly.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"AMRGaussianPulseSource","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"See Multi-Resolution Rendering with Overlapping AMR for the implementation of C++ reader in VTK.","category":"page"}] +[{"location":"man/examples/#Examples-1","page":"Example","title":"Examples","text":"","category":"section"},{"location":"man/examples/#IDL-format-output-loader-1","page":"Example","title":"IDL format output loader","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Read data","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"file = \"1d_bin.out\";\ndata = load(file);\ndata = load(file, verbose=true);\ndata = load(file, npict=1);\ndata = load(file, dir=\".\");","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"3D structured spherical coordinates","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"file = \"3d_structured.out\";\ndata = load(file, verbose=false);","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"log file","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"logfilename = \"shocktube.log\";\nhead, data = readlogdata(logfilename)","category":"page"},{"location":"man/examples/#Derived-variables-1","page":"Example","title":"Derived variables","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"v = getvars(data, [\"Bx\", \"By\", \"Bz\"])\nB = @. sqrt(v[\"Bx\"]^2 + v[\"By\"]^2 + v[\"Bz\"]^2)","category":"page"},{"location":"man/examples/#Output-format-conversion-1","page":"Example","title":"Output format conversion","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"We can convert 2D/3D BATSRUS outputs *.dat to VTK formats. It uses the VTK XML format writer writeVTK to generate files for Paraview and Tecplot. The default converted filename is out.vtu.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"ASCII Tecplot file (supports both tec and tcp) and binary Tecplot file (set DOSAVETECBINARY=TRUE in BATSRUS PARAM.in):","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"file = \"x=0_mhd_1_n00000050.dat\"\n#file = \"3d_ascii.dat\"\n#file = \"3d_bin.dat\"\nhead, data, connectivity = readtecdata(file)\nconvertTECtoVTU(head, data, connectivity)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"3D structured IDL file (gridType=1 returns rectilinear vtr file, gridType=2 returns structured vts file):","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"file3d_structured.out\"\nconvertIDLtoVTK(file, gridType=1)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"3D unstructured IDL file together with header and tree file:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"filetag = \"3d_var_1_n00002500\"\nconvertIDLtoVTK(filetag)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"note: Note\nThe file suffix should not be provided for this to work correctly!","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Multiple files:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Batsrus, Glob\nfilenamesIn = \"3d*.dat\"\ndir = \".\"\nfilenames = Vector{String}(undef,0)\nfilesfound = glob(filenamesIn, dir)\nfilenames = vcat(filenames, filesfound)\ntec = readtecdata.(filenames) # head, data, connectivity\nfor (i, outname) in enumerate(filenames)\n convertTECtoVTU(tec[i][1], tec[i][2], tec[i][3], outname[1:end-4])\nend","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"If each individual file size is large, consider using:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Batsrus, Glob\nfilenamesIn = \"3d*.dat\"\ndir = \".\"\nfilenames = Vector{String}(undef,0)\nfilesfound = glob(filenamesIn, dir)\nfilenames = vcat(filenames, filesfound)\nfor (i, outname) in enumerate(filenames)\n head, data, connectivity = readtecdata(outname)\n convertTECtoVTU(head, data, connectivity, outname[1:end-4])\nend","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Multiple files in parallel:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Distributed\n@everywhere using Batsrus, Glob\n\nfilenamesIn = \"cut*.dat\"\ndir = \".\"\nfilenames = Vector{String}(undef,0)\nfilesfound = glob(filenamesIn, dir)\nfilenames = vcat(filenames, filesfound)\n\n@sync @distributed for outname in filenames\n println(\"filename=$(outname)\")\n head, data, connectivity = readtecdata(outname)\n convertTECtoVTU(head, data, connectivity, outname[1:end-4])\nend","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"More examples can be found in examples.","category":"page"},{"location":"man/examples/#Data-visualization-1","page":"Example","title":"Data visualization","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"We provide plot recipes for Plots.jl and wrappers for PyPlot.jl.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"The recipes for Plots.jl will work on all functions given the correct dimensions, e.g.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Plots\nplot(data, \"p\")\ncontourf(data, \"Mx\", xlabel=\"x\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"See the official documentation for Plots.jl for more information.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"On the other hand, most common 1D and 2D plotting functions are wrapped over their Matplotlib equivalences through PyPlot.jl. To trigger the wrapper, using PyPlot. Check out the documentation for more details.","category":"page"},{"location":"man/examples/#Quick-exploration-of-data-1","page":"Example","title":"Quick exploration of data","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"A general plotdata function is provided for quick visualizations using Matplotlib.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"1D binary","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"p\", plotmode=\"line\")\nplotdata(data, \"p\", plotmode=\"linegrid\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"2D Cartesian (structured)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"p bx;by\", plotmode=\"contbar streamover\")\nplotdata(data, \"p bx;by\", plotmode=\"contbar quiverover\")\nplotdata(data, \"p bx;by\", plotmode=\"contbar streamover\", density=2.0)\nplotdata(data, \"p\", plotmode=\"grid\")\nplotdata(data, \"p\", plotmode=\"contbar\", plotrange=[-50., 50., -1., 1.])\nplotdata(data, \"p\", plotmode=\"contbar\")\nplotdata(data, \"p\", plotmode=\"contbarlog\")\nplotdata(data, \"p\", plotmode=\"surfbar\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"2D unstructured","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"rho\", plotmode=\"contbar\")\nplotdata(data, \"rho\", plotmode=\"trimesh\")\nplotdata(data, \"rho\", plotmode=\"tricont\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"2D structured spherical coordinates","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"rho\", plotmode=\"contbar\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"3D box","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plotdata(data, \"bx\", plotmode=\"contbar\", dir=\"y\", sequence=1, level=20)\nplotdata(data, \"bx\", plotmode=\"contbar\", dir=\"y\", plotrange=[-1.4,-1.1,0.70,0.78])\nusing PyPlot\nplt.axis(\"scaled\")\n\nsubplot(2,2,(1,3))\ncutplot(data, \"Ex\"; dir=\"y\", sequence=128, plotrange)","category":"page"},{"location":"man/examples/#Finding-indexes-1","page":"Example","title":"Finding indexes","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"To get the index of a certain quantity, e.g. electron number density","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"ρe_= findfirst(x->x==\"rhoS0\", data.head.wnames)","category":"page"},{"location":"man/examples/#Multiple-dispatch-for-Matplotlib-functions-1","page":"Example","title":"Multiple dispatch for Matplotlib functions","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Using the same plotting functions as in Matplotlib is allowed, and actually recommended. Some plotting functions can be directly called as shown below, which allows for more control from the user. using PyPlot to import the full capability of the package, etc. adding colorbar, changing line colors, setting colorbar range with clim.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"line plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plot(data, \"p\", linewidth=2, color=\"green\")\nc = plot(data, \"p\")\nplt.setp(c, linestyle=\"--\", linewidth=2);","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"scatter plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"scatter(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"contour","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"# 2D contour\ncontour(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"filled contour","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"contourf(data, \"p\")\ncontourf(data, \"p\", levels, plotrange=[-10,10,-Inf,Inf], plotinterval=0.1)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"surface plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plot_surface(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"triangle surface plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"plot_trisurf(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"triangle filled contour plot","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"tricontourf(data, \"p\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"streamline","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"streamplot(data, \"bx;bz\")\nstreamplot(data, \"bx;bz\", density=2.0, color=\"k\", plotinterval=1.0, plotrange=[-10,10,-Inf,Inf])","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"quiver (currently only for Cartesian grid)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"quiver(data, \"ux;uy\", stride=50)","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"streamline + contourf","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Batsrus, PyPlot\n\nfile = \"y*out\"\ndata = load(file)\n\nDN = matplotlib.colors.DivergingNorm\nset_cmap(\"RdBu_r\")\n\ncontourf(data, \"uxS0\", 50, plotrange=[-3,3,-3,3], plotinterval=0.05, norm=DN(0))\ncolorbar()\nstreamplot(data, \"uxS0;uzS0\", density=2.0, color=\"g\", plotrange=[-3,3,-3,3])\nxlabel(\"x\"); ylabel(\"y\"); title(\"Ux [km/s]\")\n\ncontourf(data,\"uxS0\", 50, plotinterval=0.05, norm=DN(0))\ncolorbar()\naxis(\"scaled\")\nxlabel(\"x\"); ylabel(\"y\"); title(\"uxS0\")","category":"page"},{"location":"man/examples/#Tracing-1","page":"Example","title":"Tracing","text":"","category":"section"},{"location":"man/examples/#","page":"Example","title":"Example","text":"The built-in streamplot function in Matplotlib is not satisfactory for accurately tracing. Instead we recommend FieldTracer.jl for tracing fieldlines and streamlines.","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"An example of tracing in a 2D cut and plot the field lines over contour:","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"using Batsrus, PyPlot\n\nfile = \"y=0_var_1_t00000000_n00000000.out\"\ndata = load(file, dir=\"test\")\n\nbx = data.w[:,:,5]\nbz = data.w[:,:,7]\nx = data.x[:,1,1]\nz = data.x[1,:,2]\n\nseeds = select_seeds(x, z; nSeed=100) # randomly select the seeding points\n\nfor i = 1:size(seeds)[2]\n xs = seeds[1,i]\n zs = seeds[2,i]\n # Tracing in both direction. Check the document for more options.\n x1, z1 = trace2d_eul(bx, bz, xs, zs, x, z, ds=0.1, maxstep=1000, gridType=\"ndgrid\")\n plot(x1,z1,\"--\")\nend\naxis(\"equal\")","category":"page"},{"location":"man/examples/#","page":"Example","title":"Example","text":"Currently the select_seeds function uses pseudo random number generator that produces the same seeds every time.","category":"page"},{"location":"#Batsrus.jl-1","page":"Home","title":"Batsrus.jl","text":"","category":"section"},{"location":"#Overview-1","page":"Home","title":"Overview","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"note: Note\nThis package is still under development, so be careful for any future breaking changes!","category":"page"},{"location":"#","page":"Home","title":"Home","text":"BATSRUS and SWMF data reading, converting, visualizing and analyzing in Julia.","category":"page"},{"location":"#","page":"Home","title":"Home","text":"This package provides the following functionalities:","category":"page"},{"location":"#","page":"Home","title":"Home","text":"simulation data reader\nrun log plots\n2D/3D region cut from the whole data\nphase space distribution plots\ninterpolation from unstructured to structured data\ndata format conversion to VTK\nsimulation data visualization","category":"page"},{"location":"#","page":"Home","title":"Home","text":"The ultimate goal is to build a convenient tool of reading and analyzing simulation outputs which is easy to install and easy to use.","category":"page"},{"location":"#","page":"Home","title":"Home","text":"tip: Ready to use?\nFeel free to contact the author for any help or collaboration!","category":"page"},{"location":"#Installation-1","page":"Home","title":"Installation","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"Install VisAna from the julia REPL prompt with","category":"page"},{"location":"#","page":"Home","title":"Home","text":"using Pkg\nPkg.add(\"Batsrus\")","category":"page"},{"location":"#","page":"Home","title":"Home","text":"Or in the Pkg REPL","category":"page"},{"location":"#","page":"Home","title":"Home","text":"julia> ]\npkg> add Batsrus","category":"page"},{"location":"#Benchmark-1","page":"Home","title":"Benchmark","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"Data loading speed of a 2.4GB 3D binary file, 317MB 3D binary file, and 65KB 2D binary file on Macbook Pro with quad core 2.2 GHz Intel i7 and 16 GB 1600 MHz DDR3:","category":"page"},{"location":"#","page":"Home","title":"Home","text":"2.4GB tmax [s] tmean [s]\nJulia 2.73 1.32\nPython 1.35 1.34\nIDL 6.18 6.08\nMATLAB 16.02 10.60","category":"page"},{"location":"#","page":"Home","title":"Home","text":"317MB tmean [ms]\nJulia 180.8\nPython 179.5\nIDL 453.5\nMATLAB 698.4","category":"page"},{"location":"#","page":"Home","title":"Home","text":"65KB tmean [μs]\nJulia 163.36\nPython 4390.95\nIDL 1970.29\nMATLAB 19273.25","category":"page"},{"location":"#","page":"Home","title":"Home","text":"The Julia, IDL, and MATLAB version all shares the same kernel design. The timings are obtained for Julia v1.3.1, Python 3.7.6 + Numpy 1.18.1, IDL 8.5, and MATLAB R2018b. For dynamic languages with JIT, the first time when function gets executed is also the slowest due to runtime compilation, as can be seen from tmax in the tables. spacepy reaches the same level of performance as Batsruls.jl because of the well-optimized numpy library written in C. However, for small data sizes Batsrus.jl is much faster than packages written in other languages.","category":"page"},{"location":"#Calling-From-Python-1","page":"Home","title":"Calling From Python","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"In Python, you can easily take advantage of this package with the aid of PyJulia. After the installation, in the Python REPL:","category":"page"},{"location":"#","page":"Home","title":"Home","text":"from julia import Batsrus\ndir = 'test'\nfile = '1d__raw_2_t25.60000_n00000258.out'\ndata = Batsrus.load(file, dir=dir)","category":"page"},{"location":"#","page":"Home","title":"Home","text":"There you have it! Enjoy!","category":"page"},{"location":"#","page":"Home","title":"Home","text":"warning: Python dependency\nPyPlot package backend may be affected by the settings of PyJulia dependencies. If you want to set it back properly, you need to recompile the PyCall package in Julia.","category":"page"},{"location":"#Developers-1","page":"Home","title":"Developers","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"This package inherits the ideas and code structures from its predecessor in IDL (developed by Gábor Tóth) and MATLAB.","category":"page"},{"location":"#","page":"Home","title":"Home","text":"Batsrus.jl is developed and maintained by Hongyang Zhou.","category":"page"},{"location":"#Acknowledgments-1","page":"Home","title":"Acknowledgments","text":"","category":"section"},{"location":"#","page":"Home","title":"Home","text":"All the nice guys who share their codes!","category":"page"},{"location":"man/internal/#APIs-1","page":"Internal","title":"APIs","text":"","category":"section"},{"location":"man/internal/#Public-1","page":"Internal","title":"Public","text":"","category":"section"},{"location":"man/internal/#Types-1","page":"Internal","title":"Types","text":"","category":"section"},{"location":"man/internal/#","page":"Internal","title":"Internal","text":"Modules = [Batsrus]\nPrivate = false\nOrder = [:type]","category":"page"},{"location":"man/internal/#Batsrus.BATLData","page":"Internal","title":"Batsrus.BATLData","text":"Primary Batsrus data storage type.\n\n\n\n\n\n","category":"type"},{"location":"man/internal/#Functions-1","page":"Internal","title":"Functions","text":"","category":"section"},{"location":"man/internal/#","page":"Internal","title":"Internal","text":"Modules = [Batsrus]\nPrivate = false\nOrder = [:function]","category":"page"},{"location":"man/internal/#Batsrus.convertIDLtoVTK-Tuple{AbstractString}","page":"Internal","title":"Batsrus.convertIDLtoVTK","text":"convertIDLtoVTK(filename; dir=\".\", gridType=1, verbose=false)\n\nConvert 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.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.convertTECtoVTU","page":"Internal","title":"Batsrus.convertTECtoVTU","text":"convertTECtoVTU(head, data, connectivity, filename=\"out\")\n\nConvert unstructured Tecplot data to VTK. Note that if using voxel type data in VTK, the connectivity sequence is different from Tecplot: the 3D connectivity sequence in Tecplot is the same as 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:\n\n# PLT to VTK voxel index_ = [1 2 4 3 5 6 8 7]\nfor i = 1:2\n connectivity = swaprows!(connectivity, 4*i-1, 4*i)\nend\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.cutdata-Tuple{BATLData, AbstractString}","page":"Internal","title":"Batsrus.cutdata","text":"cutdata(data, var; plotrange=[-Inf,Inf,-Inf,Inf], dir=\"x\", sequence=1)\n\nGet 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.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.cutplot","page":"Internal","title":"Batsrus.cutplot","text":"cutplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir=\"x\", sequence=1,\n level=20)\n\n2D plane cut contourf of 3D box data.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.getConnectivity-Tuple{Batl}","page":"Internal","title":"Batsrus.getConnectivity","text":"Get cell connectivity list.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getvar-Tuple{BATLData, AbstractString}","page":"Internal","title":"Batsrus.getvar","text":"Return variable data from string var.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getvars-Union{Tuple{T}, Tuple{BATLData, Vector{T}}} where T<:AbstractString","page":"Internal","title":"Batsrus.getvars","text":"getvars(data::BATLData, Names::Vector) -> Dict\n\nReturn variables' data as a dictionary from string vector. See also: getvar.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.load-Tuple{AbstractString}","page":"Internal","title":"Batsrus.load","text":"load(filenameIn; dir=\".\", npict=1, verbose=false)\n\nRead 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.\n\nExamples\n\ndata = load(\"1d_raw*\")\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.plotdata-Tuple{BATLData, AbstractString}","page":"Internal","title":"Batsrus.plotdata","text":"plotdata(data, func, args, kwargs...)\n\nPlot the variable from SWMF output.\n\nplotdata(data, \"p\", plotmode=\"contbar\")\n\nplotdata(data, \"p\", plotmode=\"grid\")\n\nplotdata(data, func, plotmode=\"trimesh\", plotrange=[-1.0, 1.0, -1.0, 1.0], plotinterval=0.2)\n\nArguments\n\nbd::BATLData: BATSRUS data to be visualized.\nfunc::String: variables for plotting.\n\nKeywords\n\nplotmode::String: type of plotting [\"cont\",\"contbar\"]...\nplotrange::Vector: range of plotting.\nplotinterval: interval for interpolation.\nlevel: level of contour.\ninnermask: Bool for masking a circle at the inner boundary.\ndir: 2D cut plane orientation from 3D outputs [\"x\",\"y\",\"z\"].\nsequence: sequence of plane from - to + in that direction.\nmultifigure: 1 for multifigure display, 0 for subplots.\nverbose: display additional information.\ndensity: density for streamlines.\nstride: quiver strides in number of cells.\n\nRight now this can only deal with 2D plots or 3D cuts. Full 3D plots may be supported in the future.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.plotlogdata-Tuple{Any, NamedTuple, AbstractString}","page":"Internal","title":"Batsrus.plotlogdata","text":"plotlogdata(data, head, func; plotmode=\"line\")\n\nPlot information from log file.\n\nInput arguments\n\ndata::Array: output data.\nhead::NamedTuple: header info.\nfunc::String: variables for plotting.\nplotmode::String: type of plotting [\"line\",\"scatter\"].\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.readhead-Tuple{Any}","page":"Internal","title":"Batsrus.readhead","text":"Return header from info file. Currently only designed for 2D and 3D.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.readlogdata-Tuple{AbstractString}","page":"Internal","title":"Batsrus.readlogdata","text":"Read information from log file.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.readtecdata-Tuple{AbstractString}","page":"Internal","title":"Batsrus.readtecdata","text":"readtecdata(file; verbose=false)\n\nReturn header, data and connectivity from BATSRUS Tecplot outputs. Both 2D and 3D binary and ASCII formats are supported.\n\nExamples\n\nfile = \"3d_ascii.dat\"\nhead, data, connectivity = readtecdata(file)\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.readtree-Tuple{Any}","page":"Internal","title":"Batsrus.readtree","text":"Return BATL tree structure.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.showhead","page":"Internal","title":"Batsrus.showhead","text":"showhead(file, filehead)\n\nDisplaying file header information.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.showhead-Tuple{BATLData}","page":"Internal","title":"Batsrus.showhead","text":"showhead(data)\nshowhead(io, data)\n\nDisplay file information of data.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.streamslice","page":"Internal","title":"Batsrus.streamslice","text":"streamslice(data::BATLData, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir=\"x\",\n sequence=1; kwargs...)\n\nPlot streamlines on 2D slices of 3D box data. Variable names in var string must be separated with ;.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.subsurface-NTuple{4, Any}","page":"Internal","title":"Batsrus.subsurface","text":"subsurface(x, y, data, limits)\nsubsurface(x, y, u, v, limits)\n\nExtract subset of 2D surface dataset in ndgrid format. See also: subvolume.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.subvolume-NTuple{5, Any}","page":"Internal","title":"Batsrus.subvolume","text":"subvolume(x, y, z, data, limits)\nsubvolume(x, y, z, u, v, w, limits)\n\nExtract subset of 3D dataset in ndgrid format. See also: subsurface.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#PyPlot.contour","page":"Internal","title":"PyPlot.contour","text":"contour(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],\n plotinterval=0.1, innermask=false, kwargs...)\n\nWrapper over contour in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.contourf","page":"Internal","title":"PyPlot.contourf","text":"contourf(data, var, levels=0; ax=nothing, plotrange=[-Inf,Inf,-Inf,Inf],\n plotinterval=0.1, innermask=false, kwargs...)\n\nWrapper over contourf in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.plot","page":"Internal","title":"PyPlot.plot","text":"plot(data, var, ax=nothing; kwargs...)\n\nWrapper over plot in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.plot_surface-Tuple{BATLData, AbstractString}","page":"Internal","title":"PyPlot.plot_surface","text":"plot_surface(data, var; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,\n innermask=false, kwargs...)\n\nWrapper over plot_surface in matplotlib.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#PyPlot.plot_trisurf","page":"Internal","title":"PyPlot.plot_trisurf","text":"plot_trisurf(data::BATLData, var::String, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf],\n kwargs...)\n\nWrapper over plot_trisurf in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.quiver","page":"Internal","title":"PyPlot.quiver","text":"quiver(data, var, ax=nothing; stride=10, kwargs...)\n\nWrapper over quiver in matplotlib. Only supports Cartesian grid for now.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.scatter","page":"Internal","title":"PyPlot.scatter","text":"scatter(data, var, ax=nothing; kwargs...)\n\nWrapper over scatter in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.streamplot","page":"Internal","title":"PyPlot.streamplot","text":"streamplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,\n kwargs...)\n\nWrapper over streamplot in matplotlib. streamplot does not have **kwargs in the API, but it supports density, color, and some other keywords.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#PyPlot.tricontourf","page":"Internal","title":"PyPlot.tricontourf","text":"tricontourf(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1,\n kwargs...)\n\nWrapper over tricontourf in matplotlib.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#","page":"Internal","title":"Internal","text":"Modules = [UnitfulBatsrus]\nPrivate = false\nOrder = [:function]","category":"page"},{"location":"man/internal/#Private-1","page":"Internal","title":"Private","text":"","category":"section"},{"location":"man/internal/#","page":"Internal","title":"Internal","text":"Modules = [Batsrus]\nPublic = false","category":"page"},{"location":"man/internal/#Batsrus.FileList","page":"Internal","title":"Batsrus.FileList","text":"Type for the file information.\n\n\n\n\n\n","category":"type"},{"location":"man/internal/#Batsrus.Head","page":"Internal","title":"Batsrus.Head","text":"BATSRUS output standalone header information.\n\n\n\n\n\n","category":"type"},{"location":"man/internal/#Batsrus.allocateBuffer-Tuple{NamedTuple, DataType}","page":"Internal","title":"Batsrus.allocateBuffer","text":"Create buffer for x and w.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.create_pvd-Tuple{String}","page":"Internal","title":"Batsrus.create_pvd","text":"create_pvd(filepattern)\n\nGenerate PVD file for a time series collection of VTK data.\n\nExample\n\ncreate_pvd(\"*.vtu)\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.fillCellNeighbors!-Tuple{Batl, Vararg{Any, 4}}","page":"Internal","title":"Batsrus.fillCellNeighbors!","text":"fillCellNeighbors!(batl, iCell_G, DiLevelNei_III, iNodeNei_III, nBlock_P)\n\nFill neighbor cell indexes for the given block. The faces, edges, and vertices are ordered from left (-) to right (+) in x-y-z sequentially.\n\nVertices: Edges: (10,11 ignored)\n\n7 ––- 8 . –4– .\n\n. - . 7 . 8 .\n\n5 ––- 6 . . –3– . 12 . . . . . . . . . 3 ––- 4 9 . –2– . . - . - . 5 . 6 1 ––- 2 . –1– .\n\nOnly tested for 3D.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.find_grid_block-Tuple{Batl, Any}","page":"Internal","title":"Batsrus.find_grid_block","text":"find_grid_block(batl, xyz_D)\n\nReturn processor local block index that contains a point. Input location should be given in Cartesian coordinates.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.find_neighbor_for_anynode-Tuple{Batl, Int64}","page":"Internal","title":"Batsrus.find_neighbor_for_anynode","text":"Find neighbors for any node in the tree. Only for Cartesian now.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.find_tree_node-Tuple{Batl, Any}","page":"Internal","title":"Batsrus.find_tree_node","text":"find_tree_node(batl, Coord_D)\n\nFind the node that contains a point. The point coordinates should be given in generalized coordinates normalized by the domain size.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.findindex-Tuple{BATLData, AbstractString}","page":"Internal","title":"Batsrus.findindex","text":"Find variable index in data.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getSibling-Tuple{Any, Any}","page":"Internal","title":"Batsrus.getSibling","text":"Return sibling index (1-8) for the given block node matrix.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getascii!-Tuple{Any, Any, IOStream, NamedTuple}","page":"Internal","title":"Batsrus.getascii!","text":"Read ascii format data.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getbinary!-Tuple{Any, Any, IOStream, NamedTuple}","page":"Internal","title":"Batsrus.getbinary!","text":"Read binary format data.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getdata-Tuple{BATLData, AbstractString, Any, Any}","page":"Internal","title":"Batsrus.getdata","text":"Prepare 2D data arrays for passing to plotting functions.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getfilehead-Tuple{IOStream, Batsrus.FileList}","page":"Internal","title":"Batsrus.getfilehead","text":"getfilehead(fileID::IoStream, filelist::FileList) -> NameTuple\n\nObtain the header information from BATSRUS output file of type linked to fileID.\n\nInput arguments\n\nfileID::IOStream: file identifier.\nfilelist::FileList: file information.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getfilesize-Tuple{IOStream, Symbol, Int32}","page":"Internal","title":"Batsrus.getfilesize","text":"Return the size in bytes for one snapshot.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.getfiletype-Tuple{String, String}","page":"Internal","title":"Batsrus.getfiletype","text":"Obtain file type.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.ibits-Tuple{Any, Any, Any}","page":"Internal","title":"Batsrus.ibits","text":"Logical shifts as the Fortran instrinsic function.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.meshgrid-Tuple{Any, Any}","page":"Internal","title":"Batsrus.meshgrid","text":"Generating consistent 2D arrays for passing to plotting functions.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.nodeToGlobalBlock-Tuple{Batl, Int32, Any}","page":"Internal","title":"Batsrus.nodeToGlobalBlock","text":"Return global block index for the node.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.order_children!-Tuple{Batl, Int32, Int64, Vector{Int32}}","page":"Internal","title":"Batsrus.order_children!","text":"order_children!(batl::Batl, iNode, iMorton::Int, iNodeMorton_I::Vector{Int32})\n\nRecursively apply Morton ordering for nodes below a root block. Store result into iNodeMortonI and iMortonNodeA using the iMorton index.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.order_tree-Tuple{Batl}","page":"Internal","title":"Batsrus.order_tree","text":"order_tree(batl)\n\nReturn maximum AMR level in the used block and the Morton curve order. Set iNodeMorton_I indirect index arrays according to\n\nroot node order\nMorton ordering for each root node\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.set_colorbar","page":"Internal","title":"Batsrus.set_colorbar","text":"Set colorbar norm and ticks.\n\n\n\n\n\n","category":"function"},{"location":"man/internal/#Batsrus.setunits-Tuple{Any, Any}","page":"Internal","title":"Batsrus.setunits","text":"setunits(filehead, type; distance=1.0, mp=1.0, me=1.0)\n\nSet 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.\n\nAlso calculate convenient constants ti0, cs0 ... for typical formulas. This function is currently not used anywhere!\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.subdata-NTuple{4, Any}","page":"Internal","title":"Batsrus.subdata","text":"subdata(data, xind, yind, sz)\nsubdata(data, xind, yind, zind, sz)\n\nReturn the sliced data based on indexes xind and yind of size sz.\n\n\n\n\n\n","category":"method"},{"location":"man/internal/#Batsrus.swaprows!-Tuple{Matrix, Int64, Int64}","page":"Internal","title":"Batsrus.swaprows!","text":"Return matrix X with swapped rows i and j.\n\n\n\n\n\n","category":"method"},{"location":"man/log/#Development-Log-1","page":"Log","title":"Development Log","text":"","category":"section"},{"location":"man/log/#","page":"Log","title":"Log","text":"All the workflows here is not restricted to one type of model output. After being familiar with new ideas and new models, one can easily make use of existing samples and create reader of their own. Because of the embarrassing parallelism nature of postprocessing, it is quite easy to take advantage of parallel approaches to process the data.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"For the plotting, streamline tracing and particle tracing, a common problem is the grid and related interpolation process. Now I have FieldTracer.jl and TestParticle.jl designed specifically for these tasks.","category":"page"},{"location":"man/log/#Test-Data-1","page":"Log","title":"Test Data","text":"","category":"section"},{"location":"man/log/#","page":"Log","title":"Log","text":"If you don't have SWMF data at hand, Batsrus.jl provides some test data for you to begin with.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"using LazyArtifacts\n\ndatapath = artifact\"testdata\" # where you can find multiple test data files","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"These are also used in the standard test. These will be automatically downloaded from batsrus_data if you run the package test locally.","category":"page"},{"location":"man/log/#VTK-AMR-Grid-Structure-1","page":"Log","title":"VTK AMR Grid Structure","text":"","category":"section"},{"location":"man/log/#","page":"Log","title":"Log","text":"vtkOverlappingAMR implements a somewhat strict Berger-Collela AMR scheme:","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"All grids are Cartesian.\nGrids at the same level do not overlap.\nThe refinement ratios, RL, between adjacent levels are integer (typically 2 or 4) and uniform within the same level.\nGrid cells are never partially refined; i.e., each cell is refined to four quads in 2D or eight hexahedra in 3D.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Or in other words,","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Refinement ratio across levels is constant.\nEach block at levels > 0 need to be covered 100% by one parent block of","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"previous level.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Some other restriction about what happens at the boundary.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"You can directly use vtkUniformGridAMR, which does not impose any restrictions. Most filters should work for this class - there just wouldn't be any specialized filters such as the dual-grid contour / clip ones for the vtkOverlappingAMR.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"The vtkAMRInformation documentation consists only of","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Refinement ratio between AMR levels\nGrid spacing for each level\nThe file block index for each block parent child information, if requested","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"(Image: sample_2DAMR) Sample 2D AMR Dataset with two levels and refinement ratio, RL=4. The root level (L0) consists of a single grid shown in black wireframe while the next level (L1) consists of two grids, depicted in green wireframe and red wireframe respectively. The two grids at L1 are projected from the root level to illustrate that the cells underneath are “hidden.”","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"In VTK, the collection of AMR grids is stored in a vtkHierarchicalBoxDataSet data-structure. Each grid, G(Li,k), is represented by a vtkUniformGrid data structure where the unique key pair (Li,k) denotes the corresponding level (Li) and the grid index within the level (k) with respect to the underlying hierarchical structure. An array historically known as IBLANK, stored as a cell attribute in vtkUniformGrid, denotes whether a cell is hidden or not. The blanking array is subsequently used by the mapper to hide lower resolution cells accordingly when visualizing the dataset.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"To enable the execution of data queries without loading the entire dataset in memory, metadata information is employed. The metadata stores a minimal set of geometric information for each grid in the AMR hierarchy. Specifically, the AMR metadata, B(Li,k), corresponding to the grid G(Li,k), is represented using a vtkAMRBox object and it consists of the following information:","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"N={Nx, Ny, Nz} — the cell dimensions of the grid (since the data is cell-centered)\nThe grid spacing at level L, hL={hx,hy,hz}\nThe grid level Li and grid index k\nThe global dataset origin, X=(X0, Y0, Z0), i.e., the minimum origin from all grids in level L0\nThe LoCorner and HiCorner, which describe the low and high corners of the rectangular region covered by the corresponding grid in a virtual integer lattice with the same spacing (h) that covers the entire domain.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"(Image: sample_2DAMR)","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"Given the metadata information stored in the AMR box of each grid, the refinement ratio at each level can be easily computed using relationship (1) from Table 1. Further, the cartesian bounds the corresponding grid covers and the number of points and cells is also available (see relationships 2-4 in Table 1). Notably, geometric queries such as determining which cell contains a given point, or if a grid intersects a user-supplied slice plane, can be answered using just the metadata.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"There is a vtkAMRDualExtractionFilter, which constructs a dual-mesh (i.e., the mesh constructed by connecting the cell-centers) over the computational domain. If we can directly tell ParaView that the mesh we have is a dual-mesh, then the initial trial with multi-block data may work directly.","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"AMRGaussianPulseSource","category":"page"},{"location":"man/log/#","page":"Log","title":"Log","text":"See Multi-Resolution Rendering with Overlapping AMR for the implementation of C++ reader in VTK.","category":"page"}] }