Skip to main content

Collect FELTOR simulation data into xarray

Project description

Tests Sourcery

xFELTOR

xFELTOR provides an interface for collecting the output data from a FELTOR simulation into an xarray dataset and extends xarray DataSet and DataArray classes with FELTOR specific plotting routines based on the animatplot.

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"],
    ]
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xfeltor-0.1.1.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xfeltor-0.1.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file xfeltor-0.1.1.tar.gz.

File metadata

  • Download URL: xfeltor-0.1.1.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for xfeltor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6577025de85327557ef4a2d5a7e5a2f9aed127f00ca7c95f2cb03fbf98ed27e1
MD5 15f5cc180659969139970e6bf820870a
BLAKE2b-256 1fef4ebd597b821d81b59a75b84a62658e625e2dcc65107981be2a9ea0cf4b94

See more details on using hashes here.

Provenance

The following attestation bundles were made for xfeltor-0.1.1.tar.gz:

Publisher: python_publish.yml on feltor-dev/xFELTOR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xfeltor-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: xfeltor-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for xfeltor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4f2b0d3316143f4db1150820cd2e984e7c34acdcf706e9bcd01eb7b26616625
MD5 0a88564299afc9be7260ecc764389245
BLAKE2b-256 53e4db54bef1cbbb191c8451d08b86e25ee9ba5f370edad9da2aa16039fe121d

See more details on using hashes here.

Provenance

The following attestation bundles were made for xfeltor-0.1.1-py3-none-any.whl:

Publisher: python_publish.yml on feltor-dev/xFELTOR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page