<div align="center">
<img height="0" width="0px">
<img width="20%" src="docs/images/logo_high_res.png" alt="OMMBV" title="OMMBV"</img>
</div>
# Orthogonal Multipole Magnetic Basis Vectors (OMMBV)
[![Build Status](https://github.com/rstoneback/OMMBV/actions/workflows/main.yml/badge.svg)](https://github.com/rstoneback/OMMBV/actions/workflows/main.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/rstoneback/OMMBV/badge.svg?branch=main)](https://coveralls.io/github/rstoneback/OMMBV?branch=main)
[![Documentation Status](https://readthedocs.org/projects/ommbv/badge/?version=latest)](https://ommbv.readthedocs.io/en/latest/?badge=latest)
[![DOI](https://zenodo.org/badge/138220240.svg)](https://zenodo.org/badge/latestdoi/138220240)
The motion of plasma in the ionosphere is the result of forcing from neutral
winds, electric fields, as well as the orientation of those fields and forces
relative to the background magnetic field. OMMBV (Orthogonal Multipole
Magnetic Basis Vectors) calculates directions (unit vectors) based upon the
geomagnetic field that are optimized for understanding the movement of plasma,
the mapping of electric fields, and coupling with the neutral atmosphere.
This system is the first to remain orthogonal for multipole magnetic fields
as well as when including a geodetic reference surface (Earth).
OMMBV also includes methods for scaling ion drifts and electric fields
at one location to any other location along the same field line, though
typically the mapping is either the magnetic footpoint or to the
magnetic equator. Scaling to the footpoint is critical for understanding
how neutral atmosphere winds at low altitudes (120 km for coupling with
E-region ionosphere) will be
expressed either at the satellite location or at the magnetic equator.
Scaling to the magnetic equator can be particularly effective when creating a
common basis for integrating measurements from multiple platforms as
the scaling reduces a 4-dimensional data distribution (local time,
longitude, latitude, altitude) down to three (local time,
longitude, apex height). This feature may also be used by numerical models
to reduce memory requirements and runtime. Calculations may be performed
at the magnetic equator and then mapped throughout the magnetosphere, as needed.
OMMBV is used by the NASA Ionospheric Connections (ICON) Explorer
Mission to understand how remote measurements of neutral motions at 120 km
impacts the motion of plasma measured in-situ (at the satellite location).
This package is also being used by the NOAA/NSPO COSMIC-2
constellation to express plasma measurements made at the satellite locations
in a more geophysically useful basis. OMMBV is currently being incorporated
into analysis routines suitable for integrating physics-based models (TIEGCM)
and measurements from the Communications/Navigation Outage Forecasting System
(C/NOFS) satellite.
The development of the multipole software has been supported, in part, by
multiple agencies under the following grants:
Naval Research Laboratory N00173-19-1-G016 and NASA 80NSSC18K1203.
Previous versions of this software that provided an 'average' basis were
funded by: National Aeronautics and Space Agency (NASA NNG12FA45C),
National Oceanic and Atmospheric Administration (NOAA NSF AGS-1033112),
and the National Science Foundation (NSF 1651393).
# Geomagnetic Unit Vectors
Plasma in the ionosphere is constrained by the geomagnetic field. Motion
along magnetic field lines is easy while motion across field lines is
comparatively hard. To understand the motion of ions it is generally
best to do so along these directions. Though there are an infinite number
of vector pairs orthogonal to the geomagnetic field, OMMBV produces a vector
basis optimized for ion-neutral coupling investigations, the major driver of
the ionosphere.
- Field Aligned: Along the geomagnetic field, pointing generally from south
to north at the equator.
- Zonal: Perpendicular to the field aligned vector and points to a
neighboring field line that has no change in apex height at the geomagnetic
equator. The apex height is the highest altitude of a magnetic field
line above a reference surface.
- Meridional: Perpendicular to the zonal and field aligned directions.
This vector is positive upward and is vertical at the geomagnetic equator.
To remain perpendicular to the field, the meridional vector has a poleward
component when away from the magnetic equator. Note that meridional may
sometimes be used in other contexts to be north/south. Here, the vector
is generally up/down.
# Performance
OMMBV is able to characterize its uncertainty in determining an accurate
vector basis. There are two potential calculation paths within OMMBV. The
default path uses information from the calculated zonal vector and field-aligned
vector to obtain the corresponding meridional vector. Alternately, OMMBV can
calculate the meridional vector and obtain the corresponding zonal vector.
If the magnetic field has an underlying orthogonal vector basis, and if
OMMBV is operating correctly, OMMBV's two calculation paths will
yield the same result.
The figures linked below provide direct numerical evidence that OMMBV is calculating
a valid orthogonal vector basis. OMMBV's normalized uncertainty
when applied to a [pure dipole magnetic field with a spherical Earth](docs/images/dipole_uncertainty.png), and
the uncertainty when [applied to the Earth](docs/images/igrf_uncertainty.png) using the
[International Geomagnetic Reference Field](https://geomag.bgs.ac.uk/research/modelling/IGRF.html),
are effectively the same. Both systems have an expected maximum uncertainty
of around 0.0001% between +/- 50 degrees latitude. Both figures are calculated
at an altitude of 550 km and use an OMMBV calculation step size of 5 km.
The default step size for OMMBV and IGRF is 0.5 km which offers improved
performance.
# Electric Field and Ion Drift Mapping
OMMBV provides scalars for mapping ion motions or electric fields
expressed along geomagnetic unit vectors to other locations along the
same field line, though typically the scaling is to either the
magnetic footpoint or to the magnetic equator.
These scalars are determined assuming that magnetic
field lines are equipotential, thus the electric field associated with
ion motion will vary as the distance between two geomagnetic field lines
changes. Note that there is no mixing of 'zonal' or 'meridional' directions
when mapping along a field line. While the orientation for both directions
varies along a field line, the zonal and meridional directions are always
orthogonal.
# Field-Line Tracing
OMMBV uses the apex locations of field lines to determine both the unit vectors
as well as the mapping vectors for both ion drifts and electric fields.
To determine the apex location of field lines, the International Geomagnetic
Reference Field (IGRF) is coupled into SciPy's odeint to produce an
accurate field line tracing algorithm. The SciPy integrator is an adaptive
method that internally determines an appropriate step size thus the
performance of the technique is both robust and accurate. The sensitivity
of the field line tracing and other quantities in this package have been
established via direct comparison (when possible) as well as sensitivity
and consistency tests.
# Coordinate Transformations
Supports the conversion of geographic and geodetic (WGS84) into each other
and into Earth Centered Earth Fixed (ECEF). ECEF coordinates are fixed with
respect to the Earth, x points from the center towards 0 degrees longitude
at the geographic equator, y similarly points to 90 degrees east, while z
points along the Earth's rotation axis.
# Vector Transformations
Supports expressing a vector known in one basis into the same vector
expressed in another basis. This supports translating measurements made in a
spacecraft frame into frames more relevant for scientific analysis.
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [1.0.1] - 2022-01-04
- Added pyproject.toml to support systems without numpy.
- Modified manifest.ini to include version.txt
- Corrected bad link in build status badge
- Corrected BSD license classifier
## [1.0.0] - 2021-12-24
- Updated vector basis algorithm and reduced uncertainty when
scaling ion drifts and electric fields for multipole fields by four orders of magnitude.
- Added support for multiple unit test magnetic fields, from dipole up to octupole.
- Added support for testing vector basis determination with a spherical Earth.
- Improved tolerance checks on vector basis during iteration so outputs better
reflect user settings.
- Improved robustness of vector basis calculation at higher latitudes.
- Updated IGRF step method to slow integration when reaching target altitude
to use user provided step size.
- Allow automatic expansion of `field_line_trace` step_size after many iterations.
- Improved robustness of `apex_location_info` to unreported changes in
`field_line_trace` step_size.
- Added `pole_tol` keyword which specifies how close to vertical local
magnetic field must be to be considered a pole.
- Added `utils.datetimes_to_doubles` a method to calculate year and
fractional day of year for IGRF calls.
- Added keyword `max_steps` to `apex_location_info`
- Corrected normalization error in `magnetic_vector`.
- Deprecated `scalar` input for basis vectors.
- Reduced number of allowed recursive calls for `field_line_trace`
- Moved vector functions to `OMMBV.vector`
- Moved transformation functions to `OMMBV.trans`
- Moved tracing functions to `OMMBV.trace`
- Moved older algorithms not needed for current outputs to `OMMBV.heritage`
- Moved supporting Fortran functions from `OMMBV.igrf13` to `OMMBV.sources`
- Improved robustness of `apex_location_info` to `full_field_line` tracing failures.
- Added support for GitHub Workflows
- Refactored unit testing
- Moved to `setup.cfg`
- Added `.zenodo.json`
- Improved documentation
- Updated docstrings
- Added logo
- Updated testing versions
## [0.5.5] - 2021-06-16
- Updated setup.py
- Added compatibility with pysat v3.x
## [0.5.4] - 2020-03-03
- Updated to latest IGRF reference code
## [0.5.3] - 2020-06-19
- Metadata clarity improvements
## [0.5.2] - 2020-06-04
- Fixed bugs coupling the code repo to community services related to the name
change from pysatMagvect to OMMBV
## [0.5.0] - 2020-02-01
- Added community documents
- Implemented new algorithm for basis vectors. First system valid for multipole fields.
- Implemented new E and D scaling vectors similar to Richmond (apexpy)
- Implemented high accuracy numerical path that minimizes geodetic transformations
- Reviewed and updated default parameters based upon observed peformance
- Validated meridional vector along maximum apex height gradient
- Retained previous basis methods, identified by heritage or integrated
- Improved accuracy and robustness of heritage techniques though new methods recommended
- Validated accuracy of scaling methods
- Incorporated IGRF13
- Expanded and organized unit tests
- Removed pysat as a dependency
- Docstring improvements
## [0.4.0] - 2018-11-26
- Testing routines have been expanded significantly.
- Default parameters have been updated based upon this testing.
- Numerous corrections have been implemented.
## [0.3.1] - 2018-08-06
- Improved use of ECEF and ENU vectors.
## [0.3.0] - 2018-07-24
- Improved robustness of setup.py
- Corrected Earth Centered Earth Fixed (ECEF) and East, North, Up (ENU) conversion routines.
## [0.2.0] - 2018-07-05
- Improved documentation and metadata.
## [0.1.6] - 2018-06-29
- Improved installation process
## [0.1.0] - 2018-06-27
- Initial release