# MI_Wavelet_analysis
**_Dominant role of soil moisture in controlling Nighttime Net Ecosystem Exchange in Sub-Humid West African Ecosystems_**
> Last updated: 2026-07-03
This repository provides the raw data and the R / MATLAB scripts to reproduce the
analyses, figures and results presented in the scientific manuscript
"Dominant role of soil moisture in controlling Nighttime Net Ecosystem Exchange in Sub-Humid West African Ecosystems", submitted to JGR Biogeosciences.
The workflow combines **mutual information** (to quantify statistical
dependencies between NEE and its drivers) and **wavelet analysis** (to resolve
those dependencies across time scales) in order to investigate the
scale-dependent controls of nighttime net ecosystem exchange (NEE).
## Public Release
```
```
---
## Table of Contents
1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Data](#data)
4. [Repository Structure](#repository-structure)
5. [How to Run](#how-to-run)
6. [Reproducing the Figures](#reproducing-the-figures)
7. [Acknowledgements](#acknowledgements)
8. [Contact](#contact)
---
## Requirements
| Software | Version | Purpose |
|---|---|---|
| R | 4.2.0 | Data processing, gap-filling, mutual information |
| MATLAB | R2022b (v9.13.0) | Wavelet power, coherence and phase analysis |
**R packages**
```R
install.packages(c("data.table", "lubridate", "randomForest",
"varrank", "REddyProc", "openeddy",
"tidyverse", "ggplot2"))
```
**MATLAB toolboxes** (included in the `Processing` subfolder)
- Wavelet coherence routines from Grinsted et al. (2004) — folder `wavelet-coherence-master` (see [Acknowledgements](#acknowledgements))
- *Cumulative Arcwise Significance of Global Wavelet Power and Global Coherence Spectra* (v1.0.0.0) by Justin Schulte — folder `arcwise_sigtest`, available on [MATLAB Central File Exchange](
fr.mathworks.com)
> Adjust the package list above to match the actual dependencies used by your scripts.
---
## Installation
Download and unpack the zip archive.
Set the main project path at the top of each script so that it matches your
local environment before running anything.
---
## Data
The data sets used in this study are provided by the **AMMA-CATCH** observatory
and are available through the following DOIs. Each data set covers the two flux
stations, **Nalohou** and **Bellefoungou**.
| Data set | Content | DOI |
|---|---|---|
| AE.H2OFlux_Odc | Meteorology, fluxes and soil moisture at the flux stations | [10.17178/AMMA-CATCH.AE.SHFlux_Odc](
dx.doi.org) |
| CE.SW_Odc | Complementary soil temperature and humidity | [10.17178/AMMA-CATCH.CE.SW_Odc](
dx.doi.org) |
| CL.Rain_Od | Rainfall | [10.17178/AMMA-CATCH.CL.Rain_Od](
dx.doi.org) |
The scripts read these inputs and write intermediate and final outputs to the
`Processing/` and `Figures/` subfolders.
---
## Repository Structure
```
MI_Wavelet_analysis/
├── Processing/ # Analysis pipeline + dependencies
│ ├── NEE_data_post_process.r # Data preparation
│ ├── Mutual_information_analysis.r # Mutual information analysis
│ ├── NEE_data_MDS_gap_filling.r # Gap-filling (MDS)
│ ├── NEE_data_RF_gap_filling.r # Gap-filling of long gaps (Random Forest)
│ ├── Global_power_analysis.m # Global wavelet power
│ ├── Coherence_analysis.m # Wavelet coherence
│ ├── Phase_analysis.m # Phase difference (wavelets)
│ ├── wavelet-coherence-master/ # Grinsted et al. (2004) toolbox
│ └── arcwise_sigtest/ # Schulte arcwise significance toolbox
├── Figures/ # Code to generate the article figures
├── LICENSE
└── README.md
```
### Pipeline overview
| Stage | File | Description |
|---|---|---|
| 1. Preparation | `NEE_data_post_process.r` | Data preparation |
| 2. Mutual information | `Mutual_information_analysis.r` | Analysis using mutual information |
| 3. Gap-filling (short) | `NEE_data_MDS_gap_filling.r` | Marginal distribution sampling (MDS) |
| 4. Gap-filling (long) | `NEE_data_RF_gap_filling.r` | Random Forest (RF); also prepares data for coherence analysis |
| 5. Wavelet power | `Global_power_analysis.m` | Global wavelet power analysis |
| 6. Wavelet coherence | `Coherence_analysis.m` | Wavelet coherence analysis |
| 7. Phase | `Phase_analysis.m` | Phase difference analysis using wavelets |
---
## How to Run
Run the R stages in order, then the MATLAB stages.
**R (interactive)**
```R
source("./Processing/NEE_data_post_process.r")
source("./Processing/Mutual_information_analysis.r")
source("./Processing/NEE_data_MDS_gap_filling.r")
source("./Processing/NEE_data_RF_gap_filling.r")
```
**MATLAB**
```matlab
run('./Processing/Global_power_analysis.m')
run('./Processing/Coherence_analysis.m')
run('./Processing/Phase_analysis.m')
```
Make sure the main path is set in accordance with your local settings.
---
## Reproducing the Figures
Once the pipeline has produced its outputs, generate the article figures with
the scripts in the `Figures/` subfolder.
---
## Acknowledgements
The wavelet transform analysis makes use of the source code shared by
**Grinsted, A., Moore, J. C., and Jevrejeva, S. (2004)**, *Application of the
cross wavelet transform and wavelet coherence to geophysical time series*,
Nonlinear Processes in Geophysics, 11, 561–566.
The assessment of the statistical significance of the global wavelet power and
global coherence spectra uses the toolbox *Cumulative Arcwise Significance of
Global Wavelet Power and Global Coherence Spectra* (v1.0.0.0) by
**Justin Schulte**, distributed through the MATLAB Central File Exchange.
Eddy covariance flux post-processing and gap-filling rely on the **REddyProc**
package: Wutzler, T., Lucas-Moffat, A., Migliavacca, M., Knauer, J., Sickel, K.,
Šigut, L., Menzer, O., and Reichstein, M. (2018): *Basic and extensible
post-processing of eddy covariance flux data with REddyProc*, Biogeosciences,
15, 5015–5030,
doi.org.
Variable ranking based on mutual information uses the **varrank** package:
Kratzer, G., and Furrer, R. (2018): *varrank: an R package for variable ranking
based on mutual information with applications to observed systemic datasets*,
arxiv.org.
---
## Contact
- **Renaud Koukoui** — romeo.koukoui@imsp-uac.org
- **Ossénatou Mamadou** — ossenatou.mamadou@imsp-uac.org
---