Skip to content

feltor-dev/xFELTOR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tests Sourcery

xFELTOR

xFELTOR provides an interface for collecting the output data from a FELTOR simulation into an xarray dataset.

xFELTOR is inspired by xBOUT and uses currently some of its plotting functionality.

Why xarray?

xarray is a powerful open-source python library which aims to provide Pandas-like labelling, visualization & analysis functionality for N-dimensional data. Some of the basic features are:

  • Labelled multidimensional data: xarray wraps numpy arrays with their dims as DataArrays.
  • Clear syntax for operations: xarray provides clearer and more general syntax containing less magic numbers than numpy
  • Lazy loading into memory: never wastes RAM on unneeded values
  • Plotting convenience: xarray provides plotting functions (wrapping matplotlib) which automatically use an appropriate type of plot for the dimension of the data (1D, 2D etc.)

For more information see the xarray getting started guide. Tom Nicholas' presentation about xarray and xBOUT is also a good place to start.

Installation

Dev install:

git clone https://github.com/uit-cosmo/xFELTOR.git
cd xFELTOR
pip install -e .

Loading your data

The function open_feltordataset() uses xarray & dask to collect FELTOR data into one xarray dataset. This can be either a single output file or multiple coherent files for restarted simulations.

The data can be loaded with

ds = open_feltordataset("./run_dir*/*.nc")

xFELTOR stores all variables from the FELTOR input file as attributes (xarray.Dataset.attrs).

Plotting Methods

In addition to the extensive functionalities provided by xarray, xFELTOR offers some useful plotting methods.

In order to plot the evolution of a 2D variable over time:

ds["electrons"].feltor.animate2D(x="x", y="y")

Density evolution

For plotting a 1D variable over time:

ds["electrons"].isel(y=100).feltor.animate1D(animate_over="time")

Density evolution

You can also plot multiple 1d and 2d variables over time:

ds.feltor.animate_list(
    variables=[
        ds["electrons"],
        ds["ions"].isel(y=100),
        ds["potential"],
        ds["vorticity"],
    ]
)

About

Collects FELTOR simulation data into xarray.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages