Skip to content

Commit bf65b85

Browse files
Merge pull request #3 from LorenzoStucchi/full-auto
Full auto methodology
2 parents 2599a7d + 11d3d0b commit bf65b85

13 files changed

+153
-52
lines changed

README.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Automatization of the SEN-et SNAP plugin for multi-temporal analysis
22
## Description
33

4-
The [SEN-ET project](https://www.esa-sen4et.org/) has been founded for ESA with the main object to "develop an optimal methodology for estimating evapotranspiration at fine (tens of meters) spatial scale, based on synergistic use of Sentinel 2 and Sentinel 3 satellites’ observations" as reported by the website of the project.
4+
The [SEN-ET project](https://www.esa-sen4et.org/) has been founded for ESA with the main object to *"develop an optimal methodology for estimating evapotranspiration at fine (tens of meters) spatial scale, based on synergistic use of Sentinel 2 and Sentinel 3 satellites’ observations"* as reported by the website of the project.
55

6-
The plugin is mainly thought for use inside SNAP, so a manual operation where the user has to make the different operations manually. However, also the python script for the operation have been released.
6+
The plugin is mainly thought for use inside SNAP, so a manual operation where the user has to make the different operations manually. However, also the python scripts for the operation have been released.
77
The scope of this repository is to create the possibility to automatize the process, allowing the computation of multiple days without the manual input of the operator. So, it is possible to compute monthly means on an area of interest.
88

99
The original schema for the plugin is represented in the image below:
@@ -12,14 +12,36 @@ The original schema for the plugin is represented in the image below:
1212

1313
The automation process reduces it to one step and presents this schema:
1414

15-
![New short sen-et](assets/new_one_step.png)
15+
![New short sen-et](assets/new_full.png)
1616

1717
## Installation
1818
It is needed to have installed SNAP (with Python 3.6) and the [SEN-ET plugin](https://www.esa-sen4et.org/static/media/Sen-ET-plugin-v1.0.1.b41ae6c8.zip) as indicated in the [official plugin documentation](https://www.esa-sen4et.org/static/media/sen-et-user-manual-v1.1.0.5d1ac526.pdf) in Section 3.2. In case of troubleshooting, see Section 3.4.
1919

20-
The test that everything is working will be the download of the ERA5 Data in the next step.
20+
The suggested version of python to be used for Windows is the 3.6.8, it should be download before the installation of SNAP. The installer could installed [here](https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe).
2121

22-
It is also needed for Windows computers to install the Git Bash terminal provided with the installation of [Git](https://git-scm.com/downloads).
22+
At the first start, it is needed to run an operator to complete the bundle installation as indicated in the documentation:
23+
24+
*The first time any of the Sen-ET operators is run the user will receive a SNAP - Warning message about path not existing. After clicking OK another dialog will appear asking user if they want to proceed with bundle download/installation (Figure 3.4). After clicking "Yes" the download and installation of the plugin bundle (the self-contained Python environment) will happen automatically. When the bundle installation finishes, a message will notify of the successful installation of the bundle. The Sen-ET SNAP plugin is installed and ready for use.*
25+
26+
The installation and the test that everything is working will be done in the step of the download of the ERA5 Data. This will be later explained.
27+
28+
For Windows computers, it is also needed to install the Git Bash terminal provided with the installation of [Git](https://git-scm.com/downloads).
29+
30+
Download the code in the terminal with
31+
```
32+
git clone https://github.com/LorenzoStucchi/SEN-ET_automatization.git
33+
```
34+
35+
### Python for generating scripts
36+
For the automatization of the project, it is needed to have python installed on the computer. Also, these libraries are needed:
37+
- xarray
38+
- netcdf4
39+
- h5netcdf
40+
41+
It is possible and recommended to use conda to create the environment with all the dependencies with the command:
42+
```
43+
conda env create -f env.yml
44+
```
2345

2446
## Data download
2547
### ECMWF Reanalysis v5 (ERA5) Data
@@ -43,7 +65,7 @@ The images request needs to be of the product type:
4365
That option could be added in the filters, zoom to the area of interest and drawn a rectangular in the area. Open the filter panel and add in the sensing date, the timespan of interest for your analysis, and the desired timespan. Using the preview, it is also possible to check the cloud coverage visually.
4466

4567
### Folder structure
46-
Once the data are downloaded, it is needed to organize them in a specific way. An analysis of the data for one month will produce products for around 500 GB. The main folder that could be named as prefered, in the schema below `MAIN_FOLDER`. One folder for each type of data called `era`, `S2` and `S3`. Inside the `S2` and `S3` folders, a folder for each of the days of the images, the folder should be named in this format `YYYY_MM_DD`.
68+
Once the data are downloaded, it is needed to organize them in a specific way. An analysis of the data for one month will produce products for around 500 GB. The main folder that could be named as preferred, in the schema below `MAIN_FOLDER`. One folder for each type of data is called `era`, `S2` and `S3`. Inside the `S2` and `S3` folders, a folder for each of the days of the images, the folder should be named in this format `YYYY_MM_DD`.
4769

4870
Once the structure has been created, the `era5.nc` and the images should be moved to the correct folder. Also, it is needed to unzip the images.
4971
As example:
@@ -88,25 +110,31 @@ MAIN_FOLDER
88110
Set the parameters in the file [`parameters.json`](input/parameters.json):
89111
- Set the coordinates of the Area Of Interest (AOI), which could be the portion of the Sentinel 2 images or a bigger area; it is used to cut the Sentinel 3 images and improve the speed of the computation.
90112
- The absolute path indicated by `MAIN_FOLDER` in the previous schema should be inserted in the `general_path` variable. In the example, the `MAIN_FOLDER` absolute path is `"D:\\TEMP\\"`.
91-
- The path into the `setet_folder` variable. The `setet_folder` is something like `"C:\\Users\\user\\.snap\\auxdata\\sen-et-conda-Win64"`.
113+
- The path into the `senet_folder` variable. The `senet_folder` is something like `"C:\\Users\\user\\.snap\\auxdata\\sen-et-conda-Win64"`.
92114
- It is also possible to modify all the default computational parameters, as explained in Section 3.3 of the official guide. The *only* parameter that should be modified is the [timezone of the area](input/parameters.json#L12).
93115

94-
Finally, copy the absolute path of all the Sentinel Images in the file [`s2_paths.txt`](input/s2_paths.txt) and [`s3_paths.txt`](input/s3_paths.txt). The path should point to the file `MTD_MSIL2A.xml` for S2 and `xfdumanifest.xml` for S3.
116+
Finally, copy the absolute path of all the Sentinel Images in the files [`s2_paths.txt`](input/s2_paths.txt) and [`s3_paths.txt`](input/s3_paths.txt). The path should point to the folders `.SAFE` for S2 and `.SEN3` for S3.
95117

96118
## Run the code
97-
In a Bash terminal run:
119+
### Windows
120+
In conda terminal run:
98121
```
99-
sh main.sh
122+
conda activate senet-auto
123+
main.sh
100124
```
101-
After the computation of the Sentinel 3 images in the graph processing tool, it is necessary to insert the time of acquisition for the Sentinel 3 images. So, it is needed to open in SNAP the Sentinel image cut on the area of interest and report the time in the file `days_ADDTIME_s3.txt` and rename it as `days_time_s3.txt`.
102-
The structure of the file should be: `YYYY_MM_DD HH:MM`
125+
This will open a bash Terminal with all the dependencies correctly installed.
103126

104-
The script produces a message when the Sentinel 3 images are available for the computation and requests to confirm that the file `days_time_s3.txt` has been created.
127+
### Unix system (linux/MacOS)
128+
In a terminal run:
129+
```
130+
conda activate senet-auto
131+
sh main.sh
132+
```
105133

106134
## Correction of errors
107135
In the [official code repository](https://github.com/DHI-GRAS/sen-et-snap-scripts) the graph presents some errors, due to some changes in the new versions of SNAP. To fix the errors the new version of the graph is present in the folder [graph](graph/).
108136

109137
## Authors
110138
The official code of SNAP is released with [GNU General Public License v3.0](https://github.com/DHI-GRAS/sen-et-snap-scripts/blob/master/LICENSE) by the original authors and as reported in the [plugin code repository](https://github.com/DHI-GRAS/senEtSnapSta).
111139

112-
The code for the automatization of the process is also realeased by [Lorenzo Stucchi](https://github.com/LorenzoStucchi) with [GNU General Public License v3.0](LICENSE).
140+
The code for the automatization of the process is also released by [Lorenzo Stucchi](https://github.com/LorenzoStucchi) with [GNU General Public License v3.0](LICENSE).

assets/new.png

-88.1 KB
Binary file not shown.

assets/new_full.png

50.8 KB
Loading

assets/new_one_step.png

-47.9 KB
Binary file not shown.

assets/old.png

16 KB
Loading

env.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: senet-auto
2+
channels:
3+
- conda-forge
4+
- defaults
5+
dependencies:
6+
- python=3.9
7+
- xarray
8+
- netcdf4
9+
- h5netcdf

graph/sentinel_3_cut.xml renamed to graph/sentinel_3_cut_time.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,33 @@
2424
<copyMetadata>true</copyMetadata>
2525
</parameters>
2626
</node>
27+
<node id="Subset_remove_bands">
28+
<operator>Subset</operator>
29+
<sources>
30+
<sourceProduct refid="Subset"/>
31+
</sources>
32+
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
33+
<sourceBands>LST</sourceBands>
34+
<region/>
35+
<referenceBand/>
36+
<geoRegion/>
37+
<subSamplingX>1</subSamplingX>
38+
<subSamplingY>1</subSamplingY>
39+
<fullSwath>false</fullSwath>
40+
<tiePointGridNames/>
41+
<copyMetadata>true</copyMetadata>
42+
</parameters>
43+
</node>
44+
<node id="Write_netcdf">
45+
<operator>Write</operator>
46+
<sources>
47+
<sourceProduct refid="Subset_remove_bands"/>
48+
</sources>
49+
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
50+
<file>!OUTPUT_Sentinel-3_time!</file>
51+
<formatName>NetCDF4-BEAM</formatName>
52+
</parameters>
53+
</node>
2754
<node id="Write">
2855
<operator>Write</operator>
2956
<sources>
@@ -42,6 +69,12 @@
4269
<node id="Subset">
4370
<displayPosition x="234.0" y="130.0"/>
4471
</node>
72+
<node id="Subset_remove_bands">
73+
<displayPosition x="233.0" y="224.0"/>
74+
</node>
75+
<node id="Write_netcdf">
76+
<displayPosition x="458.0" y="226.0"/>
77+
</node>
4578
<node id="Write">
4679
<displayPosition x="455.0" y="130.0"/>
4780
</node>

input/s2_paths.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
D:\TEMP\S2\2019_08_06\S2A_MSIL2A_20190806T095031_N0213_R079_T33TWF_20190806T114240.SAFE\MTD_MSIL2A.xml
1+
D:\TEMP\S2\2019_08_06\S2A_MSIL2A_20190806T095031_N0213_R079_T33TWF_20190806T114240.SAFE

input/s3_paths.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
D:\TEMP\S3\2019_08_03\S3A_SL_2_LST____20190803T083233_20190803T101332_20190804T153249_6059_047_335______LN2_O_NT_003.SEN3\xfdumanifest.xml
1+
D:\TEMP\S3\2019_08_03\S3A_SL_2_LST____20190803T083233_20190803T101332_20190804T153249_6059_047_335______LN2_O_NT_003.SEN3

main.sh

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
11
#!/bin/bash
22

3-
python py_script/1_create_script_graph.py
3+
python py_scripts/1_create_script_graph.py
44
sh output/1_script_gpt_s3.sh
5-
echo " ===================================================================="
6-
echo " ===================================================================="
7-
echo " Open SNAP and set the hour of s3 images in the file days_time_s3.txt"
8-
echo " ===================================================================="
9-
echo " ===================================================================="
10-
sleep 30
5+
python py_scripts/2_read_times_s3.py
116
sh output/2_script_gpt_s2.sh
12-
read -r -p "Do you set the S3 time in the file days_time_s3.txt? [Y/n] " input
13-
if [[ $input == Y ]] || [[ $input == y ]]
14-
then
15-
python py_script/2_create_script_python.py
16-
sh output/3_script_S2.sh
17-
sh output/4_script_S3.sh
18-
echo "Computation ended sucessfully"
19-
else
20-
read -r -p "Please, set the hour and minute of the Sentinel 3 images in the file days_time_s3.txt and then press Y: " input
21-
if [[ $input == Y ]] || [[ $input == y ]]
22-
then
23-
python py_script/2_create_script_python.py
24-
sh output/3_script_S2.sh
25-
sh output/4_script_S3.sh
26-
echo "Computation ended sucessfully"
27-
else
28-
echo "Wrong value chose, the script ended without computation"
29-
fi
30-
fi
7+
python py_scripts/3_create_script_python.py
8+
sh output/3_script_S2.sh
9+
sh output/4_script_S3.sh
10+
read -r -p "Computation ended sucessfully! Press any key to close the panel" input

0 commit comments

Comments
 (0)