A magnetometer is a scientific instrument used to measure the strength of the magnetic field, either produced in the laboratory or existing in nature. The Earths magnetic field (the magnetosphere) varies from place to place, for various reasons such as inhomogeneity of rocks and the interaction between charged particles from the Sun and the magnetosphere. Magnetometers are a frequent component instrument on spacecraft that explore planets.