# Batsrus.jl

## Overview

Note

This package is still under development, so be careful for any future breaking changes!

BATSRUS and SWMF data reading, converting, visualizing and analyzing in Julia.

This package provides the following functionalities:

• run log plots
• 2D/3D region cut from the whole data
• phase space distribution plots
• interpolation from unstructured to structured data
• data format conversion to VTK
• simulation data visualization

The ultimate goal is to build a convenient tool of reading and analyzing simulation outputs which is easy to install and easy to use.

Feel free to contact the author for any help or collaboration!

## Installation

Install VisAna from the julia REPL prompt with

using Pkg
Pkg.add("Batsrus")

Or in the Pkg REPL

>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'
filename = '1d__raw_2_t25.60000_n00000258.out'
data = Batsrus.readdata(filename, 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.