Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.
/ apexpy Public archive

Platform/OS-independent interface to Fortran Apex (windows, Mac, Linux). This work restored Windows functionality to ApexPy.

License

Notifications You must be signed in to change notification settings

space-physics/apexpy

Repository files navigation

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]). MLT calculations are also included. The package is free software (MIT license).

Quick start

Install:

pip install apexpy

To install development version, clone this repo and install:

git clone https://github.com/aburrell/apexpy

cd apexpy

pip install -e .

Usage

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

>>> from apexpy import Apex
>>> from __future__ import print_function
>>> A = Apex(date=2015.3)  # datetime objects are also supported
>>> # geo to apex, scalar input
>>> mlat, mlon = A.convert(60, 15, 'geo', 'apex', height=300)
>>> print("{:.12f}, {:.12f}".format(mlat, mlon))
57.469573974609, 93.633583068848
>>> # apex to geo, array input
>>> glat, glon = A.convert([90, -90], 0, 'apex', 'geo', height=0)
>>> print(["{:.12f}, {:.12f}".format(ll, glon[i]) for i,ll in enumerate(glat)])
['83.099594116211, -84.594589233398', '-74.388267517090, 125.714927673340']
>>> # geo to MLT
>>> import datetime as dt
>>> mlat, mlt = A.convert(60, 15, 'geo', 'mlt', datetime=dt.datetime(2015, 2, 10, 18, 0, 0))
>>> print("{:.12f}, {:.12f}".format(mlat, mlt))
56.590423583984, 19.108103879293
>>> # can also convert magnetic longitude to mlt
>>> mlt = A.mlon2mlt(120, dt.datetime(2015, 2, 10, 18, 0, 0))
>>> print("{:.2f}".format(mlt))
20.89

If you don't know or use Python, you can also use the command line. See details in the full documentation.

Documentation

https://apexpy.readthedocs.org/

Troubleshooting

The install procedure assumes that the same version of libgfortran is installed in the same location as when the pip wheel was built. If not, you may have trouble importing apexpy and you will have to build apexpy yourself using:

pip install --global-option='build_ext' apexpy

which requires a Fortran compiler such as Gfortran to be installed on your system. Gfortran can be obtained by:

  • Linux: apt install gfortran
  • MacOS: brew install gfortran
  • Windows: use MinGW to get Gfortran.

References

[1]Emmert, J. T., A. D. Richmond, and D. P. Drob (2010), A computationally compact representation of Magnetic-Apex and Quasi-Dipole coordinates with smooth base vectors, J. Geophys. Res., 115(A8), A08322, doi:10.1029/2010JA015326.
[2]Richmond, A. D. (1995), Ionospheric Electrodynamics Using Magnetic Apex Coordinates, Journal of geomagnetism and geoelectricity, 47(2), 191–212, doi:10.5636/jgg.47.191.

Badges

docs Documentation Status
tests
package
PyPI Package latest release Supported versions
PyPI Wheel Supported implementations

About

Platform/OS-independent interface to Fortran Apex (windows, Mac, Linux). This work restored Windows functionality to ApexPy.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages