by Lisa Tauxe, Lori Jonestrask, Nick Swanson-Hysell and Nick Jarboe
PmagPy is a software package for analyzing paleomagnetic and rock magnetic data using Python. These notebooks demonstrate how to use PmagPy in a Jupyter notebook or Python script. For examples of how to use PmagPy scripts on the command line, see the static version of PmagPy_cli.ipynb.
For information on the science of paleomagnetism and rock magnetism, see textbook at: https://earthref.org/MagIC/books/Tauxe/Essentials/
If you already have some experience working with Python, you should be able to navigate these examples.
If not, we have a full course in Python for Earth Scientists available on Github. To check it out, see:
The functionality of PmagPy is demonstrated within three notebooks:
Functions in PmagPy_plots_analysis.ipynb
Functions in PmagPy_MagIC.ipynb
specimens_extract : makes excel or latex files from specimens.txt for publications
contributions work with data model 3.0 MagIC contributions
conversion scripts : convert many laboratory measurement formats to the MagIC data model 3 format
To use the functions demonstrated in these notebooks, we have to import the PmagPy modules pmagplotlib, pmag and ipmag and some other handy functions. You can run the following commands in a Python environment where PmagPy is installed (i.e., in the Python interpreter, or in a notebook).
import pmagpy.pmag as pmag import pmagpy.pmagplotlib as pmagplotlib import pmagpy.ipmag as ipmag import pmagpy.contribution_builder as cb from pmagpy import convert_2_magic as convert import matplotlib.pyplot as plt # our plotting buddy import numpy as np # the fabulous NumPy package import pandas as pd # and of course Pandas # test if Basemap and/or cartopy is installed has_basemap, Basemap = pmag.import_basemap() has_cartopy, Cartopy = pmag.import_cartopy() # test if xlwt is installed (allows you to export to excel) try: import xlwt has_xlwt = True except ImportError: has_xlwt = False # This allows you to make matplotlib plots inside the notebook. %matplotlib inline from IPython.display import Image import os print('All modules imported!')
All modules imported!