code: def mag_discrepancy(RAW_IMU, ATTITUDE, inclination, declination=None):
      '''give the magnitude of the discrepancy between observed and expected magnetic field'''
      if declination is None:
          import mavutil
          declination = degrees(mavutil.mavfile_global.param('COMPASS_DEC', 0))
      expected = expected_mag(RAW_IMU, ATTITUDE, inclination, declination)
      mag = Vector3(RAW_IMU.xmag, RAW_IMU.ymag, RAW_IMU.zmag)
      return degrees(expected.angle(mag)f mag_discrepancy(RAW_IMU, ATTITUDE, inclination, declination=None):
      '''give the magnitude of the discrepancy between observed and expected magnetic field'''
      if declination is None:
          import mavutil
          declination = degrees(mavutil.mavfile_global.param('COMPASS_DEC', 0))
      expected = expected_mag(RAW_IMU, ATTITUDE, inclination, declination)
      mag = Vector3(RAW_IMU.xmag, RAW_IMU.ymag, RAW_IMU.zmag)
      return degrees(expected.angle(mag))
docs: give the magnitude of the discrepancy between observed and expected magnetic field