Example of how to do soft and hard iron calibration from a 3DOF magnetometer.
$ pipenv install $ pipenv run jupyter notebook
And edit the notebook.