Skip to main content

Provides a backend for xarray to read SDF files as created by the EPOCH plasma PIC code.

Project description

sdf-xarray

PyPI Build/Publish Tests

sdf-xarray provides a backend for xarray to read SDF files as created by the EPOCH plasma PIC code using the SDF-C library.

Installation

Install from PyPI with:

pip install sdf-xarray

[!NOTE] For use within jupyter notebooks, run this additional command after installation:

pip install "sdf-xarray[jupyter]"

or from a local checkout:

git clone https://github.com/PlasmaFAIR/sdf-xarray.git
cd sdf-xarray
pip install .

We recommend switching to uv to manage packages.

Usage

sdf-xarray is a backend for xarray, and so is usable directly from xarray:

Single file loading

import xarray as xr

df = xr.open_dataset("0010.sdf")

print(df["Electric_Field_Ex"])

# <xarray.DataArray 'Electric_Field_Ex' (X_x_px_deltaf_electron_beam: 16)> Size: 128B
# [16 values with dtype=float64]
# Coordinates:
#   * X_x_px_deltaf_electron_beam  (X_x_px_deltaf_electron_beam) float64 128B 1...
# Attributes:
#     units:    V/m
#     full_name: "Electric Field/Ex"

Multi file loading

To open a whole simulation at once, pass preprocess=sdf_xarray.SDFPreprocess() to xarray.open_mfdataset:

import xarray as xr
from sdf_xarray import SDFPreprocess

with xr.open_mfdataset("*.sdf", preprocess=SDFPreprocess()) as ds:
    print(ds)

# Dimensions:
# time: 301, X_Grid_mid: 128, ...
# Coordinates: (9) ...
# Data variables: (18) ...
# Indexes: (9) ...
# Attributes: (22) ...

SDFPreprocess checks that all the files are from the same simulation, as ensures there's a time dimension so the files are correctly concatenated.

If your simulation has multiple output blocks so that not all variables are output at every time step, then those variables will have NaN values at the corresponding time points.

Alternatively, we can create a separate time dimensions for each output block (essentially) using sdf_xarray.open_mfdataset with separate_times=True:

from sdf_xarray import open_mfdataset

with open_mfdataset("*.sdf", separate_times=True) as ds:
    print(ds)

# Dimensions:
# time0: 301, time1: 31, time2: 61, X_Grid_mid: 128, ...
# Coordinates: (12) ...
# Data variables: (18) ...
# Indexes: (9) ...
# Attributes: (22) ...

This is better for memory consumption, at the cost of perhaps slightly less friendly comparisons between variables on different time coordinates.

Reading particle data

By default, particle data isn't kept as it takes up a lot of space. Pass keep_particles=True as a keyword argument to open_dataset (for single files) or open_mfdataset (for multiple files):

df = xr.open_dataset("0010.sdf", keep_particles=True)

Loading SDF files directly

For debugging, sometimes it's useful to see the raw SDF files:

from sdf_xarray import SDFFile

with SDFFile("0010.sdf") as sdf_file:
    print(sdf_file.variables["Electric Field/Ex"])

    # Variable(_id='ex', name='Electric Field/Ex', dtype=dtype('float64'), ...

    print(sdf_file.variables["Electric Field/Ex"].data)

    # [ 0.00000000e+00  0.00000000e+00  0.00000000e+00 ... -4.44992788e+12  1.91704994e+13  0.00000000e+00]

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

sdf_xarray-0.1.3.tar.gz (1.3 MB view details)

Uploaded Source

Built Distributions

sdf_xarray-0.1.3-cp313-cp313-win_amd64.whl (314.0 kB view details)

Uploaded CPython 3.13 Windows x86-64

sdf_xarray-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (591.3 kB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

sdf_xarray-0.1.3-cp313-cp313-macosx_11_0_arm64.whl (414.9 kB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

sdf_xarray-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl (466.1 kB view details)

Uploaded CPython 3.13 macOS 10.13+ x86-64

sdf_xarray-0.1.3-cp312-cp312-win_amd64.whl (314.8 kB view details)

Uploaded CPython 3.12 Windows x86-64

sdf_xarray-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (590.2 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

sdf_xarray-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (416.7 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

sdf_xarray-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl (467.6 kB view details)

Uploaded CPython 3.12 macOS 10.13+ x86-64

sdf_xarray-0.1.3-cp311-cp311-win_amd64.whl (314.7 kB view details)

Uploaded CPython 3.11 Windows x86-64

sdf_xarray-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (592.1 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

sdf_xarray-0.1.3-cp311-cp311-macosx_11_0_arm64.whl (416.7 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

sdf_xarray-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl (452.1 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

sdf_xarray-0.1.3-cp310-cp310-win_amd64.whl (314.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

sdf_xarray-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (593.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

sdf_xarray-0.1.3-cp310-cp310-macosx_11_0_arm64.whl (416.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

sdf_xarray-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl (451.9 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

File details

Details for the file sdf_xarray-0.1.3.tar.gz.

File metadata

  • Download URL: sdf_xarray-0.1.3.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for sdf_xarray-0.1.3.tar.gz
Algorithm Hash digest
SHA256 61b1fc4a4c7fbd6d88a49dc5a9bdf9501dc37fc6fbbb3a20b1e5ff89ca9cb059
MD5 00a4ce1746123e9eaeb4c1049eb68a86
BLAKE2b-256 4bfbe68cc3f5a3bf0a4a9e46cc2e4c8ba944c2806e7609b4cf002508d52905aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3.tar.gz:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 548cdd008699c7129ee633dd67d5d6b167c5a9856ea4985a7b36446305a6250b
MD5 3161dad7a7ed1be6f36ccb6d76617e3f
BLAKE2b-256 aa0cfd58ea04418f783ae7b39794c5fef9d6abde95a67774819ba51dac3cd725

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp313-cp313-win_amd64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac3b66e867ef1ee7ff1f6687bea0e0c23916ef3454b40491d8bbbb6379cc3e88
MD5 60e02f04c83e885fa559800dd6c8c268
BLAKE2b-256 180f80e6563a65085a412afb34c32efe8cc2dc18b1103748e0818d6e410873b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 782db682ad69e0b8b4404bd31b8a446d03af3d762aaa564a2e795eabd1b82397
MD5 625d3a963d4674db9f1cdb8a4661b181
BLAKE2b-256 76ce2539c8e4a6244f5b5c46d4397d74a9cda8c3d3bd1c788b6b266c00c5ff6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bc88374b3f08d28371a2c7e404553e1ab0304fa091c853ef72118e5008ec2559
MD5 dd89c57a9b7d8bb453d87e5f30f24e9e
BLAKE2b-256 5c9e985d384f7ece7fa4d3a22765dd8b7eefef405eaf45fcfe43df725d47779b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d176e750cc6b5e409b1a5cc9898b0fbcc25f449ac8404110faa150df1b170ec0
MD5 06feefec9444afa67f8dabcdf013f6dd
BLAKE2b-256 8f7a018a09e526e2df98e0873f54b5e1fc8a04e2aaf0ff2430e5253ec309db65

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp312-cp312-win_amd64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea447d566eba2c64d867ea74e272c9c757308e57732970fa9c12a7f521b31d69
MD5 1d8966f9636441df0b5f488ba22cfcf8
BLAKE2b-256 3a29933ae3c48018999c47cc6f487ff773965b634924a1ccf3d01693cbcb2ba3

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5578bd92d63c45b7ac74ed4eefa03ec730b0e70b0d6056abdaad14d176f9e61a
MD5 6ac066af5ab48849cf596dba5342b205
BLAKE2b-256 0fe4475c630ec774d8a0290cee6c87f31166a91cd1d1686b929cd299fae70d70

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4fe60e427617b99ad210bb6f70303c43a1eacc656e2c4ae785d471c3f8d6da08
MD5 5e0224886b1288b7a9850f96a45b6db7
BLAKE2b-256 ddb38b93cbb30b0169e54f61c11278a321b2fb3135c9e69b247fb30f71543ef0

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b33db1d369bf8ca5ea8f6c6e3d3f1e7c0bb1ef692125f66d56c0caf24467cd41
MD5 9ae1e8a93c15f864c172a4e3c5b1e8a0
BLAKE2b-256 15c42956b370fbc542b86c9e1ba9b0953232735088f9e73a32ebf2754f9f9a65

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp311-cp311-win_amd64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6fa65999e1f02de3745394a5b11185d3fc3b11a1be3d256067ef257f38e192fd
MD5 858765127d82ea66892e660ba80173e9
BLAKE2b-256 1b4472c3e838ce5cc4163e79694965be657dcf7d1e83ddd8f12121dc8ae7fd07

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f014eaf9434b5ef229c329d53b0d016154a2369021afa330adea452a4e22c5c
MD5 b8588e83acb026905d65ec71b96f2466
BLAKE2b-256 9cb86b6fdc4863299f7f877d97633a0995c21759f88fadaefe27cb4a8d0a8a92

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f06921790f8ae55c2d3df8e71b0472daf5a93819f5bfdb43cf660efb99369fd1
MD5 a9dfea6497c900e0eab8dd4df8f15616
BLAKE2b-256 0bc918a6ebd89a1f096052cabe9845e3bf12f6b49f96bac30de20fa938910fcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a23293c141d67cfee008c436ec959c1cd9d4bb4b92ed2a9c0cda5e7a3264ba89
MD5 c5d905a8158d11c67d24c7b463e8320f
BLAKE2b-256 0250b9dd222e1d1d33e8b778a9e9f53a5e294bb733868caf3910801c1f32dd96

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp310-cp310-win_amd64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed3f6152ec014f3f53ac2baca9a6a56f268e8c1a1be7ac8b1d527c2cbb3ee05d
MD5 238925cdc2fb97b25fe8d8554043dc91
BLAKE2b-256 7825bd3dee547bfcf027f73c17ddc3797170af6ce4f069a1dcd9bde96acf4bdb

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b380514f87c05e62a1d514316493d11cdecab95dd41b8f66bc93a26ace3e45b
MD5 a980f065ecf980d4e837d82fcb452437
BLAKE2b-256 59cdef1d5f031ea28bb8f5a9fee25f5d1a56b411e727adc34952988acb81dba3

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

File details

Details for the file sdf_xarray-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sdf_xarray-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f3a12a5d10786a70334e6cac6cbe9e47d1e27de41e94354531fcfe8eb6deabf6
MD5 609994b6e10dfafbecf1f5ffa67b7fa2
BLAKE2b-256 298565589ef460ca7d2933cdd34f8269b4403581af5fe246972ce503e3a398c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_xarray-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: build_publish.yml on PlasmaFAIR/sdf-xarray

Attestations:

Supported by

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