marss2l 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. marss2l-0.2.1/LICENCE +166 -0
  2. marss2l-0.2.1/PKG-INFO +219 -0
  3. marss2l-0.2.1/README.md +204 -0
  4. marss2l-0.2.1/marss2l/__init__.py +1 -0
  5. marss2l-0.2.1/marss2l/dataframe_image_plumes.py +1217 -0
  6. marss2l-0.2.1/marss2l/eval_baseline.py +165 -0
  7. marss2l-0.2.1/marss2l/eval_final.py +272 -0
  8. marss2l-0.2.1/marss2l/huggingface.py +242 -0
  9. marss2l-0.2.1/marss2l/loaders.py +1914 -0
  10. marss2l-0.2.1/marss2l/locations_case_studies.py +155 -0
  11. marss2l-0.2.1/marss2l/loss.py +263 -0
  12. marss2l-0.2.1/marss2l/mars_sentinel2/__init__.py +0 -0
  13. marss2l-0.2.1/marss2l/mars_sentinel2/countries.py +77 -0
  14. marss2l-0.2.1/marss2l/mars_sentinel2/ee.py +32 -0
  15. marss2l-0.2.1/marss2l/mars_sentinel2/integrated_transmittances.json +1 -0
  16. marss2l-0.2.1/marss2l/mars_sentinel2/mixing_ratio_methane.py +839 -0
  17. marss2l-0.2.1/marss2l/mars_sentinel2/plume_detection.py +120 -0
  18. marss2l-0.2.1/marss2l/mars_sentinel2/plume_detection_model.py +739 -0
  19. marss2l-0.2.1/marss2l/mars_sentinel2/plumesimulation.py +759 -0
  20. marss2l-0.2.1/marss2l/mars_sentinel2/quantification.py +17 -0
  21. marss2l-0.2.1/marss2l/mars_sentinel2/query_images.py +422 -0
  22. marss2l-0.2.1/marss2l/mars_sentinel2/s2lutils.py +399 -0
  23. marss2l-0.2.1/marss2l/mars_sentinel2/transmittance_to_ch4.py +725 -0
  24. marss2l-0.2.1/marss2l/mars_sentinel2/utils.py +188 -0
  25. marss2l-0.2.1/marss2l/mars_sentinel2/utils_torch.py +55 -0
  26. marss2l-0.2.1/marss2l/mars_sentinel2/wind.py +396 -0
  27. marss2l-0.2.1/marss2l/mbmp_torch.py +59 -0
  28. marss2l-0.2.1/marss2l/metrics.py +112 -0
  29. marss2l-0.2.1/marss2l/models.py +431 -0
  30. marss2l-0.2.1/marss2l/plot/__init__.py +14 -0
  31. marss2l-0.2.1/marss2l/plot/colors.py +7 -0
  32. marss2l-0.2.1/marss2l/plot/geographical_location.py +76 -0
  33. marss2l-0.2.1/marss2l/plot/images_by_month.py +282 -0
  34. marss2l-0.2.1/marss2l/plot/inference.py +25 -0
  35. marss2l-0.2.1/marss2l/plot/plot_histograms_predictions.py +124 -0
  36. marss2l-0.2.1/marss2l/plot/plot_location_for_inference.py +187 -0
  37. marss2l-0.2.1/marss2l/plot/prob_vs_emission_rate.py +102 -0
  38. marss2l-0.2.1/marss2l/plot/recall_fluxrate_plot.py +280 -0
  39. marss2l-0.2.1/marss2l/plot/time_series.py +151 -0
  40. marss2l-0.2.1/marss2l/reproduce_training.py +268 -0
  41. marss2l-0.2.1/marss2l/sampling.py +101 -0
  42. marss2l-0.2.1/marss2l/seed.py +44 -0
  43. marss2l-0.2.1/marss2l/stats_dataset.py +276 -0
  44. marss2l-0.2.1/marss2l/train_final.py +527 -0
  45. marss2l-0.2.1/marss2l/trainer.py +472 -0
  46. marss2l-0.2.1/marss2l/utils.py +211 -0
  47. marss2l-0.2.1/marss2l/validation_utils.py +129 -0
  48. marss2l-0.2.1/marss2l.egg-info/PKG-INFO +219 -0
  49. marss2l-0.2.1/marss2l.egg-info/SOURCES.txt +56 -0
  50. marss2l-0.2.1/marss2l.egg-info/dependency_links.txt +1 -0
  51. marss2l-0.2.1/marss2l.egg-info/top_level.txt +1 -0
  52. marss2l-0.2.1/pyproject.toml +94 -0
  53. marss2l-0.2.1/setup.cfg +4 -0
  54. marss2l-0.2.1/tests/test_calculate_injection_slices.py +67 -0
  55. marss2l-0.2.1/tests/test_georeader_utils.py +451 -0
  56. marss2l-0.2.1/tests/test_mixing_ratio_methane.py +378 -0
  57. marss2l-0.2.1/tests/test_plume_detection.py +308 -0
  58. marss2l-0.2.1/tests/test_transmittance_to_ch4.py +641 -0
marss2l-0.2.1/LICENCE ADDED
@@ -0,0 +1,166 @@
1
+
2
+ GNU LESSER GENERAL PUBLIC LICENSE
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+
10
+ This version of the GNU Lesser General Public License incorporates
11
+ the terms and conditions of version 3 of the GNU General Public
12
+ License, supplemented by the additional permissions listed below.
13
+
14
+ 0. Additional Definitions.
15
+
16
+ As used herein, "this License" refers to version 3 of the GNU Lesser
17
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
18
+ General Public License.
19
+
20
+ "The Library" refers to a covered work governed by this License,
21
+ other than an Application or a Combined Work as defined below.
22
+
23
+ An "Application" is any work that makes use of an interface provided
24
+ by the Library, but which is not otherwise based on the Library.
25
+ Defining a subclass of a class defined by the Library is deemed a mode
26
+ of using an interface provided by the Library.
27
+
28
+ A "Combined Work" is a work produced by combining or linking an
29
+ Application with the Library. The particular version of the Library
30
+ with which the Combined Work was made is also called the "Linked
31
+ Version".
32
+
33
+ The "Minimal Corresponding Source" for a Combined Work means the
34
+ Corresponding Source for the Combined Work, excluding any source code
35
+ for portions of the Combined Work that, considered in isolation, are
36
+ based on the Application, and not on the Linked Version.
37
+
38
+ The "Corresponding Application Code" for a Combined Work means the
39
+ object code and/or source code for the Application, including any data
40
+ and utility programs needed for reproducing the Combined Work from the
41
+ Application, but excluding the System Libraries of the Combined Work.
42
+
43
+ 1. Exception to Section 3 of the GNU GPL.
44
+
45
+ You may convey a covered work under sections 3 and 4 of this License
46
+ without being bound by section 3 of the GNU GPL.
47
+
48
+ 2. Conveying Modified Versions.
49
+
50
+ If you modify a copy of the Library, and, in your modifications, a
51
+ facility refers to a function or data to be supplied by an Application
52
+ that uses the facility (other than as an argument passed when the
53
+ facility is invoked), then you may convey a copy of the modified
54
+ version:
55
+
56
+ a) under this License, provided that you make a good faith effort to
57
+ ensure that, in the event an Application does not supply the
58
+ function or data, the facility still operates, and performs
59
+ whatever part of its purpose remains meaningful, or
60
+
61
+ b) under the GNU GPL, with none of the additional permissions of
62
+ this License applicable to that copy.
63
+
64
+ 3. Object Code Incorporating Material from Library Header Files.
65
+
66
+ The object code form of an Application may incorporate material from
67
+ a header file that is part of the Library. You may convey such object
68
+ code under terms of your choice, provided that, if the incorporated
69
+ material is not limited to numerical parameters, data structure
70
+ layouts and accessors, or small macros, inline functions and templates
71
+ (ten or fewer lines in length), you do both of the following:
72
+
73
+ a) Give prominent notice with each copy of the object code that the
74
+ Library is used in it and that the Library and its use are
75
+ covered by this License.
76
+
77
+ b) Accompany the object code with a copy of the GNU GPL and this license
78
+ document.
79
+
80
+ 4. Combined Works.
81
+
82
+ You may convey a Combined Work under terms of your choice that,
83
+ taken together, effectively do not restrict modification of the
84
+ portions of the Library contained in the Combined Work and reverse
85
+ engineering for debugging such modifications, if you also do each of
86
+ the following:
87
+
88
+ a) Give prominent notice with each copy of the Combined Work that
89
+ the Library is used in it and that the Library and its use are
90
+ covered by this License.
91
+
92
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
93
+ document.
94
+
95
+ c) For a Combined Work that displays copyright notices during
96
+ execution, include the copyright notice for the Library among
97
+ these notices, as well as a reference directing the user to the
98
+ copies of the GNU GPL and this license document.
99
+
100
+ d) Do one of the following:
101
+
102
+ 0) Convey the Minimal Corresponding Source under the terms of this
103
+ License, and the Corresponding Application Code in a form
104
+ suitable for, and under terms that permit, the user to
105
+ recombine or relink the Application with a modified version of
106
+ the Linked Version to produce a modified Combined Work, in the
107
+ manner specified by section 6 of the GNU GPL for conveying
108
+ Corresponding Source.
109
+
110
+ 1) Use a suitable shared library mechanism for linking with the
111
+ Library. A suitable mechanism is one that (a) uses at run time
112
+ a copy of the Library already present on the user's computer
113
+ system, and (b) will operate properly with a modified version
114
+ of the Library that is interface-compatible with the Linked
115
+ Version.
116
+
117
+ e) Provide Installation Information, but only if you would otherwise
118
+ be required to provide such information under section 6 of the
119
+ GNU GPL, and only to the extent that such information is
120
+ necessary to install and execute a modified version of the
121
+ Combined Work produced by recombining or relinking the
122
+ Application with a modified version of the Linked Version. (If
123
+ you use option 4d0, the Installation Information must accompany
124
+ the Minimal Corresponding Source and Corresponding Application
125
+ Code. If you use option 4d1, you must provide the Installation
126
+ Information in the manner specified by section 6 of the GNU GPL
127
+ for conveying Corresponding Source.)
128
+
129
+ 5. Combined Libraries.
130
+
131
+ You may place library facilities that are a work based on the
132
+ Library side by side in a single library together with other library
133
+ facilities that are not Applications and are not covered by this
134
+ License, and convey such a combined library under terms of your
135
+ choice, if you do both of the following:
136
+
137
+ a) Accompany the combined library with a copy of the same work based
138
+ on the Library, uncombined with any other library facilities,
139
+ conveyed under the terms of this License.
140
+
141
+ b) Give prominent notice with the combined library that part of it
142
+ is a work based on the Library, and explaining where to find the
143
+ accompanying uncombined form of the same work.
144
+
145
+ 6. Revised Versions of the GNU Lesser General Public License.
146
+
147
+ The Free Software Foundation may publish revised and/or new versions
148
+ of the GNU Lesser General Public License from time to time. Such new
149
+ versions will be similar in spirit to the present version, but may
150
+ differ in detail to address new problems or concerns.
151
+
152
+ Each version is given a distinguishing version number. If the
153
+ Library as you received it specifies that a certain numbered version
154
+ of the GNU Lesser General Public License "or any later version"
155
+ applies to it, you have the option of following the terms and
156
+ conditions either of that published version or of any later version
157
+ published by the Free Software Foundation. If the Library as you
158
+ received it does not specify a version number of the GNU Lesser
159
+ General Public License, you may choose any version of the GNU Lesser
160
+ General Public License ever published by the Free Software Foundation.
161
+
162
+ If the Library as you received it specifies that a proxy can decide
163
+ whether future versions of the GNU Lesser General Public License shall
164
+ apply, that proxy's public statement of acceptance of any version is
165
+ permanent authorization for you to choose that version for the
166
+ Library.
marss2l-0.2.1/PKG-INFO ADDED
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: marss2l
3
+ Version: 0.2.1
4
+ Summary: MARS-S2L Plume detection, segmentation and quantification of methane plumes in Sentinel-2 and Landsat images
5
+ Author: Gonzalo Mateo-García, Anna Vaughan
6
+ License-Expression: LGPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/gonzmg88/marss2l
8
+ Project-URL: Bug Tracker, https://github.com/gonzmg88/marss2l/issues
9
+ Keywords: ch4,methane,remote sensing
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.12
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENCE
14
+ Dynamic: license-file
15
+
16
+ [![MARS-S2L DOI:10.48550/arXiv.2511.21777](https://img.shields.io/badge/MARSS2L%20DOI-10.48550%2FarXiv.2511.21777-blue)](https://doi.org/10.48550/arXiv.2511.21777) [![PyPI](https://img.shields.io/pypi/v/marss2l)](https://pypi.org/project/marss2l/) [![PyPI - License](https://img.shields.io/pypi/l/marss2l)](https://github.com/UNEP-IMEO-MARS/marss2l/blob/main/LICENSE) [![HF](https://img.shields.io/badge/%F0%9F%A4%97-Datasets-yellow)](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L) [![HF](https://img.shields.io/badge/%F0%9F%A4%97-Models-yellow)](https://huggingface.co/UNEP-IMEO/MARS-S2L)
17
+
18
+ # <img src="./notebooks/logo.png" alt="Logo" width='7%'> MARS-S2L
19
+
20
+ This package contains the operational UNEP International Methane Emissions Observatory (IMEO) pipeline for methane plume detection, segmentation, and quantification in Sentinel-2 and Landsat satellite imagery. The methods and models implemented in this package are described in:
21
+
22
+ > Allen, Mateo-García, Irakulis-Loitxate et al., *Artificial intelligence for methane detection: from continuous monitoring to verified mitigation* [10.48550/arXiv.2511.21777](https://arxiv.org/abs/2511.21777)
23
+
24
+ ### Licence
25
+
26
+ The MARS-S2L database and all trained models are released under a [Creative Commons Non-Commercial Share-Alike licence](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt). The code in this package is published under a [GNU Lesser GPL v3 licence](https://www.gnu.org/licenses/lgpl-3.0.en.html).
27
+
28
+ ## Install
29
+
30
+ Create the `marss2lpy312` virtual environment with conda:
31
+
32
+ ```bash
33
+ conda env create -f environment/conda_vm.yaml
34
+ ```
35
+
36
+ Install `marss2l` package:
37
+
38
+ ```bash
39
+ pip install marss2l
40
+ ```
41
+
42
+ ## *End-to-end* inference [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/UNEP-IMEO-MARS/marss2l/blob/main/notebooks/examples/download_and_inference.ipynb)
43
+
44
+ [This tutorial](./notebooks/examples/download_and_inference.ipynb) demonstrates an *end-to-end* example of the UNEP IMEO pipeline for detecting methane plumes in Sentinel‑2 and Landsat imagery. It downloads, compute the multi-band, multi-pass (MBMP, [Irakullis‑Loitxate et al., 2022](https://doi.org/10.1021/acs.est.1c04873)) retrieval, run inference with the MARS-S2L model ([Allen et al., 2025](https://arxiv.org/abs/2511.21777)), quantify the retrieval ΔXCH₄ and estimate the flux rate of detected plumes ([Gorroño et al., 2023](https://amt.copernicus.org/articles/16/89/2023/)).
45
+
46
+ **Important considerations:**
47
+
48
+ - The MARS‑S2L model produce false positives.
49
+ - Therefore any positive model output must be validated before its use.
50
+ - <u>**At UNEP IMEO, all plumes are manually validated by at least two independent remote sensing analysts before their publication.**</u>
51
+
52
+ ## Dataset [🤗](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L)
53
+
54
+ The MARS-S2L database and all trained models are released under a [Creative Commons Non-Commercial Share-Alike licence](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt).
55
+
56
+ Currently the dataset is publicly available in this Hugging-Face🤗 repo: [UNEP-IMEO/MARS-S2L](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L).
57
+
58
+ To download the entire dataset and trained models (~100GB) run:
59
+
60
+ ```bash
61
+ hf download --local-dir /path/to/localdir/MARS-S2L \
62
+ --repo-type dataset UNEP-IMEO/MARS-S2L
63
+ ```
64
+
65
+ The following notebooks show how to load and plot images using the `torch.Dataset` directly from the Hugging Face repository: [`notebooks/examples/plot_images_dataset_train.ipynb`](./notebooks/examples/plot_images_dataset_train.ipynb) and [`notebooks/examples/plot_plumes_dataset_test.ipynb`](./notebooks/examples/plot_plumes_dataset_test.ipynb).
66
+
67
+ ## Retrain the MARS-S2L model
68
+
69
+ We trained the model on a A100 GPU with 80Gb RAM. In order to re-train the proposed model and the baseline run:
70
+
71
+ ```bash
72
+ wandb init # select the wandb project to display the training metrics
73
+ python -m marss2l.reproduce_training --csv_path /path/to/dataset/validated_images_all.csv\
74
+ --batch_size 128 --num_workers 16 --num_workers_val 8\
75
+ --batch_size_val 256 --n_samples_per_epoch_train 65536\
76
+ --basename_dir train_logs # Where to store the training outputs
77
+ ```
78
+
79
+ This code will train 4 models the proposed MARS-S2L model and the CH4Net model both trained on the train split of the dataset. In addition it will evaluate these models in the test split of the dataset. After the training the content of the `--basename_dir` folder should be:
80
+
81
+ ```
82
+ train_logs/
83
+ ├── marss2l
84
+ │   ├── best_epoch
85
+ │   ├── config_experiment.json
86
+ │   └── preds_test_2023.csv
87
+ ├── ch4net
88
+ │   ├── best_epoch
89
+ │   ├── config_experiment.json
90
+ │   └── preds_test_2023.csv
91
+ ├── ch4net_sim
92
+ │   ├── best_epoch
93
+ │   ├── config_experiment.json
94
+ │   └── preds_test_2023.csv
95
+ └── marss2l_nosim
96
+    ├── best_epoch
97
+    ├── config_experiment.json
98
+    └── preds_test_2023.csv
99
+
100
+ ```
101
+
102
+ Where:
103
+ * `best_epoch` are the weights of the trained model
104
+ * `config_experiment.json` is the metadata with the configuration of the experiment
105
+ * `preds_test_2023.csv` are the model predictions for all entries in the test set
106
+
107
+
108
+ ## Reproduce the figures
109
+
110
+ In the folder `notebooks/figures` there is the code to reproduce most of the figures of the paper. These notebooks read the data directly from the Hugging Face repository. See [this README](./notebooks/figures/README.md).
111
+
112
+ ## Load and eval trained models
113
+
114
+ The MARS-S2L model of the paper is stored in this [Hugging-Face🤗 repository](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L) in the *trained_models* folder. The files are stored following the same naming convention as described above.
115
+
116
+ In order to re-run the evaluation in the test set with the trained model proposed see [this README](./notebooks/figures/README.md).
117
+
118
+ ## Dataset structure
119
+
120
+ The file [`validated_images_all.csv`](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L/blob/main/validated_images_all.csv) contains the metadata of all the items in the dataset. Each item comprises a Sentinel-2 or Landsat image of 200x200 pixels
121
+ together with its concatenated background image and the cloud mask. The methane enhancement image (ΔXCH₄) in ppb is also provided for positive samples. For positive samples, a vector multipolygon with the extent of the plume in WKT format is provided. In addition, each item
122
+ includes several metadata described in the next section. (*Images metadata description*).
123
+
124
+ The file [`validated_images_plumes.csv`](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L/blob/main/validated_images_plumes.csv) contains all validated plumes in the dataset. Notice that there are few images that contain more than one plume.
125
+ The content of this file is described in the *Plumes metadata description* section.
126
+
127
+ ### Images metadata description
128
+
129
+ Column description of file [`validated_images_all.csv`](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L/blob/main/validated_images_all.csv):
130
+
131
+ | Name | Description | Example |
132
+ | ------------- | ------------- | -------- |
133
+ |s2path| Path to S2 or Landsat image concatenated with the background image. S2 L1C image with bands: B02, B03, B04, B08, B11, B12. Landsat TOA reflectance image with bands B02, B03, B04, B05, B06, B07 | data/train_2023/43/b82be820-fe9c-411a-af20-82cf162760a7_ea782bfb-21b6-46c5-a6ed-d3b8ef8815a0_s2.tif |
134
+ |cloudmaskpath| Path to cloud mask generated with CloudSEN12 with interpretation `{0 : "clear", 1: "Thick cloud", 2: "Thin cloud", 3: "Cloud shadow"}` | data/train_2023/43/b82be820-fe9c-411a-af20-82cf162760a7_ea782bfb-21b6-46c5-a6ed-d3b8ef8815a0_cloudmask.tif |
135
+ |ch4path| Path to the ΔXCH₄ enhancement image in ppb. Only provided for positive samples (`isplume` `True`). | data/train_2023/43/b82be820-fe9c-411a-af20-82cf162760a7_ea782bfb-21b6-46c5-a6ed-d3b8ef8815a0_ch4.tif |
136
+ |wind_u| U component of the wind at 10m | -1.87 |
137
+ |wind_v| V component of the wind at 10m | 3.76 |
138
+ |wind_source| Source where the wind data is downloaded from. | ECMWF/ERA5_LAND/HOURLY |
139
+ |vza| Viewing zenith angle. | 5.40 |
140
+ |sza| Solar zenith angle. | 16.32 |
141
+ |percentage_clear| Percentage of pixels clear according to CloudSEN12 mask. | 100.0 |
142
+ |tile| Name of the S2 or Landsat product | S2A_MSIL1C_20240613T100031_N0510_R122_T32RNS_20240613T134114 or LC08_L1TP_192040_20190601_20200828_02_T1 |
143
+ |isplume| Whether there is a methane plume on the image or not | True |
144
+ |ch4_fluxrate| Flux rate in kg/h if there is a plume in the tile. | 7756.50 |
145
+ |ch4_fluxrate_std| Standard deviation of the fluxrate. | 2941.19 |
146
+ |satellite| Name of the satellite | S2A, S2B, LC08 or LC09 |
147
+ |tile_date| Date of acquisition | 2024-06-13 10:00:31+00:00 |
148
+ |notified| If the image contains a plume, whether the plume was notified or not | False |
149
+ |id_location| UUID of the site | b82be820-fe9c-411a-af20-82cf162760a7 |
150
+ |last_update| Last time this registry was modified | 2025-05-20 10:00:31+00:00 |
151
+ |location_name| Code of the location. | A_10 |
152
+ |country| Country of the location | Algeria |
153
+ |lon| Longitude of the center of the location | 9.783133 |
154
+ |lat| Latitude of the center of the location | 28.087894 |
155
+ |offshore| Whether the location is offshore or onshore. | False |
156
+ |sector| Sector of the observation | Oil and Gas, Coal, Waste or Unknown |
157
+ |observability| Given observability to the image. Clear and cloudy is computed automatically with the cloudmask (50% threshold). Additionally the analyst can change this category (e.g. if the cloudmask is not correct or if there're artifacts in the scene such as snow, smoke, shadows...). | clear, cloudy, bad_retrieval, smoke, shadow, snow, out_of_swath |
158
+ |background_image_tile| Name of the S2 or Landsat product used as background. | S2A_MSIL1C_20240603T100031_N0510_R122_T32RNS_20240603T134002 |
159
+ |crs| Coordinate reference system of the image | EPSG:32632 |
160
+ |transform_a| Geotransform of the image | 10.0 |
161
+ |transform_b| Geotransform of the image | 0.0 |
162
+ |transform_c| Geotransform of the image | 575940.0 |
163
+ |transform_d| Geotransform of the image | 0.0 |
164
+ |transform_e| Geotransform of the image | -10.0 |
165
+ |transform_f| Geotransform of the image | 3108180.0 |
166
+ |width| Width of the image | 200 |
167
+ |height| Height of the image | 200 |
168
+ |window_row_off| Top left row of the location of the plume within the image (used for the simulation). | 0.0 |
169
+ |window_col_off| Top left column of the location of the plume within the image (used for the simulation). | 62.0 |
170
+ |window_height| Height in pixels of the plume within the image (used for the simulation). | 101.0 |
171
+ |window_width| Width in pixels of the plume within the image (used for the simulation). | 46.0 |
172
+ |id_loc_image| Id of the image | ea782bfb-21b6-46c5-a6ed-d3b8ef8815a0 |
173
+ |plume| Vector WKT representation of the plume. | MULTIPOLYGON (((9.781389 28.090856, 9.781646 28.090288, 9.781861 28.089796, 9.781818 28.089134, 9.781989 28.088622, 9.782268 28.088187, 9.782633 28.087903, 9.783105 28.087865, 9.783362 28.088244, 9.783083 28.088774, 9.78304 28.089436, 9.783148 28.090061, 9.783384 28.090705, 9.783663 28.091424, 9.783856 28.092522, 9.783642 28.093299, 9.783234 28.093905, 9.783106 28.094794, 9.783041 28.095571, 9.782312 28.096195, 9.78154 28.096422, 9.780896 28.096934, 9.779888 28.097104, 9.779352 28.096915, 9.779759 28.096063, 9.780596 28.09523, 9.781132 28.094472, 9.780896 28.093867, 9.780896 28.09309, 9.781154 28.092314, 9.781239 28.091784, 9.781154 28.091292, 9.781389 28.090856))) |
174
+ |footprint| Vector WKT representation of the footprint of the image | POLYGON ((9.772934575210368 28.09701036650939, 9.7728039936767 28.07877712456095, 9.793361656935707 28.07865982254285, 9.7934957112434 28.09689297500473, 9.772934575210368 28.09701036650939)) |
175
+ |split_name| Name of the split the item belongs to. One of 'train_2023', 'test_2023', 'val_2023' or 'Not Used' | 'train_2023' |
176
+ |case_study | Case study area of the same. | Turkmenistan |
177
+
178
+ ### Plumes metadata description
179
+
180
+ Column description of file [`validated_images_plumes.csv`](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L/blob/main/validated_images_plumes.csv).
181
+
182
+ | Name | Description | Example |
183
+ | ------------- | ------------- | -------- |
184
+ |id_plume | UUID of the plume | 652fd72a-4a24-4938-8646-84309f899914|
185
+ |id_loc_image | UUID of its corresponding image | 37ecaefe-619e-4dc7-90f1-d57bd48dbf0f|
186
+ |tile| Name of the S2 or Landsat product | S2A_MSIL1C_20240613T100031_N0510_R122_T32RNS_20240613T134114 or LC08_L1TP_192040_20190601_20200828_02_T1 |
187
+ |tile_date| Date of acquisition | 2024-06-13 10:00:31+00:00 |
188
+ |satellite| Name of the satellite | S2A, S2B, LC08 or LC09 |
189
+ |lat | Latitude of the source of the plume | 28.088329877970512|
190
+ |lon | Longitude of the source of the plume | 9.78350881586494|
191
+ |ch4_fluxrate | Estimated flux rate of the plume in kg/h | 9639.58562343052|
192
+ |ch4_fluxrate_std | Estimated std of the flux rate of the plume in kg/h | 3964.424919968837|
193
+ |geometry | Plume shape | MULTIPOLYGON (((9.782459 28.090423, 9.782716 28.089211, 9.782802 28.088378, 9.783746 28.088151, 9.78396 28.089249, 9.784217 28.090953, 9.784475 28.092316, 9.784432 28.093528, 9.783788 28.095156, 9.782802 28.095383, 9.78293 28.09402, 9.782716 28.093339, 9.782201 28.092203, 9.782416 28.09118, 9.782459 28.090423)))|
194
+ |last_update | Last time this registry was updated | 2025-05-19 05:30:16.151729+00:00|
195
+ |window_row_off | Pixel upper left row coordinate within the image where the plume is located | 15|
196
+ |window_col_off | Pixel upper left column coordinate within the image where the plume is located | 88|
197
+ |window_height | Number of columns from the upper left coordinate | 82|
198
+ |window_width | Number of rows from the upper left coordinate | 25|
199
+
200
+ ## Licence
201
+
202
+ The MARS-S2L database, all trained models and tutorials are released under a [Creative Commons Non-Commercial Share-Alike licence](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt).
203
+
204
+ The code in this package is published under a [GNU Lesser GPL v3 licence](https://www.gnu.org/licenses/lgpl-3.0.en.html) <img src="https://www.gnu.org/graphics/lgplv3-88x31.png" alt="licence" width="80">.
205
+
206
+ ## Cite
207
+ If you find this work useful, please cite:
208
+
209
+ ```bibtex
210
+ @article{allen_2025,
211
+ title = {Artificial intelligence for methane detection: from continuous monitoring to verified mitigation},
212
+ author = {Allen, Anna and Mateo-Garcia, Gonzalo and Irakulis-Loitxate, Itziar and Martin, Manuel Montesino-San and Watine, Marc and Requeima, James and Gorroño, Javier and Randles, Cynthia and Mokalled, Tharwat and Guanter, Luis and Turner, Richard E. and Cifarelli, Claudio and Caltagirone, Manfredi},
213
+ url = {http://arxiv.org/abs/2511.21777},
214
+ doi = {10.48550/arXiv.2511.21777},
215
+ month = nov,
216
+ year = {2025}
217
+ }
218
+ ```
219
+
@@ -0,0 +1,204 @@
1
+ [![MARS-S2L DOI:10.48550/arXiv.2511.21777](https://img.shields.io/badge/MARSS2L%20DOI-10.48550%2FarXiv.2511.21777-blue)](https://doi.org/10.48550/arXiv.2511.21777) [![PyPI](https://img.shields.io/pypi/v/marss2l)](https://pypi.org/project/marss2l/) [![PyPI - License](https://img.shields.io/pypi/l/marss2l)](https://github.com/UNEP-IMEO-MARS/marss2l/blob/main/LICENSE) [![HF](https://img.shields.io/badge/%F0%9F%A4%97-Datasets-yellow)](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L) [![HF](https://img.shields.io/badge/%F0%9F%A4%97-Models-yellow)](https://huggingface.co/UNEP-IMEO/MARS-S2L)
2
+
3
+ # <img src="./notebooks/logo.png" alt="Logo" width='7%'> MARS-S2L
4
+
5
+ This package contains the operational UNEP International Methane Emissions Observatory (IMEO) pipeline for methane plume detection, segmentation, and quantification in Sentinel-2 and Landsat satellite imagery. The methods and models implemented in this package are described in:
6
+
7
+ > Allen, Mateo-García, Irakulis-Loitxate et al., *Artificial intelligence for methane detection: from continuous monitoring to verified mitigation* [10.48550/arXiv.2511.21777](https://arxiv.org/abs/2511.21777)
8
+
9
+ ### Licence
10
+
11
+ The MARS-S2L database and all trained models are released under a [Creative Commons Non-Commercial Share-Alike licence](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt). The code in this package is published under a [GNU Lesser GPL v3 licence](https://www.gnu.org/licenses/lgpl-3.0.en.html).
12
+
13
+ ## Install
14
+
15
+ Create the `marss2lpy312` virtual environment with conda:
16
+
17
+ ```bash
18
+ conda env create -f environment/conda_vm.yaml
19
+ ```
20
+
21
+ Install `marss2l` package:
22
+
23
+ ```bash
24
+ pip install marss2l
25
+ ```
26
+
27
+ ## *End-to-end* inference [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/UNEP-IMEO-MARS/marss2l/blob/main/notebooks/examples/download_and_inference.ipynb)
28
+
29
+ [This tutorial](./notebooks/examples/download_and_inference.ipynb) demonstrates an *end-to-end* example of the UNEP IMEO pipeline for detecting methane plumes in Sentinel‑2 and Landsat imagery. It downloads, compute the multi-band, multi-pass (MBMP, [Irakullis‑Loitxate et al., 2022](https://doi.org/10.1021/acs.est.1c04873)) retrieval, run inference with the MARS-S2L model ([Allen et al., 2025](https://arxiv.org/abs/2511.21777)), quantify the retrieval ΔXCH₄ and estimate the flux rate of detected plumes ([Gorroño et al., 2023](https://amt.copernicus.org/articles/16/89/2023/)).
30
+
31
+ **Important considerations:**
32
+
33
+ - The MARS‑S2L model produce false positives.
34
+ - Therefore any positive model output must be validated before its use.
35
+ - <u>**At UNEP IMEO, all plumes are manually validated by at least two independent remote sensing analysts before their publication.**</u>
36
+
37
+ ## Dataset [🤗](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L)
38
+
39
+ The MARS-S2L database and all trained models are released under a [Creative Commons Non-Commercial Share-Alike licence](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt).
40
+
41
+ Currently the dataset is publicly available in this Hugging-Face🤗 repo: [UNEP-IMEO/MARS-S2L](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L).
42
+
43
+ To download the entire dataset and trained models (~100GB) run:
44
+
45
+ ```bash
46
+ hf download --local-dir /path/to/localdir/MARS-S2L \
47
+ --repo-type dataset UNEP-IMEO/MARS-S2L
48
+ ```
49
+
50
+ The following notebooks show how to load and plot images using the `torch.Dataset` directly from the Hugging Face repository: [`notebooks/examples/plot_images_dataset_train.ipynb`](./notebooks/examples/plot_images_dataset_train.ipynb) and [`notebooks/examples/plot_plumes_dataset_test.ipynb`](./notebooks/examples/plot_plumes_dataset_test.ipynb).
51
+
52
+ ## Retrain the MARS-S2L model
53
+
54
+ We trained the model on a A100 GPU with 80Gb RAM. In order to re-train the proposed model and the baseline run:
55
+
56
+ ```bash
57
+ wandb init # select the wandb project to display the training metrics
58
+ python -m marss2l.reproduce_training --csv_path /path/to/dataset/validated_images_all.csv\
59
+ --batch_size 128 --num_workers 16 --num_workers_val 8\
60
+ --batch_size_val 256 --n_samples_per_epoch_train 65536\
61
+ --basename_dir train_logs # Where to store the training outputs
62
+ ```
63
+
64
+ This code will train 4 models the proposed MARS-S2L model and the CH4Net model both trained on the train split of the dataset. In addition it will evaluate these models in the test split of the dataset. After the training the content of the `--basename_dir` folder should be:
65
+
66
+ ```
67
+ train_logs/
68
+ ├── marss2l
69
+ │   ├── best_epoch
70
+ │   ├── config_experiment.json
71
+ │   └── preds_test_2023.csv
72
+ ├── ch4net
73
+ │   ├── best_epoch
74
+ │   ├── config_experiment.json
75
+ │   └── preds_test_2023.csv
76
+ ├── ch4net_sim
77
+ │   ├── best_epoch
78
+ │   ├── config_experiment.json
79
+ │   └── preds_test_2023.csv
80
+ └── marss2l_nosim
81
+    ├── best_epoch
82
+    ├── config_experiment.json
83
+    └── preds_test_2023.csv
84
+
85
+ ```
86
+
87
+ Where:
88
+ * `best_epoch` are the weights of the trained model
89
+ * `config_experiment.json` is the metadata with the configuration of the experiment
90
+ * `preds_test_2023.csv` are the model predictions for all entries in the test set
91
+
92
+
93
+ ## Reproduce the figures
94
+
95
+ In the folder `notebooks/figures` there is the code to reproduce most of the figures of the paper. These notebooks read the data directly from the Hugging Face repository. See [this README](./notebooks/figures/README.md).
96
+
97
+ ## Load and eval trained models
98
+
99
+ The MARS-S2L model of the paper is stored in this [Hugging-Face🤗 repository](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L) in the *trained_models* folder. The files are stored following the same naming convention as described above.
100
+
101
+ In order to re-run the evaluation in the test set with the trained model proposed see [this README](./notebooks/figures/README.md).
102
+
103
+ ## Dataset structure
104
+
105
+ The file [`validated_images_all.csv`](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L/blob/main/validated_images_all.csv) contains the metadata of all the items in the dataset. Each item comprises a Sentinel-2 or Landsat image of 200x200 pixels
106
+ together with its concatenated background image and the cloud mask. The methane enhancement image (ΔXCH₄) in ppb is also provided for positive samples. For positive samples, a vector multipolygon with the extent of the plume in WKT format is provided. In addition, each item
107
+ includes several metadata described in the next section. (*Images metadata description*).
108
+
109
+ The file [`validated_images_plumes.csv`](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L/blob/main/validated_images_plumes.csv) contains all validated plumes in the dataset. Notice that there are few images that contain more than one plume.
110
+ The content of this file is described in the *Plumes metadata description* section.
111
+
112
+ ### Images metadata description
113
+
114
+ Column description of file [`validated_images_all.csv`](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L/blob/main/validated_images_all.csv):
115
+
116
+ | Name | Description | Example |
117
+ | ------------- | ------------- | -------- |
118
+ |s2path| Path to S2 or Landsat image concatenated with the background image. S2 L1C image with bands: B02, B03, B04, B08, B11, B12. Landsat TOA reflectance image with bands B02, B03, B04, B05, B06, B07 | data/train_2023/43/b82be820-fe9c-411a-af20-82cf162760a7_ea782bfb-21b6-46c5-a6ed-d3b8ef8815a0_s2.tif |
119
+ |cloudmaskpath| Path to cloud mask generated with CloudSEN12 with interpretation `{0 : "clear", 1: "Thick cloud", 2: "Thin cloud", 3: "Cloud shadow"}` | data/train_2023/43/b82be820-fe9c-411a-af20-82cf162760a7_ea782bfb-21b6-46c5-a6ed-d3b8ef8815a0_cloudmask.tif |
120
+ |ch4path| Path to the ΔXCH₄ enhancement image in ppb. Only provided for positive samples (`isplume` `True`). | data/train_2023/43/b82be820-fe9c-411a-af20-82cf162760a7_ea782bfb-21b6-46c5-a6ed-d3b8ef8815a0_ch4.tif |
121
+ |wind_u| U component of the wind at 10m | -1.87 |
122
+ |wind_v| V component of the wind at 10m | 3.76 |
123
+ |wind_source| Source where the wind data is downloaded from. | ECMWF/ERA5_LAND/HOURLY |
124
+ |vza| Viewing zenith angle. | 5.40 |
125
+ |sza| Solar zenith angle. | 16.32 |
126
+ |percentage_clear| Percentage of pixels clear according to CloudSEN12 mask. | 100.0 |
127
+ |tile| Name of the S2 or Landsat product | S2A_MSIL1C_20240613T100031_N0510_R122_T32RNS_20240613T134114 or LC08_L1TP_192040_20190601_20200828_02_T1 |
128
+ |isplume| Whether there is a methane plume on the image or not | True |
129
+ |ch4_fluxrate| Flux rate in kg/h if there is a plume in the tile. | 7756.50 |
130
+ |ch4_fluxrate_std| Standard deviation of the fluxrate. | 2941.19 |
131
+ |satellite| Name of the satellite | S2A, S2B, LC08 or LC09 |
132
+ |tile_date| Date of acquisition | 2024-06-13 10:00:31+00:00 |
133
+ |notified| If the image contains a plume, whether the plume was notified or not | False |
134
+ |id_location| UUID of the site | b82be820-fe9c-411a-af20-82cf162760a7 |
135
+ |last_update| Last time this registry was modified | 2025-05-20 10:00:31+00:00 |
136
+ |location_name| Code of the location. | A_10 |
137
+ |country| Country of the location | Algeria |
138
+ |lon| Longitude of the center of the location | 9.783133 |
139
+ |lat| Latitude of the center of the location | 28.087894 |
140
+ |offshore| Whether the location is offshore or onshore. | False |
141
+ |sector| Sector of the observation | Oil and Gas, Coal, Waste or Unknown |
142
+ |observability| Given observability to the image. Clear and cloudy is computed automatically with the cloudmask (50% threshold). Additionally the analyst can change this category (e.g. if the cloudmask is not correct or if there're artifacts in the scene such as snow, smoke, shadows...). | clear, cloudy, bad_retrieval, smoke, shadow, snow, out_of_swath |
143
+ |background_image_tile| Name of the S2 or Landsat product used as background. | S2A_MSIL1C_20240603T100031_N0510_R122_T32RNS_20240603T134002 |
144
+ |crs| Coordinate reference system of the image | EPSG:32632 |
145
+ |transform_a| Geotransform of the image | 10.0 |
146
+ |transform_b| Geotransform of the image | 0.0 |
147
+ |transform_c| Geotransform of the image | 575940.0 |
148
+ |transform_d| Geotransform of the image | 0.0 |
149
+ |transform_e| Geotransform of the image | -10.0 |
150
+ |transform_f| Geotransform of the image | 3108180.0 |
151
+ |width| Width of the image | 200 |
152
+ |height| Height of the image | 200 |
153
+ |window_row_off| Top left row of the location of the plume within the image (used for the simulation). | 0.0 |
154
+ |window_col_off| Top left column of the location of the plume within the image (used for the simulation). | 62.0 |
155
+ |window_height| Height in pixels of the plume within the image (used for the simulation). | 101.0 |
156
+ |window_width| Width in pixels of the plume within the image (used for the simulation). | 46.0 |
157
+ |id_loc_image| Id of the image | ea782bfb-21b6-46c5-a6ed-d3b8ef8815a0 |
158
+ |plume| Vector WKT representation of the plume. | MULTIPOLYGON (((9.781389 28.090856, 9.781646 28.090288, 9.781861 28.089796, 9.781818 28.089134, 9.781989 28.088622, 9.782268 28.088187, 9.782633 28.087903, 9.783105 28.087865, 9.783362 28.088244, 9.783083 28.088774, 9.78304 28.089436, 9.783148 28.090061, 9.783384 28.090705, 9.783663 28.091424, 9.783856 28.092522, 9.783642 28.093299, 9.783234 28.093905, 9.783106 28.094794, 9.783041 28.095571, 9.782312 28.096195, 9.78154 28.096422, 9.780896 28.096934, 9.779888 28.097104, 9.779352 28.096915, 9.779759 28.096063, 9.780596 28.09523, 9.781132 28.094472, 9.780896 28.093867, 9.780896 28.09309, 9.781154 28.092314, 9.781239 28.091784, 9.781154 28.091292, 9.781389 28.090856))) |
159
+ |footprint| Vector WKT representation of the footprint of the image | POLYGON ((9.772934575210368 28.09701036650939, 9.7728039936767 28.07877712456095, 9.793361656935707 28.07865982254285, 9.7934957112434 28.09689297500473, 9.772934575210368 28.09701036650939)) |
160
+ |split_name| Name of the split the item belongs to. One of 'train_2023', 'test_2023', 'val_2023' or 'Not Used' | 'train_2023' |
161
+ |case_study | Case study area of the same. | Turkmenistan |
162
+
163
+ ### Plumes metadata description
164
+
165
+ Column description of file [`validated_images_plumes.csv`](https://huggingface.co/datasets/UNEP-IMEO/MARS-S2L/blob/main/validated_images_plumes.csv).
166
+
167
+ | Name | Description | Example |
168
+ | ------------- | ------------- | -------- |
169
+ |id_plume | UUID of the plume | 652fd72a-4a24-4938-8646-84309f899914|
170
+ |id_loc_image | UUID of its corresponding image | 37ecaefe-619e-4dc7-90f1-d57bd48dbf0f|
171
+ |tile| Name of the S2 or Landsat product | S2A_MSIL1C_20240613T100031_N0510_R122_T32RNS_20240613T134114 or LC08_L1TP_192040_20190601_20200828_02_T1 |
172
+ |tile_date| Date of acquisition | 2024-06-13 10:00:31+00:00 |
173
+ |satellite| Name of the satellite | S2A, S2B, LC08 or LC09 |
174
+ |lat | Latitude of the source of the plume | 28.088329877970512|
175
+ |lon | Longitude of the source of the plume | 9.78350881586494|
176
+ |ch4_fluxrate | Estimated flux rate of the plume in kg/h | 9639.58562343052|
177
+ |ch4_fluxrate_std | Estimated std of the flux rate of the plume in kg/h | 3964.424919968837|
178
+ |geometry | Plume shape | MULTIPOLYGON (((9.782459 28.090423, 9.782716 28.089211, 9.782802 28.088378, 9.783746 28.088151, 9.78396 28.089249, 9.784217 28.090953, 9.784475 28.092316, 9.784432 28.093528, 9.783788 28.095156, 9.782802 28.095383, 9.78293 28.09402, 9.782716 28.093339, 9.782201 28.092203, 9.782416 28.09118, 9.782459 28.090423)))|
179
+ |last_update | Last time this registry was updated | 2025-05-19 05:30:16.151729+00:00|
180
+ |window_row_off | Pixel upper left row coordinate within the image where the plume is located | 15|
181
+ |window_col_off | Pixel upper left column coordinate within the image where the plume is located | 88|
182
+ |window_height | Number of columns from the upper left coordinate | 82|
183
+ |window_width | Number of rows from the upper left coordinate | 25|
184
+
185
+ ## Licence
186
+
187
+ The MARS-S2L database, all trained models and tutorials are released under a [Creative Commons Non-Commercial Share-Alike licence](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt).
188
+
189
+ The code in this package is published under a [GNU Lesser GPL v3 licence](https://www.gnu.org/licenses/lgpl-3.0.en.html) <img src="https://www.gnu.org/graphics/lgplv3-88x31.png" alt="licence" width="80">.
190
+
191
+ ## Cite
192
+ If you find this work useful, please cite:
193
+
194
+ ```bibtex
195
+ @article{allen_2025,
196
+ title = {Artificial intelligence for methane detection: from continuous monitoring to verified mitigation},
197
+ author = {Allen, Anna and Mateo-Garcia, Gonzalo and Irakulis-Loitxate, Itziar and Martin, Manuel Montesino-San and Watine, Marc and Requeima, James and Gorroño, Javier and Randles, Cynthia and Mokalled, Tharwat and Guanter, Luis and Turner, Richard E. and Cifarelli, Claudio and Caltagirone, Manfredi},
198
+ url = {http://arxiv.org/abs/2511.21777},
199
+ doi = {10.48550/arXiv.2511.21777},
200
+ month = nov,
201
+ year = {2025}
202
+ }
203
+ ```
204
+
@@ -0,0 +1 @@
1
+ __version__ = "0.2.1"