Skip to content

Commit fd1c6f6

Browse files
Merge branch 'develop'
2 parents c7c9086 + c3c4db1 commit fd1c6f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3485
-669
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ It is therefore possible, to cover large geographic extent with a __seamless ima
3939
It is worth noting that the overall accuracy of your final ARD product strongly depends on the accuracy of sen2like auxiliary data. Two categories of auxiliary data are important: the raster reference for geometric corrections and the meteorological data for atmospheric corrections. Regarding atmospheric corrections, one possibility is to use data from the Copernicus Atmosphere Monitoring Service [9]. The Sen2Like team prepared a dedicated CAMS monthly dataset for the Year 2020, available from [here](http://185.178.85.51/CAMS/). Please refer to this short [description](http://185.178.85.51/CAMS/Readme_CAMS2020.txt) for additional information.
4040

4141
For further details on the format specification of the harmonized products or the functionalities of the Sen2Like software, please
42-
refer to the [Product Format Specification](sen2like/docs/source/S2-PDGS-MPC-L2HF-PFS-v1.1.pdf), and the [User Manual v1.8](sen2like/docs/source/S2-SEN2LIKE-UM-V1.8.pdf).
42+
refer to the [Product Format Specification](sen2like/docs/source/S2-PDGS-MPC-L2HF-PFS-v1.2.pdf), and the [User Manual v1.8](sen2like/docs/source/S2-SEN2LIKE-UM-V1.9.pdf).
4343

4444
## Publications and Contacts
4545
**Yearning to know more ? Check out**
46-
* poster [Sen2Like, a tool to generate Sentinel-2 Harmonised Surface Reflectance Products, First Results With Landsat-8, 3rd S2 Validation Team Meeting](https://www.researchgate.net/publication/332428332_Sen2like_a_Tool_to_Generate_Sentinel-2_Harmonised_Surface_Reflectance_Products_-_First_Results_With_Landsat-8)
46+
* poster [Sen2like: A solution for Harmonization and Fusion of Sentinel-2 and Landsat 8/9 data, JACIE 2023](https://www.researchgate.net/publication/372831217_Sen2like_A_solution_for_Harmonization_and_Fusion_of_Sentinel-2_and_Landsat_89_data)
4747
* A [Sen2Like Relaxing Video](https://youtu.be/KBSYYBShyos) prepared for [ESA EO PHI-WEEK 2020](https://www.youtube.com/playlist?list=PLvT7fd9OiI9XELZXcljYTftUtJ_NFWRrY)
4848
* A [Sen2Like Time Lapse including NDVI graphic](https://youtu.be/yEObvI1KQBg) prepared for QWG#12
4949

@@ -60,7 +60,7 @@ And the following research papers :
6060
+ [10] Saunier, S.; Pflug, B.; Lobos, I.M.; Franch, B.; Louis, J.; De Los Reyes, R.; Debaecker, V.; Cadau, E.G.; Boccia, V.; Gascon, F.; Kocaman, S. Sen2Like: Paving the Way towards Harmonization and Fusion of Optical Data. Remote Sens. 2022, 14, 3855. (https://doi.org/10.3390/rs14163855)
6161

6262

63-
**Learn how to use Sen2Like**, have a look at the [User Manual](sen2like/docs/source/S2-SEN2LIKE-UM-V1.8.pdf).
63+
**Learn how to use Sen2Like**, have a look at the [User Manual](sen2like/docs/source/S2-SEN2LIKE-UM-V1.9.pdf).
6464

6565
**Get help**, contact us at sen2like@telespazio.com.
6666

sen2like/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
*
33
# but not what we want to send in the build context
44
!requirements.txt
5+
!requirements_dev.txt
56
!sen2like
7+
!aux_data

sen2like/Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@
1414
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
17-
17+
ARG SEN2LIKE_BUILD_IMAGE_TAG
1818
# docker image baser on miniconda image (debian:latest)
19-
FROM continuumio/miniconda3:22.11.1 AS build
19+
FROM ${SEN2LIKE_BUILD_IMAGE_TAG} AS build
2020
LABEL stage=sen2like_build
2121

2222
# set the working dir to /usr/local/sen2like
2323
WORKDIR /usr/local/sen2like
2424

25-
# Create the environment:
26-
# copy requirements.txt from sources to docker image
27-
COPY ./requirements.txt .
28-
# create sen2like env from requirement
29-
RUN conda create -n sen2like --file requirements.txt -c conda-forge
30-
3125
# Install conda-pack:
3226
RUN conda install -c conda-forge conda-pack
3327

@@ -48,11 +42,18 @@ FROM debian:bullseye-slim AS runtime
4842
COPY --from=build /venv /venv
4943

5044
# install in curent docker image mesa-glx
51-
RUN apt-get update && apt-get install -y libgl1-mesa-glx
45+
RUN apt-get update \
46+
&& apt-get install -y libgl1-mesa-glx \
47+
&& rm -rf /var/lib/apt/lists/*
5248

5349
# set PATH with venv
5450
ENV VIRTUAL_ENV=/venv
5551
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
52+
ENV PROJ_LIB=/venv/share/proj
53+
54+
# set the working dir to /usr/local/aux_data
55+
WORKDIR /usr/local/aux_data
56+
COPY ./aux_data .
5657

5758
# set the working dir to /usr/local/sen2like
5859
WORKDIR /usr/local/sen2like

sen2like/Dockerfile-base

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# docker image based on miniconda image (debian:latest)
2+
# ARG MINICONDA_DOCKER_VERSION
3+
# FROM continuumio/miniconda3:${MINICONDA_DOCKER_VERSION}
4+
FROM continuumio/miniconda3:23.3.1-0
5+
6+
# set the working dir to /usr/local/sen2like
7+
WORKDIR /usr/local/sen2like
8+
9+
# Create the environment:
10+
# copy requirements.txt from sources to docker image
11+
COPY ./requirements.txt .
12+
# create sen2like env from requirement
13+
RUN conda create -n sen2like --file requirements.txt -c conda-forge

sen2like/Dockerfile-tests

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# sen2like-base docker image is based on miniconda image (debian:latest)
2+
ARG SEN2LIKE_BUILD_IMAGE_TAG
3+
FROM ${SEN2LIKE_BUILD_IMAGE_TAG}
4+
LABEL stage=sen2like_tests
5+
6+
# Update the environment:
7+
# copy dev/tests requirements from sources to docker image
8+
COPY ./requirements_dev.txt .
9+
10+
# update sen2like env
11+
RUN conda install -n sen2like --file requirements_dev.txt -c conda-forge
12+
13+
# install system dependencies in curent docker image mesa-glx
14+
RUN apt-get update \
15+
&& apt-get install -y libgl1-mesa-glx \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
# image is ready for tests, usage must activate sen2like conda env

sen2like/README.md

Lines changed: 146 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ TOC Generated with markdown all in one: https://github.com/yzhang-gh/vscode-mark
2626
- [Geometry](#geometry)
2727
- [Atmcor](#atmcor)
2828
- [Nbar](#nbar)
29+
- [Sbaf](#sbaf)
2930
- [Fusion](#fusion)
3031
- [Stitching](#stitching)
32+
- [TopographicCorrection (Experimental)](#topographiccorrection-experimental)
33+
- [DEMRepository](#demrepository)
3134
- [OutputFormat](#outputformat)
3235
- [COGoptions](#cogoptions)
3336
- [JPEG2000options](#jpeg2000options)
@@ -39,6 +42,8 @@ TOC Generated with markdown all in one: https://github.com/yzhang-gh/vscode-mark
3942
- [Single tile mode](#single-tile-mode)
4043
- [Multi tile mode](#multi-tile-mode)
4144
- [ROI based mode](#roi-based-mode)
45+
- [Auxiliary data tools](#auxiliary-data-tools)
46+
- [DEM downloader](#dem-downloader)
4247
- [Release notes](#release-notes)
4348
- [License](#license)
4449

@@ -100,7 +105,7 @@ conda activate sen2like
100105

101106
```bash
102107
python sen2like.py
103-
[INFO ] 2023-01-11 14:50:54 - sen2like - Run Sen2like 4.3.0
108+
[INFO ] 2023-01-11 14:50:54 - sen2like - Run Sen2like 4.4.0
104109
usage: sen2like.py [-h] [--version] [--refImage PATH] [--wd PATH]
105110
[--conf PATH] [--confParams STRLIST] [--bands STRLIST]
106111
[--allow-other-srs] [--no-run] [--intermediate-products]
@@ -124,8 +129,16 @@ Please refer to the docker documentation to install docker on your environnement
124129

125130
From the sen2like root directory (the one containing `Dockerfile`)
126131

132+
First build the base image :
133+
127134
```bash
128-
docker build -t sen2like . && docker image prune --filter label=stage=sen2like_build -f
135+
docker build -t sen2like --build-arg sen2like_base .
136+
```
137+
138+
Then the final image :
139+
140+
```bash
141+
docker build -t sen2like --build-arg SEN2LIKE_BUILD_IMAGE_TAG=sen2like_base . && docker image prune --filter label=stage=sen2like_build -f
129142
```
130143

131144
The result is a docker image with tag `sen2like:latest`
@@ -149,15 +162,15 @@ Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
149162
Example
150163

151164
```bash
152-
docker image tag sen2like my-internal-docker-registry-url/sen2like:4.3
165+
docker image tag sen2like my-internal-docker-registry-url/sen2like:4.4
153166
```
154167

155168
Push the image on a registry with the command `docker push NAME[:TAG]`
156169

157170
Example
158171

159172
```bash
160-
docker push my-internal-docker-registry-url/sen2like:4.3
173+
docker push my-internal-docker-registry-url/sen2like:4.4
161174
```
162175

163176
## Running the tool
@@ -181,15 +194,15 @@ Build sen2like docker image or pull it from a registry with the command `docker
181194
Example :
182195

183196
```bash
184-
docker pull https://my-internal-docker-registry-url/sen2like:4.3
197+
docker pull https://my-internal-docker-registry-url/sen2like:4.4
185198
```
186199

187200
You can run it directly without entering into the container:
188201

189202
```bash
190-
docker run --rm my-internal-docker-registry-url/sen2like/sen2like:4.3
203+
docker run --rm my-internal-docker-registry-url/sen2like/sen2like:4.4
191204

192-
[INFO ] 2023-01-11 14:50:54 - sen2like - Run Sen2like 4.3.0
205+
[INFO ] 2023-01-11 14:50:54 - sen2like - Run Sen2like 4.4.0
193206
usage: sen2like.py [-h] [--version] [--refImage PATH] [--wd PATH]
194207
[--conf PATH] [--confParams STRLIST] [--bands STRLIST]
195208
[--allow-other-srs] [--no-run] [--intermediate-products]
@@ -210,7 +223,7 @@ In the following examples **local** folder `/data` is supposed to exist and cont
210223
```bash
211224
docker run --rm \
212225
--mount type=bind,source="/data",target=/data \
213-
my-internal-docker-registry-url/sen2like/sen2like:4.3 \
226+
my-internal-docker-registry-url/sen2like/sen2like:4.4 \
214227
single-tile-mode 31TFJ \
215228
--conf "/data/config.ini" \
216229
--start-date 2017-10-30 --end-date 2017-10-31 \
@@ -224,7 +237,7 @@ Python script `sen2like.py` could be accessed from a docker container.
224237
Launch the docker binding **local** `/data` folder to the container `/data` folder, example:
225238

226239
```bash
227-
docker run --rm -it --mount type=bind,source="/data",target=/data --entrypoint=/bin/bash my-internal-docker-registry-url/sen2like/sen2like:4.3
240+
docker run --rm -it --mount type=bind,source="/data",target=/data --entrypoint=/bin/bash my-internal-docker-registry-url/sen2like/sen2like:4.4
228241

229242
root@15a2f44ddd70:/usr/local/sen2like
230243

@@ -271,9 +284,10 @@ Enable or disable a processing block based on value `(True, False)`:
271284
* `doGeometryCheck`: Run the geometric assessment using KLT to compute geometry QI
272285
* `doToa`: Run the TOA correction
273286
* `doInterCalibration`: Run the Inter Calibration correction (S2B)
274-
* `doAtmcor`: Run the Atmospheric correction (SMAC or Sen2Cor)
287+
* `doAtmcor`: Activate the Atmospheric correction (SMAC or with sen2cor)
275288
* `doNbar`: Run Nbar correction processing
276289
* `doSbaf`: Run the Sbaf correction processing
290+
* `doTopographicCorrection`: Activate the Topographic correction (sen2like or with sen2cor)
277291
* `doFusion`: Run the Fusion processing
278292
* `doPackagerL2H`: Run the packaging processing for harmonized products
279293
* `doPackagerL2F`: Run the packaging processing for fused products
@@ -287,7 +301,6 @@ Indicates path for special directories:
287301
* `cams_daily_dir`: Where the CAMS daily files are located
288302
* `cams_hourly_dir`: Where the CAMS hourly files are located
289303
* `cams_climatology_dir`: Where the CAMS climatology files are located
290-
* `dem_dir`: Where the DEM files are located
291304
* `scl_dir`: Where the auxiliary scl maps files are located
292305

293306
#### Downloader
@@ -349,7 +362,7 @@ url_parameters_pattern_Sentinel2 = /data/PRODUCTS/Sentinel2/31TFJ
349362

350363
Define parameters for geometric correction.
351364

352-
* `reference_band`= The reference band to be used for geometric correction
365+
* `reference_band`: The reference band to be used for geometric correction
353366
* `doMatchingCorrection`: Apply the matching correction (`True`, `False`)
354367
* `doAssessGeometry`: Assess geometry (Band list separated by comma.)
355368
* `references_map`: Path to the reference json file containing the reference image for each tile
@@ -359,7 +372,7 @@ Define parameters for geometric correction.
359372

360373
Atmospheric correction method to use.
361374

362-
* `use_sen2cor`: Activate sen2cor for Atmospheric correction (SMAC otherwise)
375+
* `use_sen2cor`: Activate sen2cor for Atmospheric correction (SMAC otherwise), `doAtmcor` MUST be `True`
363376
* `sen2cor_path`: Path to sen2cor tool command (L2A_Process.py)
364377

365378
#### Nbar
@@ -369,6 +382,23 @@ Define parameters for Nbar processing.
369382
* `nbar_methode`: Method to get BRDF coefficients. Currently, available methods are : ROY, VJB
370383
* `vjb_coeff_matrice_dir`: If VJB method is selected, directory path of the BRDF coefficients netcdf file
371384

385+
#### Sbaf
386+
387+
Define parameters for SBAF processing.
388+
389+
* `adaptative`: **Experimental** Use adaptative SBAF or not. Adaptative SBAF is based on NDVI to which is apply a factor and offset depending the processed band.
390+
* `adaptative_band_candidates`: S2 equivalent band list separated by comma for which to apply adaptative SBAF. For now B04, B11 and B12 are known to be the better candidates.
391+
Band mapping table:
392+
|Landsat|S2|
393+
|-|-|
394+
|B01|B01|
395+
|B02|B02|
396+
|B03|B03|
397+
|B04|B04|
398+
|B05|B8A|
399+
|B06|B11|
400+
|B07|B12|
401+
372402
#### Fusion
373403

374404
Define parameters for Fusion processing.
@@ -385,6 +415,33 @@ Define parameters for stitching processing.
385415
* `same_utm_only`: Enable or disable stitching with product on different UTM as current processed product.
386416
For Landsat it allows to use previous or next product that can be on another UTM for stitching and have a better tile coverage.
387417

418+
#### TopographicCorrection (Experimental)
419+
420+
Define parameters for topographic correction process. Topographic correction can be done with the sen2like processing block or with sen2cor.
421+
422+
* `sen2cor_topographic_correction`: with topographic correction activated (`doTopographicCorrection=True`), and atmcor with sen2cor enabled (`doAtmcor=True` and `use_sen2cor=True`), the topographic correction is delegated to sen2cor instead of the sen2like TopographicCorrection processing block.
423+
* `topographic_correction_limiter`: limit to this value the maximum topographic factor to apply (only for sen2like topographic correction, not sen2cor).
424+
* `apply_valid_pixel_mask`: Use valid pixel mask to select pixel for which the correction is done. Useful to not apply correction on cloudy pixels (only for sen2like topographic correction, not sen2cor).
425+
426+
427+
#### DEMRepository
428+
429+
Define parameters for DEMRepository component.
430+
431+
The DEMRepository component is responsible to access DEM files mainly for [`TopographicCorrection`](#topographiccorrection) processing block
432+
433+
* `dem_folder`: Base folder path that host DEM dataset
434+
* `dem_dataset`: DEM dataset to use
435+
* `src_dem_resolution`: resolution to use for DEM in DEM dataset
436+
437+
DEM storage tree MUST follow the following structure :
438+
439+
`{dem_folder}/{dem_dataset}/Copernicus_DSM_{src_dem_resolution}m_{tile_code}.TIF`
440+
441+
Where `tile_code` is the current processed MGRS tile.
442+
443+
See [DEM Downloader chapter](#dem-downloader) to know how to generate MGRS DEM tile.
444+
388445
#### OutputFormat
389446

390447
Define output format, gain and offset for image files.
@@ -393,7 +450,7 @@ Define output format, gain and offset for image files.
393450
* `offset`: DN Offset to substract from the output image (DN to reflectance conversion)
394451
* `output_format`: Format of the output image. Supported formats: COG, GTIFF (for geotiff), JPEG2000.
395452

396-
*Note: DN to reflectance conversion: reflectance = (DN - offset) / gain *
453+
> *Note: DN to reflectance conversion: reflectance = (DN - offset) / gain*
397454
398455
#### COGoptions
399456

@@ -714,6 +771,81 @@ Debug arguments:
714771
--no-log-date Do no store date in log (default: False)
715772
```
716773

774+
## Auxiliary data tools
775+
776+
Auxiliary data tools are located in the folder `aux_data`
777+
778+
For now there is only the DEM downloader tools.
779+
780+
### DEM downloader
781+
782+
This tool allows to create DEM aux data for TopographicCorrection of Sen2like.
783+
784+
It creates a DEM as GeoTiff having the same extend and UTM projection as a MGRS tile.
785+
786+
To do so, from a given MGRS tile code, it retrieves matching Copernicus DEM tiles, build a mosaic, then crop and reproject it.
787+
788+
In order to use this tool, `sen2like` module/folder **MUST** be in `PYTHONPATH`.
789+
790+
Usage example to display the help:
791+
792+
```bash
793+
PYTHONPATH=sen2like/ aux_data/dem/dem_downloader.py -h
794+
```
795+
796+
It should display:
797+
798+
```
799+
usage: dem_downloader.py [-h] --server_url SERVER_URL [--debug] MGRS_TILE_CODE DEM_DATASET_NAME DEM_LOCAL_URL
800+
801+
Create DEM for a MGRS Tile.
802+
The generated DEM is TIF file in the MGRS extend and its projected in the MGRS tile EPSG (UTM).
803+
804+
805+
positional arguments:
806+
MGRS_TILE_CODE MGRS Tile code for witch to generate DEM, example 31TFJ
807+
DEM_DATASET_NAME DEM dataset name, example COP-DEM_GLO-90-DGED__2022_1
808+
DEM_LOCAL_URL Base output folder for generated DEM, example /data/AUX_DATA/
809+
Generated files are stored as follow :
810+
/data/AUX_DATA/{DEM_DATASET_NAME}/Copernicus_DSM_{resolution}m_{MGRS_TILE_CODE}.TIF
811+
812+
813+
options:
814+
-h, --help show this help message and exit
815+
--server_url SERVER_URL
816+
DEM server base URL (default: https://prism-dem-open.copernicus.eu/pd-desk-open-access/prismDownload/)
817+
--debug, -d Enable Debug mode (default: False)
818+
```
819+
820+
The `--server_url` options MUST allow to produce URL formatted as follow to download tiles : `<SERVER_URL>/<DEM_DATASET_NAME>/<DEM_GEOCELL_FILE>`
821+
822+
With:
823+
824+
- `<DEM_DATASET_NAME>` is the `DEM_DATASET_NAME` program argument
825+
- `<DEM_GEOCELL_FILE>` is a file name that match `Copernicus_DSM_VV_WWW_XX_YYY_ZZ.tar`, example: `Copernicus_DSM_30_N42_00_E012_00.tar`
826+
See [Product Structure / Naming Convention in this document](https://spacedata.copernicus.eu/documents/20123/122407/GEO1988-CopernicusDEM-SPE-002_ProductHandbook_I5.0+%281%29.pdf)
827+
828+
829+
The tools is also available in the Sen2like docker image in `/usr/local/aux_data` folder.
830+
`sen2like` path to use for `PYTHONPATH` is `/usr/local/sen2like`.
831+
832+
Example :
833+
834+
```bash
835+
docker run --rm \
836+
-v /data/DEM:/data/DEM \
837+
-e PYTHONPATH=/usr/local/sen2like \
838+
--entrypoint /usr/local/aux_data/dem/dem_downloader.py \
839+
sen2like \
840+
33TTG \
841+
COP-DEM_GLO-90-DGED__2022_1 \
842+
/data/DEM
843+
```
844+
845+
It results a file `/data/DEM/COP-DEM_GLO-90-DGED__2022_1/Copernicus_DSM_90m_33TTG.TIF` on the docker host.
846+
847+
The tool keep extracted Copernicus geocell DEM TIF files in folder `<DEM_LOCAL_URL>/<DEM_DATASET_NAME>/geocells` to avoid to download them every time it needs them to create a MGRS DEM file.
848+
717849
## [Release notes](./release-notes.md)
718850

719851
## License

0 commit comments

Comments
 (0)