Sometimes you just need to straighten out the workings inside the Phantom.
One of the things you can do at that point is to calibrate the compass. Some folks believe it must be done very frequently, others do it very infrequently. I do it when my bird starts acting goofy, whenever I have changed anything (except a battery), and when I have arrived in a location more than a hundred miles from home.
Timing is an important factor in calibrating the compass.
The phantom must be allowed to complete the "System start and self-check"
procedure without interruption, of any kind. No movement, no nothing is best, but then again some folks do it on a boat.
Things to consider
Here is a link to the DJI WIKI on the subject.
Location is of utmost importance. Never do the compass dance over buried power lines or concrete containing rebar. Stay away from any magnetic interferrence - of any kind. Electronics can cause interference. I was using a lanyard with metal clips and they goofed me up for months. I can go on and on about what to stay away from, the fact is you have to do your best to remain clear of any interference. In Wyoming, it's easy to escape the man made issues. We do have some very annoying rocks though.
The method doesn't really matter.
Here is DJI's WIKI showing where the compass module is located.
Do not calibrate the compass over underground power lines.