### Normalising angled Earth magnetic field from Sense HAT magnetometer

Posted:

**Tue Jan 22, 2019 8:13 pm**We want to investigate the connection between the magnetic intensity measurements from Sense HAT magnetometer and predictions from the World Magnetic Model (WMM). We want to research the accuracy of the magnetometer on Sense HAT.

The program will get raw magnetometer data (X, Y and Z) in microteslas from Sense HAT and calculate values H and F as described in British geological survey's article (https://geomag.bgs.ac.uk/education/earthmag.html) (section 2.1). It will then save them to CSV file, along with timestamp and location calculated with ephem.

We will then compare values Z, H and F from ISS with WMM data and create maps with our data and differences (like figures 6, 8 and 10). We will then research, how accurate are Sense HAT magnetometer data.

We want to compare our data with data from WMM to see how accurate is Sense HAT magnetometer, but we have a problem that the orientation of magnetometer will always be different. Because of that, our data will always be (very) different from WMM so we won't be able to compare them correctly.

We talked with Astro Pi support team and they suggested to "normalise the angled measurements so it looks like they were taken by a device aligned North/South".

Unfortunately, we (and they) don't know how to do this, so they suggested to ask this question on Stack Exchange. I asked it on https://math.stackexchange.com/question ... etic-field and https://physics.stackexchange.com/quest ... etic-field, but unfortunately, it didn't receive any answers, so I am also asking this here.

How can we do this? We have data for the timestamp, ISS location (latitude, longitude, elevation), magnetic data (X, Y and Z) and also the direction from the North.

We want to normalise our data so we will be able to correctly compare them with data from WMM.

Here is part of our program that calculates magnetometer values (which gets not normalised data):

The program will get raw magnetometer data (X, Y and Z) in microteslas from Sense HAT and calculate values H and F as described in British geological survey's article (https://geomag.bgs.ac.uk/education/earthmag.html) (section 2.1). It will then save them to CSV file, along with timestamp and location calculated with ephem.

We will then compare values Z, H and F from ISS with WMM data and create maps with our data and differences (like figures 6, 8 and 10). We will then research, how accurate are Sense HAT magnetometer data.

We want to compare our data with data from WMM to see how accurate is Sense HAT magnetometer, but we have a problem that the orientation of magnetometer will always be different. Because of that, our data will always be (very) different from WMM so we won't be able to compare them correctly.

We talked with Astro Pi support team and they suggested to "normalise the angled measurements so it looks like they were taken by a device aligned North/South".

Unfortunately, we (and they) don't know how to do this, so they suggested to ask this question on Stack Exchange. I asked it on https://math.stackexchange.com/question ... etic-field and https://physics.stackexchange.com/quest ... etic-field, but unfortunately, it didn't receive any answers, so I am also asking this here.

How can we do this? We have data for the timestamp, ISS location (latitude, longitude, elevation), magnetic data (X, Y and Z) and also the direction from the North.

We want to normalise our data so we will be able to correctly compare them with data from WMM.

Here is part of our program that calculates magnetometer values (which gets not normalised data):

Code: Select all

```
compass = sense.get_compass_raw()
try:
# Get raw data (values are swapped because Sense HAT on ISS is in different position)
# x: northerly intensity
# y: easterly intensity
# z: vertical intensity
x = float(compass['z'])
y = float(compass['y'])
z = float(compass['x'])
except (ValueError, KeyError) as err:
# Write error to log (excluded from this snippet)
pass
try:
# h: horizontal intensity
# f: total intensity
# d: declination
# i: inclination
h = sqrt(x ** 2 + y ** 2)
f = sqrt(h ** 2 + z ** 2)
d = degrees(atan(y / x))
i = degrees(atan(z / h))
except (TypeError, ValueError, ZeroDivisionError) as err:
# Write error to log (excluded from this snippet)
pass
```