Magnetometer

A triad of magnetometers measures the local magnetic field in body coordinates. Compare the slow orbital variation with the faster variation caused by spacecraft spin.

Stable attitude

A satellite maintains a steady nadir-pointing attitude as it orbits Earth. Magnetometer field components and magnitude change over one orbit while the body attitude stays fixed.

The field changes as the satellite moves through Earth’s magnetic field, even while its inertial attitude is fixed.

magnetometer_stable.py
"""Show orbital magnetic-field variation with a fixed inertial attitude."""

from pathlib import Path
import sys

import matplotlib.pyplot as plt
import numpy as np

sys.path.append(str(Path(__file__).resolve().parents[3]))
import ADCS

environment = ADCS.Environment(magnetic_field=ADCS.IGRF14())
magnetometers = [ADCS.MTM(axis=axis, sample_time=20.0) for axis in np.eye(3)]
satellite = ADCS.Satellite(
    mass=4.0, J_0=np.diag([0.0333, 0.0333, 0.00667]),
    sensors=magnetometers, disturbances=[],
)
radius = 6878.1363  # 500 km altitude
orbit = ADCS.Orbital_State(
    environment=environment, J2000=0.22,
    R=np.array([0.0, -radius, 0.0]),
    V=np.array([np.sqrt(398600.4415 / radius), 0.0, 0.0]),
)
results = ADCS.simulate(
    x=ADCS.State(w=np.zeros(3), q=np.array([1.0, 0.0, 0.0, 0.0])),
    satellite=satellite, os0=orbit, environment=environment,
    dt=20.0, tf=6000.0,
)

run = results.runs[0]
time_min = np.asarray(run.time_s) / 60.0
field_nt = np.vstack(run.clean_sensor_hist) * 1e9
fig, axes = plt.subplots(2, 1, figsize=(9, 6), sharex=True)
for i, axis in enumerate("xyz"):
    axes[0].plot(time_min, field_nt[:, i], label=f"$B_{axis}$")
axes[0].set_ylabel("Body-frame field [nT]")
axes[0].set_title("Magnetic field over one orbit · fixed inertial attitude")
axes[0].legend(ncol=3)
axes[0].grid(alpha=0.3)
axes[1].plot(time_min, np.linalg.norm(field_nt, axis=1), color="black")
axes[1].set_ylabel("Field magnitude [nT]")
axes[1].set_xlabel("Time [min]")
axes[1].grid(alpha=0.3)
fig.tight_layout()

plt.show()

Tumbling attitude

A satellite tumbles near its intermediate inertia axis in the Dzhanibekov effect. The body-frame magnetic-field components vary rapidly as the satellite tumbles.

The rapid body-frame change is related to \(\boldsymbol{\omega}\times \mathbf{B}\). When spin is much faster than orbital field change, this gives limited information about the rate perpendicular to \(\mathbf{B}\); it does not recover the full angular rate. The B-Dot controller uses the measured field derivative to detumble.

magnetometer_tumbling.py
"""Show fast body-frame magnetic-field variation during a Dzhanibekov tumble."""

from pathlib import Path
import sys

import matplotlib.pyplot as plt
import numpy as np

sys.path.append(str(Path(__file__).resolve().parents[3]))
import ADCS

environment = ADCS.Environment(magnetic_field=ADCS.IGRF14())
inertia = np.array([
    [0.0333, 0.0060, 0.0],
    [0.0060, 0.0333, 0.0],
    [0.0, 0.0, 0.00667],
])
magnetometers = [ADCS.MTM(axis=axis, sample_time=1.0) for axis in np.eye(3)]
satellite = ADCS.Satellite(
    mass=4.0, J_0=inertia, sensors=magnetometers, disturbances=[],
)
orbit = ADCS.Orbital_State(
    environment=environment, J2000=0.22,
    R=np.array([7000.0, 0.0, 0.0]), V=np.array([0.0, 7.5, 0.0]),
)
results = ADCS.simulate(
    x=ADCS.State(
        w=np.deg2rad([3.5, -3.5, 0.1]), q=np.array([1.0, 0.0, 0.0, 0.0]),
    ),
    satellite=satellite, os0=orbit, environment=environment,
    dt=1.0, tf=180.0,
)

run = results.runs[0]
field_nt = np.vstack(run.clean_sensor_hist) * 1e9
fig, ax = plt.subplots(figsize=(9, 4.5))
for i, axis in enumerate("xyz"):
    ax.plot(run.time_s, field_nt[:, i], label=f"$B_{axis}$")
ax.set_title("Body-frame magnetic field during the tumble")
ax.set_xlabel("Time [s]")
ax.set_ylabel("Magnetic field [nT]")
ax.legend(ncol=3)
ax.grid(alpha=0.3)
fig.tight_layout()

plt.show()