Skip to main content

ApexPy logo: yellow magnetic field lines surrounding the Earth's surface, which is blue

Overview

Documentation Status PyPI Package latest release doi

This is a Python wrapper for the Apex fortran library by Emmert et al. [2010] [1], which allows converting between geodetic, modified apex, and quasi-dipole coordinates as well as getting modified apex and quasi-dipole base vectors (Richmond [1995] [2]). The geodetic system used here is WGS84. MLT calculations are also included. The package is free software (MIT license).

Quick start

Install from PyPI using pip:

pip install apexpy

This assumes that the same version of libgfortran is installed in the same location as when the pip wheel was built (if a wheel was used). If not, you may have trouble importing apexpy. If you run into trouble, try the command:

pip install --no-binary :apexpy: apexpy

which requires both libgfortran and gfortran to be installed on your system. More detailed installation instructions (and troubleshooting) is available in the documentation.

Conversion is done by creating an Apex object and using its methods to perform the desired calculations. Some simple examples:

from apexpy import Apex
import datetime as dt
atime = dt.datetime(2015, 2, 10, 18, 0, 0)
apex15 = Apex(date=2015.3)  # dt.date and dt.datetime objects also work

# Geodetic to apex, scalar input
mlat, mlon = apex15.convert(60, 15, 'geo', 'apex', height=300)
print("{:.12f}, {:.12f}".format(mlat, mlon))
57.477310180664, 93.590156555176

# Apex to geodetic, array input
glat, glon = apex15.convert([90, -90], 0, 'apex', 'geo', height=0)
print(["{:.12f}, {:.12f}".format(ll, glon[i]) for i,ll in enumerate(glat)])
['83.103820800781, -84.526657104492', '-74.388252258301, 125.736274719238']

# Geodetic to magnetic local time
mlat, mlt = apex15.convert(60, 15, 'geo', 'mlt', datetime=atime)
print("{:.12f}, {:.12f}".format(mlat, mlt))
56.598316192627, 19.107861709595

# can also convert magnetic longitude to mlt
mlt = apex15.mlon2mlt(120, atime)
print("{:.2f}".format(mlt))
20.90

If you don’t know or use Python, you can also use the command line. See details in the full documentation (link in the section below).

Documentation

https://apexpy.readthedocs.io/en/latest

References

Badges

docs

Documentation Status

tests

GitHub Actions Build Status
Coverage Status
Scrutinizer Status Codacy Badge

package

PyPI Package latest release Supported versions
PyPI Wheel Supported implementations

Release files for apexpy 2.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apexpy 2.1.1
File Size Uploaded
apexpy-2.1.1.tar.gz 340.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for apexpy 2.1.1
File Interpreter ABI Platform
apexpy-2.1.1-cp310-cp310-macosx_26_0_x86_64.whl CPython 3.10 CPython 3.10 macOS 26.0+ x86-64 Details

Total release size: 627.2 kB

Release files / apexpy-2.1.1.tar.gz

Download URL apexpy-2.1.1.tar.gz
Size 340.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f1f0a555664f75734a02bb48217676b5534e40eb0e8d64e04bf24274be7f7825
BLAKE2b-256 checksum
How to use checksums
d187052779ac4c12588d286331e6029af9b43be3d3f18a65cbd3d07933775144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / apexpy-2.1.1-cp310-cp310-macosx_26_0_x86_64.whl

Download URL apexpy-2.1.1-cp310-cp310-macosx_26_0_x86_64.whl
Size 286.6 kB
Tags CPython 3.10 macOS 26.0+ x86-64
SHA-256 checksum
How to use checksums
fb7a978ed6dfd8abbb041c42732930d5c11847648b1318f51e7a1fe873447f3e
BLAKE2b-256 checksum
How to use checksums
04d0fe2e230644ff09aa8a43d8001f45f38c444b6229833084f8c1246cff5a0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

2.1.1 This release

2 release files

2.1.0

1 release file

2.0.2

2 release files

2.0.1

1 release file

2.0.0

1 release file

1.1.0

1 release file

1.0.3

5 release files

1.0.2

5 release files

1.0.1

7 release files

1.0.0

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page