Skip to main content

A Python wrapper for Apex coordinates

Project description

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 CodeClimate Quality Status
Scrutinizer Status Codacy Badge

package

PyPI Package latest release Supported versions
PyPI Wheel Supported implementations

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

apexpy-2.0.2.tar.gz (331.4 kB view details)

Uploaded Source

Built Distribution

apexpy-2.0.2-cp310-cp310-macosx_14_0_arm64.whl (276.2 kB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

File details

Details for the file apexpy-2.0.2.tar.gz.

File metadata

  • Download URL: apexpy-2.0.2.tar.gz
  • Upload date:
  • Size: 331.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for apexpy-2.0.2.tar.gz
Algorithm Hash digest
SHA256 d1e7d8c3302122cac5565bf3f43575d76cdcf1e648bb4495794cc6d8bc98a4ab
MD5 43f60a34a39237784d18eb693cff9b08
BLAKE2b-256 fbb40200daa7a3e343728c1815ec9ed53d35c11416fda86c189c2c878655af18

See more details on using hashes here.

File details

Details for the file apexpy-2.0.2-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for apexpy-2.0.2-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6e513962e8437010ca5096183113454acf56c564263e9ddf2d9fec01abe83937
MD5 b640fa2cddb84cff4605c763b4b3ed4d
BLAKE2b-256 8701809c1fce3ab45bb46078a8b691bbae270ab201fce5df1605f0dfdb389cce

See more details on using hashes here.

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