Pixhawk 2.1 EKF IMU Ground Mag Anomaly

Just upgraded to copter 3.5.5 and when tested in the field the copter has a yaw drift and flips shortly after takeoff. The error generated was “EKF2 IMU1 ground mag anomaly, yaw re-aligned”. Does anyone know why this problem may be occurring or how to fix it? I have already done compass calibration with good offsets, accelerometer calibration, and motor interference was done before upgrading to 3.5.5. I had similar problems when using the Pixhawk 2.1 with the 3.4 firmware.

The platform is a DJI S1000 Octocopter, Pixhawk 2.1, Here GNSS, using Mission Planner for ground control software.

Links to tlog and .bin files really help here. Sounds very odd, but I doubt that a compass error would flip your octocopter. EKF is usually very good about rejecting bad measurements.

Here are the files with the associated errors.
https://drive.google.com/open?id=1s-Cnc5h-3gM2LadJKRb4mVCz6DaYutAf

https://drive.google.com/open?id=17U9OMBwXY_lSkUOMVxPxUHgX0DGY8VO-