Getting going with rockmag.py on JupyterHub#
First step!#
Log into your JupyterHub server

Then upload this notebook into your own EarthRef JupyterHub server

Then change kernel in JupyterHub to Python 3.10

Finally, execute this notebook by clicking Cell
-> Run All
This will run all the cells in the notebook, which includes the installation/update of the PmagPy
package which includes the rockmag.py
module. Running the notebook will also import that current version of the rockmagpy notebooks from the RockmagPy-notebooks repository. You will find a new folder called rockmag
in your JupyterHub directory after running the notebook.
Warning: Every time you execute this notebook, the
rockmag
folder will be overwritten! If you have any data in therockmag
folder, make sure to back it up (or simply rename it) before running this setup notebook again.

Jupyter notebooks and JupyterHub#
The Jupyter notebook environment enables us to interactively run code and visualize the output complete with annotated notes (like this one!). Such a notebook can be run locally on one’s computer with a Python installation or can be run on a JupyterHub such as the EarthRef JupyterHub server.
Upload and download from JupyterHub#
To upload data from a computer, click the ‘Upload’ button. To download a particular image or data file, it can be opened and then downloaded using the File menu. You can upload this notebook (which you can download here [click the download button]) to JupyterHub (if you haven’t already) to get setup with RockmagPy notebooks.
Jupyter notebook anatomy#
Jupyter notebooks have two basic cell type:
Markdown: for typesetting notes. This cell is an example of a markdown cell. Here is a “cheatsheet” for markdown typesetting: https://medium.com/ibm-data-science-experience/markdown-for-jupyter-notebooks-cheatsheet-386c05aeebed if you are hungry for more.
Code: for writing python code
Insert a new cell by selecting ‘Insert Cell Below’ in the drop-down menu under ‘Insert’. Cell types default to ‘Code’ but the cell type can be changed to ‘Markdown’ with the box labeled ‘Markdown’ on the menu bar.
To ‘execute’ a cell of either flavor, click on the Run key, select Run Cells under the Cell drop-down menu, or type Shift+Enter
.
What is PmagPy
?#
PmagPy
(Tauxe et al., 2016; doi:10.1002/2016GC006307) is a software package including programs and functions for analyzing paleomagnetic and rock magnetic data using Python. In addition to providing tools for the working paleomagnetist, PmagPy serves as an interface between paleomagnetic laboratory data and the MagIC database.
The documentation for PmagPy is located here: https://pmagpy.github.io/PmagPy-docs/
What is RockmagPy
?#
RockmagPy
is a module within PmagPy
focused on functions for analyzing rock magnetic data in MagIC format using Python. When you install PmagPy
, you get RockmagPy
.
The documentation for RockmagPy is located here: https://pmagpy.github.io/RockmagPy-notebooks/
Installing the latest release of PmagPy
#
Running the cell (by selecting it and then pressing run), will install the latest version of PmagPy
.
%pip install pmagpy --user --upgrade # install or upgrade pmagpy in your user packages
%pip install cartopy --user --upgrade # install or upgrade cartopy in your user packages
Get the RockmagPy-notebook materials from GitHub:#
Run the code block below to pull in the files and RockmagPy Jupyter Notebooks from Github (PmagPy/RockmagPy-notebooks).
!rm -Rf ~/rockmag_notebooks # remove any existing downloaded files
!mkdir ~/rockmag_notebooks # make space for downloaded files
!wget -O - https://github.com/PmagPy/RockmagPy-notebooks/tarball/master | tar xz -C ~/rockmag_notebooks # download the latest files
Get the 2025 Rockmagpy Workshop materials from GitHub:#
Run the code block below to pull in the files and Jupyter Notebooks from Github associated with the 2025 Rockmagpy Workshop at the IRM conference (Institute-for-Rock-Magnetism/2025_rockmagpy_workshop).
!rm -Rf ~/2025_rockmagpy_workshop # remove any existing downloaded files
!mkdir ~/2025_rockmagpy_workshop # make space for downloaded files
!wget -O - https://github.com/Institute-for-Rock-Magnetism/2025_rockmagpy_workshop/tarball/master | tar xz -C ~/2025_rockmagpy_workshop # download the latest files
Next step:#
Click on ‘Open’ under the ‘File’ menu. You may need to refresh your browser to see the new rockmag_notebooks and 2025_rockmagpy_workshop directories). Open the rockmag directory and navigate through to your notebook of choice.
You can return to this notebook and re-run the cells above to upgrade the packages or reset and update the notebook library and data files in the future.