ADCS.environment.magnetic_field module¶
Selectable geomagnetic field model.
Every field evaluation in the package goes through field_gc(), which
dispatches on a model name so that the implementation can be chosen per
orbit – the magnetic counterpart of zonal_J for gravity:
"igrf_numba"(default)The in-tree numba kernel,
ADCS.environment.igrf.igrf_gc()."igrf_ppigrf"The
ppigrfpackage, which was the field model up to 0.1.8. Kept so that older results can be reproduced exactly. It is an optional dependency (pip install "Generalized_ADCS[ppigrf]") and is imported only when selected.
Both evaluate IGRF-14 from the same coefficients and agree to ~1e-12
relative; they differ only in speed. A further model (e.g. WMM) is a new
entry in MAGNETIC_MODELS plus a branch in field_gc().
- ADCS.environment.magnetic_field.field_gc(magnetic_model, r, theta, phi, date)[source]¶
Geomagnetic field in geocentric spherical components, from a chosen model.
- Parameters:
magnetic_model (str) – One of
MAGNETIC_MODELS.r (float or numpy.ndarray) – Geocentric radius [km].
theta (float or numpy.ndarray) – Geocentric colatitude [deg].
phi (float or numpy.ndarray) – Geocentric longitude [deg], positive east.
date (datetime.datetime or sequence) – One date, or one date per sample (paired elementwise).
- Returns:
(Br, Btheta, Bphi)in nT, each with the broadcast shape of the coordinates.- Return type:
tuple
- Raises:
ValueError – If
magnetic_modelis unknown.ImportError – If
"igrf_ppigrf"is requested and ppigrf is not installed.
- Example:
>>> from datetime import datetime >>> br, bt, bp = field_gc("igrf_numba", 6771.2, 45.0, 10.0, datetime(2024, 3, 1))
- ADCS.environment.magnetic_field.DEFAULT_MAGNETIC_MODEL = 'igrf_numba'¶
Model used when none is requested.
- ADCS.environment.magnetic_field.MAGNETIC_MODELS = ('igrf_numba', 'igrf_ppigrf')¶
Names accepted by
magnetic_modelarguments throughout the package.