Here we take the differential pressure from flow in porous media experiments, and use continuous wavelet transformation (CWT) to gain further insight into the pressure data. The fluctuations in the pressure data provide key insights to the underlying pore-scale dynamics.
The paper associated with work is: https://doi.org/10.1029/2023GL104473
Recommended steps for running the notebook.
-
Download and install vscode: https://code.visualstudio.com/
-
Download and install python: https://www.python.org/downloads/ (download version 3.10.11)
-
Install the python extension in vscode. In vscode, click the extensions icon in the sidebar and search for "python"
-
Open a new folder (link it the folder containing the contents of this repository, wherever that is on your computer)
-
Create a virtual enviornment. In vscode click View>Terminal and enter the code below:
python -m venv venv
Then for Mac enter: source myenv/bin/activate
or for Windows: myenv\Scripts\activate -
Install the necessary packages by typing this in the terminal:
pip install -r requirements.txt
NB. must be in the folder where the requirements.txt file is. Alternatively, you can install the packages individually e.g. pip install numpy. Now open the notebook (wavelet_plotting_GRL_paper.ipynb) and begin!
The variables for the wavelet analysis are
- dt. This is the time step between pressure data points in seconds.
- mirror = True. This mirrors the pressure data to minimise any edge effects. Can also be set to 'False".
- wf = 'dog' # or 'morlet'. This is the wavelet. Options are 'dog', which is the Derivative-of-Gaussian wavelet. The Morlet wavelet can also be selected.
- om0 = 6. This is the derivative of the wavelet.
- dj=0.1. This is the scale step. The power is rectified by scale as done in Liu et al. (2007). See manuscript for more details.
- mirrormethod = 2 # 1 or 2 (mirroring method reduces end effects, so type of mirroring depends on the pressure signal and overall trend). Mirror method 1 mirrors the data in the x axes only, mirror method 2 mirrors the data in the x and y axes.
- filter. If you have a lot of data, you can filter it to make the code run faster. Filter can = 'None' for no filtering. Filter = 1 for a moving average filter, and filter = 2 for downsampling of the data set.
- infile. This is the file where your pressure data is saved. It needs to be a .dat file containing just the pressure measurements (code assumes input of kPa).
Update these for your data set and then you are good to go!
Note, if the filter is set to 'None' then these pressure plots will be the same. The mirrored pressure signal is also given, to see how well edge effects will be managed in the continuous wavelet transformation.

This is the equivalent of a Fourier analysis plot. Red noise is indicated on the plot as this type of noise is common for flow in porous media. See https://doi.org/10.1029/2022WR031947 for further details on this.

The fifth output is the amplitude of fluctuations versus their frequency for different sections of the signal
The sections are shown in the pressure plot and can be adjusted within the code.


