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 was also an early release test and should not be used.

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 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 .

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.1.tar.gz (789.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.1-cp312-abi3-win_amd64.whl (301.2 kB view details)

Uploaded CPython 3.12+Windows x86-64

iupitermag-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (482.8 kB view details)

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

iupitermag-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (452.4 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

iupitermag-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl (433.2 kB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: iupitermag-0.1.1.tar.gz
  • Upload date:
  • Size: 789.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.1.tar.gz
Algorithm Hash digest
SHA256 04496dadfb165078e2265f7ffa9eea7998897530ab6ecf3915967dfb85036d09
MD5 7e1a1f9ffd9a604654137142f8c7a40c
BLAKE2b-256 bbcf67137e25e3caf3592780cf52c1a01ba706b12d6cbe3f6d117be0c5d454e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iupitermag-0.1.1-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 301.2 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.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9f3a7daf1628041870c3bff3151dfe4a9814adb3261254b3aea0da1f4ef4601f
MD5 2731e365d02746fd6c2133e412e686af
BLAKE2b-256 a3d96f1875309966c741960f2ee183c84b0bc50f9d5023db4b9f44ee5db5382a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iupitermag-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 482.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.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c514861568d583f35b486a534cb78015146ce1c422d53340d911cd5458cc6e5
MD5 e9ac342fdc2db58d86f483983b0305e4
BLAKE2b-256 bea9227349e3e111c19479a63019c2ea7eb88a8aa937424986742059dff80dbf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iupitermag-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 452.4 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.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e731979705e7b6dc2da3526bc179a12932a87e70653112f8e5fe8faffeb3fdc9
MD5 578a90764a0d29227fe032fa15bdc43e
BLAKE2b-256 2c0ae49513b86ffb4f6f7f029116e846f07e3f8bc8a021f9cebf15faf2b28daa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iupitermag-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 433.2 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.1-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8b5422e6783e224c587f493426082f51d1cad5ccfe68b9f485c9ef89ee06a9d5
MD5 55e3b8f5d9b7c8584e2dd284c7835a72
BLAKE2b-256 b1312d57eb68b3dac678bce5b358fcf577bffec0c8d456ed2c8f7df6a248a739

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