IGRF Magnetic Model - aa236b-winter-2019/software-documentation GitHub Wiki
IGRF 12 is the 12th generation of the International Geomagnetic Reference Field. It is included in the Matlab Aerospace Toolbox, as well as some python packages. It is a tool that takes in a location and a time, and returns a magnetic field vector. For our spacecraft in orbit, measuring the magnetic field is as simple as reading values off the magnetometers, but for our orbital simulation, we have to simulate this environment to spoof the magnetic sensor data. Because of this, we built a python IGRF function for our orbital simulation. The function written for this purpose can be found in the orbital simulation files, named <igrffx.py>.
- numpy
- pyIGRF
- pymap3d
- navpy
- datetime
- astropy
For this part of the simulation, we need to use the location in Earth Centered Inertial, and time in MJD to get a B vector. To do this, we used the package pyIGRF. However, the pyIGRF function takes location in geodetic coordinates, not ECI. Because of this, we had to use a function in the package pymap3d, eci2geodetic, to convert our ECI coordinates into geodetic. From here we fed the geodetic coordinates into the pyIGRF function, and got a magnetic field vector in north east down (NED) coordinates. This vector was then expressed in the ECI frame by using a navpy function, ned2ecef, then converting the ECEF coordinates to ECI using ecef2eci from pymap3d.
Using this method for the orbital simulation, we were able to get a B vector in ECI from our location. The next step was to convert the vector form the ECI frame to the body frame by using our quaternion. To do this, we converted the quaternion to a rotation matrix from ECI to the body frame, and multiplied our B vector by it.
Magnetic Field Over the Orbit