code: def mag_field_df(MAG, ofs=None):
      '''calculate magnetic field strength from raw magnetometer (dataflash version)'''
      mag = Vector3(MAG.MagX, MAG.MagY, MAG.MagZ)
      offsets = Vector3(MAG.OfsX, MAG.OfsY, MAG.OfsZ)
      if ofs is not None:
          mag = (mag - offsets) + Vector3(ofs[0], ofs[1], ofs[2])
      return mag.length(f mag_field_df(MAG, ofs=None):
      '''calculate magnetic field strength from raw magnetometer (dataflash version)'''
      mag = Vector3(MAG.MagX, MAG.MagY, MAG.MagZ)
      offsets = Vector3(MAG.OfsX, MAG.OfsY, MAG.OfsZ)
      if ofs is not None:
          mag = (mag - offsets) + Vector3(ofs[0], ofs[1], ofs[2])
      return mag.length()
docs: calculate magnetic field strength from raw magnetometer (dataflash version)