aburrell / aacgmv2

Python library for AACGM-v2 magnetic coordinates
MIT License
28 stars 16 forks source link

convert from geomagnetic to geographic doesn't work with latitude in [-11, 11] #6

Closed thaitrinh closed 6 years ago

thaitrinh commented 7 years ago

OS: MacOS Sierra 10.12.5 AACGMV2 1.0.13 convert(lat=-10.,lon=60., alt=250, date=date(2010, 6, 15), a2g=True) Error: RuntimeError: AACGM_v2_Convert returned error code -1

cmeeren commented 7 years ago

AACGM is known to have problems in certain regions, specifically near the equator. Try https://github.com/cmeeren/apexpy instead.

thaitrinh commented 7 years ago

@cmeeren: Thank you very much!

thaitrinh commented 7 years ago

I think I understood what the problem is. For the low magnetic latitudes (near equator) both AACGM and Apexpy have problem when the altitude is so high. For example, for lat=-11, the maximum altitude can only be 241 km, for lat=-5, the maximum altitude can be only 48.8 km. Do you know why? Thank you!

cmeeren commented 7 years ago

If I remember correctly, apexpy doesn't have these limitations since it uses the APEX model which AFAIK is defined everywhere. I don't remember the details of why; @klaundal might be able to explain more.

klaundal commented 7 years ago

You are trying to convert magnetic to geographic coordinates. In aacgm and modified apex, the magnetic coordinates (mlon, mlat) essentially label the IGRF field lines (they are constant along these lines, except for a sign change between hemispheres). The height tells you where on the field line your point is. Since the field lines do not extend infinitely far out in space, there will be a limit to this height. That limit is lower at lower latitudes, since the field lines don't extend very far. When you exceed the height limit you get an error.