Code
import sys
'../src')
sys.path.append(import numpy as np
import quaternion
from scipy import signal as sps
import vector as vec
from utils import db10
import multipole as mp
from matplotlib import pylab as plt
ION MagNav Workshop, PLANS 2023, Monterey, CA
Aaron Nielsen
The views expressed in this article are those of the author and do not necessarily reflect the official policy or position of the United States Government, Department of Defense, United States Air Force or Air University.
Distribution A: Authorized for public release. Distribution is unlimited. Case No. 2023-0427.
There’s a docker container with a jupyter notebook that contains this exercise:
Then select work/calibration.ipynb
Set up code for python
```{python}
import vector as vec
import numpy as np
from matplotlib import pylab as plt
import quaternion
```
Create an external Earth magnetic field vector in a North, East, Down coordinate system.
abg = np.radians(np.array([b_earth_declination, -b_earth_inclination, 0.0]))
qrot = quaternion.from_euler_angles(abg)
b_earth_ned = quaternion.rotate_vectors(qrot,np.array([[b_earth_magnitude,0,0]]))
# what does the Earth's core field look like to the sensor if the sensor spins in space?
# rotating the aircraft to a specific heading in the Earth reference frame is the
# same as rotating the Earth magnetic field to -heading in the aircraft reference frame.
abg = np.radians(np.array([-headings,
np.zeros_like(headings),
np.zeros_like(headings)])).T
qrot = quaternion.from_euler_angles(abg)
#b_earth_at_sensor = quaternion.rotate_vectors(qrot,b_earth_ned)
b_earth_at_sensor = quaternion.as_vector_part(
qrot * quaternion.from_vector_part(b_earth_ned) * qrot.conjugate()
)
# plot the measured magnetic field at the sensor
fig, ax = plt.subplots(3,1)
fig.suptitle('Earth B-field at sensor')
axlabels = [ 'x', 'y', 'z']
for sax in [0,1,2]:
ax[sax].plot(headings, b_earth_at_sensor[:,sax], label=axlabels[sax])
ax[sax].grid()
ax[sax].set_xlabel('heading')
ax[sax].legend()
ax[sax].set_xticks(np.arange(0, 361, 30))
True direction cosines
Direction cosines corrupted by aircraft moment
Tolles-Lawson model that is “correct” - permanent only terms
Tolles-Lawson with induced moments
Compute the true direction cosines using just the Earth field:
This simulation has only a permanent moment, so only include a permanent moment in the A-matrix:
def AMatrix(dc,btot=1,perm_only=False):
if perm_only:
return dc #* vec.mag(btot)
else:
Aperm = dc
Aindu = np.hstack([ dc**2 ,
dc[:,0,np.newaxis]*dc[:,1:],
dc[:,1,np.newaxis]*dc[:,2,np.newaxis] ])
Aindu *= vec.mag(btot)
return np.hstack([ Aperm, Aindu] ) #* vec.mag(btot)
perm_only=True
amat_earth_at_sensor = AMatrix(
dc_earth_at_sensor,
b_earth_at_sensor,
perm_only=perm_only)
We can solve using either the true direction cosines or the DC with the moment included.
Start with true external field, not corrupted by permament moment
Text(0.5, 0.98, 'Computed magnetic correction')
<matplotlib.legend.Legend at 0x7f33b367d6d0>
The compensated field has a residual of 250 nT amplitude at double the frequency of the rotation rate.
<matplotlib.legend.Legend at 0x7f33b35f4100>
We can solve using either the true direction cosines or the DC with the moment included.
Start with true external field, not corrupted by permament moment
Text(0.5, 0.98, 'Computed magnetic correction')
<matplotlib.legend.Legend at 0x7f33b344f490>
The compensated field has a residual of 250 nT amplitude at double the frequency of the rotation rate.
<matplotlib.legend.Legend at 0x7f33b33d5040>
Compute the corrupted direction cosines using just the Earth field:
We can solve using either the true direction cosines or the DC with the moment included.
Start with true external field, not corrupted by permament moment
Text(0.5, 0.98, 'Computed magnetic correction')
<matplotlib.legend.Legend at 0x7f33b314f2e0>
The compensated field has a residual of 250 nT amplitude at double the frequency of the rotation rate.
<matplotlib.legend.Legend at 0x7f33b31a66d0>
Compute the corrupted direction cosines using just the Earth field:
We can solve using either the true direction cosines or the DC with the moment included.
Start with true external field, not corrupted by permament moment
Text(0.5, 0.98, 'Computed magnetic correction')
<matplotlib.legend.Legend at 0x7f33b2e94520>
The compensated field has a residual of 250 nT amplitude at double the frequency of the rotation rate.
<matplotlib.legend.Legend at 0x7f33b2dec670>