You know that Mavic technique where you rotate the aircraft a bunch so the compass sensors can be calibrated? In full-scale aircraft, this is called a "Compass Swing" procedure. It works kinda the same way.
Here are two helicopter examples I found, though fixed-wing have to do it also. It's best done on a dedicated part of the airport with a painted compass rose design to assist aligning the aircraft in specific known directions.
These videos are short and only show one swing between sample directions. How many directions depends on the level of calibration required. The engines have to be running at the time, because they may be contributing to the overall magnetic field against which you're calibrating. You can imagine this takes a lot of money, fuel and peoples' time. A busy military airfield is probably doing a compass swing almost full-time.
Here are two helicopter examples I found, though fixed-wing have to do it also. It's best done on a dedicated part of the airport with a painted compass rose design to assist aligning the aircraft in specific known directions.
These videos are short and only show one swing between sample directions. How many directions depends on the level of calibration required. The engines have to be running at the time, because they may be contributing to the overall magnetic field against which you're calibrating. You can imagine this takes a lot of money, fuel and peoples' time. A busy military airfield is probably doing a compass swing almost full-time.