Instructors: Devin C. Cowan1 and Santiago Soler1
Authors of the material: Devin C. Cowan1, Santiago Soler1 and Lindsey Heagy1
Contributors: Mariana G.2 and Rowan Cockett3
1 Geophysical Inversion Facility. Earth Ocean and Atmospheric Sciences. University of British Columbia.
2 Centro de Investigación Científica y de Educación Superior de Ensenada (CICESE), Baja California
3 Curvenote
Information | |
---|---|
Where | ETH Zürich, Switzerland |
When | Feb 1 and Feb 2, 2024 |
Organizer | Agrogeophysics Organizing Committee |
Website of the event | agrogeophy.github.io/agrogeo24 |
In this workshop we'll showcase how we can use the tools available in SimPEG, a Python library for Simulations and Parameter Estimations in Geophysics, to simulate ERT (a.k.a. DC resistivity) data from a synthetic model and then to run a deterministic inversion to recover the original model. You'll learn how to set up a DC survey, define a mesh, build a synthetic model, create a simulation that implements all the physics, and run a forward model to generate synthetic data. Lastly you'll learn how to set up an inversion to recover the resistivity of the subsurface. By the end of the tutorial you'll be able to use SimPEG to invert your own data.
We were invited by Agrogeo24 to give a workshop about SimPEG, to show the agrogeophysical community how we can use SimPEG to run forward simulations of DC resistivity data (ERT), and how we can invert that type of data.
During this workshop we'll go through two Jupyter notebooks that showcase examples on how we can run forward and inverse problems for ERT data:
During this workshop we'll use Juptyer notebooks to run the forward and inverse modelling of DC resistivity data.
To be able to follow the workshop and run these notebooks, you'll need to have access to a Python environment. This could be done through online services like Google Colab, or through a local Python installation like Anaconda or Miniforge.
By default we'll use Google Colab. But we'll consider installing Python locally in case something goes wrong with the former.
Here will provide instructions to:
To be able to run the Jupyter notebooks for this tutorial in Google Colab, we'll need to follow these steps:
- Login to our Google Colab account.
- Create a new notebook.
- Install some Python libraries that we'll need to use, such as SimPEG.
If you don't have a Google account, create one and log in. If you do, you just need to log in.
- Access to Google Colab by going to: https://colab.research.google.com
- Find the top menu and choose
File
>New notebook
. A new tab should open with a blank notebook in it.
To be able to follow this workshop we need to install some Python libraries that aren't preinstalled in the default Google Colab environment.
- Click on the first cell of the notebook (if it's not empty, then create a new Code cell and move it to the first position with the arrows icons that appear on its top-right).
- Type the following line in the selected cell:
Note the
!pip install simpeg==0.20.0 discretize==0.10.0 pymatsolver==0.2.0
!
sign at the beginning of the line, don't remove it. - Run that cell by clicking the Play button on its left or by pressing
Shift+Enter
in your keyboard.pip
should install all the packaged listed in that line. If installation goes smoothly, you should see a line that readsSuccessfully installed ...
and lists all the new packages that had been installed.
Important
Every time you open a notebook in Colab or create a new one, you'll have to reinstall these packages (Google Colab don't save installed states across notebooks).
If it's a new notebook, just follow the previous instructions from the top.
If it's an existing notebook, make sure that it has the !pip install ...
line at the top (add it otherwise), and run it.
To be able to run the Jupyter notebooks for this tutorial in our own machines, we'll have to follow these steps:
- Install a Python distribution (like Anaconda or miniforge).
- Create a conda environment with all the Python packages needed (for example, SimPEG).
- Activate this conda environment and run JupyterLab to start coding.
We recommend installing a Python distribution like miniforge or Anaconda.
Both of them will install Python and a package manager that allows us to install new Python libraries (like SimPEG for example), and also create environments.
Anaconda uses the conda
package manager, while Miniforge uses the new
mamba
, which works faster than conda
.
If you have either of both installed, you can skip this step. Otherwise, please follow their installation instructions:
- Install miniforge: https://github.com/conda-forge/miniforge#install
- Install Anaconda: https://docs.anaconda.com/anaconda/install
Important
In the following steps we'll make use of the mamba
package manager. In case
you installed Anaconda, use conda
instead. You can simply replace mamba
for conda
on every command we ask to use it and it'll work fine.
- Download the
environment.yml
file from (right-click and select "Save page as" or similar). - Make sure that the file is called
environment.yml
. Windows sometimes adds a.txt
to the end, which you should remove. - Open a terminal (Anaconda Prompt or Miniforge Prompt if you are running Windows). The following steps should be done in the terminal.
- Navigate to the folder that has the downloaded environment file (if you don't know how to do this, take a moment to read the Software Carpentry lesson on the Unix shell).
- Create the conda environment by running
mamba env create --file environment.yml
(this will download and install all of the packages used in the tutorial). If you installed Anaconda, then replacemamba
forconda
in the previous line.
Tip
You'll need a browser that is able to run JupyterLab (basically anyone except Internet Explorer or Edge). If you are in Windows, make sure you change your default browser to a different one.
Now we can activate the newly created simpeg-agrogeo24
environment.
- Open a terminal (Anaconda Prompt or Miniforge Prompt if you are running Windows).
- Activate the
simpeg-agrogeo24
environment by runningmamba activate simpeg-agrogeo24
. If you installed Anaconda, then replacemamba
forconda
in the previous line. - With the
simpeg-agrogeo24
environment activated, we can start JupyterLab by runningjupyterlab
in the terminal. A new tab in our web browser should open showing JupyterLab's interface.
This work is licensed under a Creative Commons Attribution 4.0 International License.