Package: planetMagFields
planetMagFieldsSoftware to easily access and analyze information about magnetic fields of planets in our solar system and visualize them in both 2D and 3D.PrerequisitesInstallationFeatures and examplesJupyter notebookDocumentationAcknowledgementsPrerequisitesplanetMagFieldsrequiresNumPy,MatplotlibandSciPy. Other than that, the following external libraries are used for a few different functions:2D plotting for map projections other than Hammer :CartopylibraryPotential extrapolation:SHTnslibraryWriting vts files for 3D visualisation:PyEVTKlibraryInstallationplanetMagFieldscan be installed in a few different ways:UsingpipplanetMagFieldsis available onPyPIand can be installed with$python3-mpipinstallplanetMagFieldsUsingsetup.pyYou can also usesetup.pyto installplanetMagFields:$gitclonehttps://github.com/AnkitBarik/planetMagFields
$cdplanetMagFields
$pytho3setup.pyinstall--userOr usingpip:$gitclonehttps://github.com/AnkitBarik/planetMagFields
$cdplanetMagFields
$python3-mpipinstall.--userUsingPYTHONPATHDownload the package from the GitHub repository and add it
toPYTHONPATH:$gitclonehttps://github.com/AnkitBarik/planetMagFields
$exportPYTHONPATH=$PYTHONPATH:/path/to/planetMagFieldsFeatures and examplesThePlanetclassThis gives access to all the relevant properties of a planet and has methods to plot
the field and write avtsfile for 3D visualization. Usage:fromplanetmagfieldsimportPlanetp=Planet(name='earth',datDir='planetmagfields/data/')This displays the some information about the planetPlanet:Earthl_max=13Dipoletilt(degrees)=-9.410531and gives access to
variables associated with the planet such as:p.lmax: maximum spherical harmonic degree till which data is availablep.glm,p.hlm: the Gauss coefficientsp.Br: computed radial magnetic field at surfacep.dipTheta: dipole tilt with respect to the rotation axisp.dipPhi: dipole longitude ( in case zero longitude is known, applicable to Earth )p.idx: indices to get values of Gauss coefficientsp.model: the magnetic field model used. Available models can be obtained using theget_modelsfunction. Selects the latest available model when unspecified.Example usingIPython:In[1]:fromplanetmagfieldsimportPlanetIn[2]:p=Planet(name='jupiter',model='jrm09')Planet:JupiterModel:jrm09l_max=10Dipoletilt(degrees)=10.307870In[3]:p.glm[p.idx[2,0]]# g20Out[3]:11670.4In[4]:p.hlm[p.idx[4,2]]# h42Out[4]:27811.22D and 3D visualizationsplanetMagFieldscan be used to produce both 2D and 3D visualizations of a planetary field.
While doing so, it also provides the option of potential extrapolation using theSHTnslibrary. Two examples are shown below: Earth's surface field and a 3D visualization of Jupiter's field usingParaview. This is done by writing a.vtsfile using thePyEVTKlibrary.Jupyter notebookFor quick and easy visualization we include aJupyternotebook with a binder link (see badge at the top).
This makes use ofJupyter widgetsto provide dropdown lists of planets and available magnetic
field models for each as well as a slider for radial level, as shown belowThis plots the radial magnetic field at the chosen radial level and the corresponding magnetic field spectrum,DocumentationFull list of features with examples as well as the magnetic field models used are described in detail in the documentation,
available here:https://ankitbarik.github.io/planetMagFields/AcknowledgementsI would like to thankRegupathi Angappanfor motivating me to create this package, testing it and for writing the Jupyter notebook. I thankJon Aurnoufor testing it out and pointing out runtime errors. I would like to thankThomas Gastinefor comparing the plots with real data and pointing out a normalization error which has been fixed. Thanks a lot toArthusfor adding thesetup.py.