Skip to main content

Python package with Rust bindings to calculate the magnetic field in Jupiter's magnetosphere.

Reason this release was yanked:

This release had bugs in the CON2020 code that were fixed in 0.1.3

Project description

iupitermag

Introduction

iupitermag is a Python package written in Rust to model Jupiter's magnetic field.

Jupiter's Surface Field Strength

Jupiter's internal magnetic field intensity at the 1-bar "surface".

Many other public codes do this or something similar,

More details on Jupiter magnetic field models and these codes can be found in this paper - Wilson, R.J., Vogt, M.F., Provan, G. et al. Internal and External Jovian Magnetic Fields: Community Code to Serve the Magnetospheres of the Outer Planets Community. Space Sci Rev 219, 15 (2023). https://doi.org/10.1007/s11214-023-00961-3

Installation

Installing using wheels on PyPI

If you are on Python versions 3.12 or 3.13, you can install directly using the wheels hosted on PyPI.

$ pip install iupitermag

or

$ uv add iupitermag

Installing from source using uv

If you are using uv as your Python package manager, you can run the following commands after cloning and changing into this directory.

$ uv pip install .

Installing from source using maturin

$ maturin develop --release

Usage

Calculating the internal and current sheet fields at a single point.

All positions should be in the IAU_JUPITER coordinate system.

import iupitermag as im

internal_field = im.InternalField("JRM33")
cs_field = im.CurrentSheetField("CON2020")

r = 10.
theta = 0.
phi = 0.
b_int_rtp = internal_field.calc_field(r, theta, phi)
b_ext_rtp = cs_field.calc_field(r, theta, phi)

# Or, you can the cartesian form.  This calls the spherical version internally.
x = 10.
y = 5.
z = 1.
b_int_xyz = internal_field.calc_field_xyz(x, y, z)
b_ext_xyz = cs_field.calc_field_xyz(x, y, z)

Calculating the internal and current sheet fields for a collection of points.

If you have a collection of points stored as a single numpy array of shape (N, 3), you can use map_calc_field or parmap_calc_field (or their corresponding cartesian versions map_calc_field_xyz and parmap_calc_field_xyz).

points = np.zeros((10000, 3))
points[:, 0] = np.random.random_sample((10000,)) * 10 + 5

b_int = internal_field.map_calc_field(points)
b_ext = cs_field.map_calc_field(points)

b_int = internal_field.parmap_calc_field(points)
b_ext = cs_field.parmap_calc_field(points)

points_xyz = points * 1.

b_int_xyz = internal_field.map_calc_field_xyz(points_xyz)
b_ext_xyz = cs_field.map_calc_field_xyz(point_xyz)

b_int_xyz = internal_field.parmap_calc_field_xyz(points_xyz)
b_ext_xyz = cs_field.parmap_calc_field_xyz(points_xyz)

Based on some benchmarks, you should find parmap_calc_field nearly an order of magnitude faster than map_calc_field or a Python loop over all points calling calc_field repeatedly. parmap_* uses Rayon for parallelizing the calculation. Here are the results of benchmarking different methods to calculate the JRM33 field for different number of points.

Benchmark

As you can see, parmap_ is usually the better option if you have more than 20 or so points. Note that the Python loop version still calls the Rust code internally to calculate the JRM33 field, so even that is faster than a pure-Python implementation (not shown above).

Tracing magnetic field lines

iupitermag can trace magnetic field lines to Jupiter using trace_field_to_planet, which takes as input a collection of starting points (which each result in a separate trace). The coordinates for these starting points should be cartesian.

internal_field = im.InternalField("JRM33")
cs_field = im.CurrentSheetField("CON2020")

starting_positions_xyz = np.array([
    [-10., 0., 0.],
    [-15., 0., 0.],
    [-20., 0., 0.],
    [-25., 0., 0.],
    [10., 0., 0.],
    [15., 0., 0.],
    [20., 0., 0.],
    [25., 0., 0.],
])

trace = im.trace_field_to_planet(starting_positions_xyz, internal_field, cs_field)

Traced field lines

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

iupitermag-0.1.2.tar.gz (788.3 kB view details)

Uploaded Source

Built Distributions

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

iupitermag-0.1.2-cp312-abi3-win_amd64.whl (299.5 kB view details)

Uploaded CPython 3.12+Windows x86-64

iupitermag-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (481.8 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

iupitermag-0.1.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (451.0 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

iupitermag-0.1.2-cp312-abi3-macosx_10_12_x86_64.whl (431.9 kB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file iupitermag-0.1.2.tar.gz.

File metadata

  • Download URL: iupitermag-0.1.2.tar.gz
  • Upload date:
  • Size: 788.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for iupitermag-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d762540cc0795d5f06a77436f974ef6cafebfbc178c85bc47b3ed56f94caff1c
MD5 c5d47a6dd412e6b2482c19d628eb71f3
BLAKE2b-256 3db01e328b86933eacff1d107bfae6d9f89c029911099b8c64ec833a79b19800

See more details on using hashes here.

File details

Details for the file iupitermag-0.1.2-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: iupitermag-0.1.2-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 299.5 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for iupitermag-0.1.2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dbe55740b8a5edfda57a47ee44c4cca17edac2fd2aaf7d86e67a79dce99e1955
MD5 1c6850762b3cea3fb0281907c559d056
BLAKE2b-256 a4b4bf883c4f7a71248a693f61455e9dc76ee03ff8abd34a0d8fc65bf3e25886

See more details on using hashes here.

File details

Details for the file iupitermag-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: iupitermag-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 481.8 kB
  • Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for iupitermag-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e10e53391fbd615f54bcb2884e398436ab1dd2b35167954da49d5b0de83aa880
MD5 369f62e4226dbd18da9d920c86a688ed
BLAKE2b-256 821ba5f3b2557d59f58679c4689bc8e5ab031ca8c75beded16201b9cf2f78397

See more details on using hashes here.

File details

Details for the file iupitermag-0.1.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: iupitermag-0.1.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 451.0 kB
  • Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for iupitermag-0.1.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 54e2aae3c305480a7da542f71ea0aee724597a6e3c08d88c343f978c8a55af01
MD5 175efa521010f65530c5d383bcfa2e07
BLAKE2b-256 d5e140e7aff8aa69e1a92ab34f93aca42c0aac3c82a7ac970cf05c6927fcd933

See more details on using hashes here.

File details

Details for the file iupitermag-0.1.2-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: iupitermag-0.1.2-cp312-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 431.9 kB
  • Tags: CPython 3.12+, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for iupitermag-0.1.2-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 15106107ae85eb090e4d8e0bd9439aefac88b2269d1eef649f0d50809db6024e
MD5 b6c1da60905843045d912b68363cbc21
BLAKE2b-256 091525fc8320a329e53bec31ccee475435c895abc8ae0dac008edf45d6e5786a

See more details on using hashes here.

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