Skip to content

Commit 75997f6

Browse files
Update sen2like sources for 4.4.1
1 parent 150eb50 commit 75997f6

File tree

16 files changed

+75
-61
lines changed

16 files changed

+75
-61
lines changed

sen2like/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ conda activate sen2like
105105

106106
```bash
107107
python sen2like.py
108-
[INFO ] 2023-01-11 14:50:54 - sen2like - Run Sen2like 4.4.0
108+
[INFO ] 2023-01-11 14:50:54 - sen2like - Run Sen2like 4.4.1
109109
usage: sen2like.py [-h] [--version] [--refImage PATH] [--wd PATH]
110110
[--conf PATH] [--confParams STRLIST] [--bands STRLIST]
111111
[--allow-other-srs] [--no-run] [--intermediate-products]
@@ -132,7 +132,7 @@ From the sen2like root directory (the one containing `Dockerfile`)
132132
First build the base image :
133133

134134
```bash
135-
docker build -t sen2like --build-arg sen2like_base .
135+
docker build -t sen2like_base -f Dockerfile-base .
136136
```
137137

138138
Then the final image :
@@ -184,7 +184,7 @@ Python script sen2like.py could be found in cloned git repository, or unzipped f
184184
For example if git cloned in home directory:
185185

186186
```bash
187-
/opt/anaconda3/bin/python "$HOME/sen2like/sen2like/sen2like.py" single-tile-mode 31TFJ --conf "./config.ini" --start-date 2017-10-30 --end-date 2017-10-31 --wd "/data/production" --refImage "/data/References/GRI/S2A_OPER_MSI_L1C_TL_MPS__20161018T120000_A000008_T31TFJ_N01.01/IMG_DATA/S2A_OPER_MSI_L1C_TL_MPS__20161018T120000_A000008_T31TFJ_B04.jp2" --bands B04
187+
python "$HOME/sen2like/sen2like/sen2like.py" single-tile-mode 31TFJ --conf "./config.ini" --start-date 2017-10-30 --end-date 2017-10-31 --wd "/data/production" --refImage "/data/References/GRI/S2A_OPER_MSI_L1C_TL_MPS__20161018T120000_A000008_T31TFJ_N01.01/IMG_DATA/S2A_OPER_MSI_L1C_TL_MPS__20161018T120000_A000008_T31TFJ_B04.jp2" --bands B04
188188
```
189189

190190
### Docker
@@ -202,7 +202,7 @@ You can run it directly without entering into the container:
202202
```bash
203203
docker run --rm my-internal-docker-registry-url/sen2like/sen2like:4.4
204204

205-
[INFO ] 2023-01-11 14:50:54 - sen2like - Run Sen2like 4.4.0
205+
[INFO ] 2023-01-11 14:50:54 - sen2like - Run Sen2like 4.4.1
206206
usage: sen2like.py [-h] [--version] [--refImage PATH] [--wd PATH]
207207
[--conf PATH] [--confParams STRLIST] [--bands STRLIST]
208208
[--allow-other-srs] [--no-run] [--intermediate-products]
@@ -357,6 +357,11 @@ url_parameters_pattern_Sentinel2 = /data/PRODUCTS/Sentinel2/31TFJ
357357
* `cloud_cover_property`: Path in result json where cloud cover is stored
358358
* `gml_geometry_property`: Path in result json where gml geometry is stored
359359

360+
**For Landsat8 L1 product selection, you MUST have `productType` or `processingLevel` URL parameter set in `location_Landsat8`**
361+
362+
Possible values for these parameters can be found [here](https://datahub.creodias.eu/resto/api/collections/Landsat8/describe.xml)
363+
364+
Notice that at the time of writing this it seems that `processingLevel=LEVEL1` select only L1TP product type.
360365

361366
#### Geometry
362367

sen2like/conf/config.ini

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ url_parameters_pattern_Landsat9 = {base_url}/{mission}/{path}/{row}
3737

3838
##################################################################
3939
# Creodias only
40-
; base_url = https://finder.creodias.eu/resto/api/collections
41-
; location_Landsat8 = path={path}&row={row}
42-
; location_Landsat9 = path={path}&row={row}
40+
; base_url = https://datahub.creodias.eu/resto/api/collections
41+
; location_Landsat8 = path={path}&row={row}&productType=L1TP
42+
; location_Landsat9 = path={path}&row={row}&productType=L1TP
4343
; location_Sentinel2 = productIdentifier=%25T{tile}%25
4444
; url_parameters_pattern = {base_url}/{mission}/search.json?maxRecords=1000&_pretty=true&cloudCover=%5B0%2C{cloud_cover}%5D&startDate={start_date}&completionDate={end_date}&sortParam=startDate&sortOrder=ascending&status=all&{location}&dataset=ESA-DATASET
4545
; thumbnail_property = properties/productIdentifier
@@ -54,7 +54,7 @@ url_parameters_pattern_Landsat9 = {base_url}/{mission}/{path}/{row}
5454
;url_parameters_pattern_Landsat9 = {base_url_landsat}/{mission}/{path}/{row}
5555

5656
# remote S2 part
57-
;base_url_s2 = https://finder.creodias.eu/resto/api/collections
57+
;base_url_s2 = https://datahub.creodias.eu/resto/api/collections
5858
;location_Sentinel2 = productIdentifier=%25T{tile}%25
5959
;url_parameters_pattern = {base_url_s2}/{mission}/search.json?maxRecords=1000&_pretty=true&cloudCover=%5B0%2C{cloud_cover}%5D&startDate={start_date}&completionDate={end_date}&sortParam=startDate&sortOrder=ascending&status=all&{location}&dataset=ESA-DATASET
6060
;thumbnail_property = properties/productIdentifier
@@ -68,9 +68,9 @@ url_parameters_pattern_Landsat9 = {base_url}/{mission}/{path}/{row}
6868
;url_parameters_pattern_Sentinel2 = {base_url_s2}/{mission}/{tile}
6969

7070
# remote landsat part
71-
;base_url_landsat = https://finder.creodias.eu/resto/api/collections
72-
;location_Landsat8 = path={path}&row={row}
73-
;location_Landsat9 = path={path}&row={row}
71+
;base_url_landsat = https://datahub.creodias.eu/resto/api/collections
72+
;location_Landsat8 = path={path}&row={row}&productType=L1TP
73+
;location_Landsat9 = path={path}&row={row}&productType=L1TP
7474
;url_parameters_pattern = {base_url_landsat}/{mission}/search.json?maxRecords=1000&_pretty=true&cloudCover=%5B0%2C{cloud_cover}%5D&startDate={start_date}&completionDate={end_date}&sortParam=startDate&sortOrder=ascending&status=all&{location}&dataset=ESA-DATASET
7575
;thumbnail_property = properties/productIdentifier
7676
;cloud_cover_property = properties/cloudCover

sen2like/conf/config.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@
3333
<url_parameters_pattern_Landsat9>{base_url}/{mission}/{path}/{row}</url_parameters_pattern_Landsat9>
3434

3535
<!-- Creodias -->
36-
<!-- <base_url>https://finder.creodias.eu/resto/api/collections</base_url>-->
37-
<!-- <location_Landsat8>path={path}&amp;row={row}</location_Landsat8>-->
38-
<!-- <location_Landsat9>path={path}&amp;row={row}</location_Landsat9>-->
36+
<!-- <base_url>https://datahub.creodias.eu/resto/api/collections</base_url>-->
37+
<!-- <location_Landsat8>path={path}&amp;row={row}&amp;productType=L1TP</location_Landsat8>-->
38+
<!-- <location_Landsat9>path={path}&amp;row={row}&amp;productType=L1TP</location_Landsat9>-->
3939
<!-- <location_Sentinel2>productIdentifier=%25T{tile}%25</location_Sentinel2>-->
4040
<!-- <url_parameters_pattern>{base_url}/{mission}/search.json?maxRecords=100&amp;_pretty=true&amp;cloudCover=%5B0%2C{cloud_cover}%5D&amp;startDate={start_date}&amp;completionDate={end_date}&amp;sortParam=startDate&amp;sortOrder=ascending&amp;status=all&amp;{location}&amp;dataset=ESA-DATASET</url_parameters_pattern>-->
4141
<!-- <thumbnail_property>properties/productIdentifier</thumbnail_property>-->
4242
<!-- <cloud_cover_property>properties/cloudCover</cloud_cover_property>-->
4343
<!-- <gml_geometry_property>properties/gmlgeometry</gml_geometry_property>-->
4444

4545
<!-- mixed landsat local, remote s2 -->
46-
<!-- <base_url_s2>https://finder.creodias.eu/resto/api/collections</base_url_s2>-->
46+
<!-- <base_url_s2>https://datahub.creodias.eu/resto/api/collections</base_url_s2>-->
4747
<!-- <base_url_landsat>/data/PRODUCTS</base_url_landsat>-->
4848
<!-- <location_Sentinel2>productIdentifier=%25T{tile}%25</location_Sentinel2>-->
4949
<!-- <url_parameters_pattern_Landsat8>{base_url_landsat}/{mission}/{path}/{row}</url_parameters_pattern_Landsat8>-->
@@ -56,10 +56,10 @@
5656

5757
<!-- mixed landsat s2, remote landsat -->
5858
<!-- <base_url_s2>/data/PRODUCTS</base_url_s2>-->
59-
<!-- <base_url_landsat>https://finder.creodias.eu/resto/api/collections</base_url_landsat>-->
59+
<!-- <base_url_landsat>https://datahub.creodias.eu/resto/api/collections</base_url_landsat>-->
6060
<!-- <url_parameters_pattern_Sentinel2>{base_url_s2}/{mission}/{tile}</url_parameters_pattern_Sentinel2>-->
61-
<!-- <location_Landsat8>path={path}&amp;row={row}</location_Landsat8>-->
62-
<!-- <location_Landsat9>path={path}&amp;row={row}</location_Landsat9>-->
61+
<!-- <location_Landsat8>path={path}&amp;row={row}&amp;productType=L1TP</location_Landsat8>-->
62+
<!-- <location_Landsat9>path={path}&amp;row={row}&amp;productType=L1TP</location_Landsat9>-->
6363
<!-- <url_parameters_pattern>{base_url_landsat}/{mission}/search.json?maxRecords=100&amp;_pretty=true&amp;cloudCover=%5B0%2C{cloud_cover}%5D&amp;startDate={start_date}&amp;completionDate={end_date}&amp;sortParam=startDate&amp;sortOrder=ascending&amp;status=all&amp;{location}&amp;dataset=ESA-DATASET</url_parameters_pattern>-->
6464
<!-- <thumbnail_property>properties/productIdentifier</thumbnail_property>-->
6565
<!-- <cloud_cover_property>properties/cloudCover</cloud_cover_property>-->

sen2like/release-notes.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Sen2Like Release Notes
22

3+
## v4.4.1
4+
5+
### Important information about sen2like on Creodias
6+
7+
If you are using sen2like on Creodias you should update your sen2like configuration to properly filter Landsat products due to changes in Creodias Opensearch catalog API.
8+
9+
Please refer to [Creodias config parameters chapter](README.md#creodias-api) and take a look at [default configuration sample file](conf/config.ini)
10+
11+
### Fix
12+
13+
* sen2cor was applied only to first product when enable to process a L1 stack
14+
* Fix docker image build instructions in [README.md](README.md)
15+
* TopographicCorrection post process fail if DEM is not present
16+
* Replace finder catalog url by datahub catalog url and update landsat L1 product selection config sample, see [config parameters](README.md#creodias-api)
17+
* Force 2D coordinates for roi file with 3D coordinates
18+
319
## v4.4.0
420

521
### **Breaking changes**

sen2like/sen2like/atmcor/smac/smac.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212

1313
# Written by O.Hagolle CNES, from the original SMAC C routine
1414
# =============================================================================================
15-
from math import cos, pi, exp, sqrt, acos
15+
from math import acos, cos, exp, pi, sqrt
1616

1717
import numpy as np
1818

19-
2019
# =============================================================================================
2120

2221
def PdeZ(Z):

sen2like/sen2like/core/product_archive/product_archive.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ def _filter_valid_products(self, input_product_list: list[InputProduct], start_d
286286
is_product_valid = self.filter_on_date(input_product, start_date, end_date)
287287

288288
if input_product.instrument == 'S2' and processing_level_filter is not None:
289+
# select S2 L1C or L2A depending processing_level_filter
290+
# if l2a program arg is used, selected only L2A
291+
# otherwise select only L1C
292+
# TODO : find a better way for product selection.
289293
is_product_valid &= input_product.s2l_product_class.processing_level(
290294
os.path.basename(input_product.path)) == processing_level_filter
291295

@@ -307,7 +311,7 @@ def search_product(self, urls, tile, start_date: datetime=None, end_date: dateti
307311
:param end_date: End of the period
308312
:param product_mode: Indicates if we are in product or tile mode
309313
:param exclude: List of products to exclude
310-
:param processing_level: Add processing level for filtering
314+
:param processing_level: Add processing level for filtering if s2_processing_level is not set in config (l2a program arg)
311315
:return: list of selected InputProduct
312316
"""
313317
input_product_list = self._load_input_product(urls, product_mode)

sen2like/sen2like/core/product_archive/product_selector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def _read_polygon_from_json(json_file):
3636
if feature is None:
3737
logging.error("No features in json file: %s", json_file)
3838
return None
39+
feature.GetGeometryRef().FlattenTo2D()
3940
export = feature.GetGeometryRef().ExportToWkt()
4041
dataset = None
4142
return export

sen2like/sen2like/core/products/product.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ def __init__(self, config: S2L_Config, tile: str):
5757
self.doTopographicCorrection = config.getboolean('doTopographicCorrection') # pylint: disable=invalid-name
5858
self.sen2cor_topographic_correction = config.getboolean('sen2cor_topographic_correction')
5959

60-
if self.doAtmcor and config.get('s2_processing_level') == 'LEVEL2A':
61-
logger.warning("Disable atmospheric correction (SMAC and sen2cor) because process L2A product")
62-
self.doAtmcor = False
63-
self.use_sen2cor = False
60+
if config.get('s2_processing_level') == 'LEVEL2A':
61+
62+
if self.doAtmcor:
63+
logger.warning("Disable atmospheric correction (SMAC and sen2cor) because process L2A product")
64+
self.doAtmcor = False
65+
self.use_sen2cor = False
66+
67+
if self.doInterCalibration:
68+
logger.warning("Disable inter calibration because process L2A product")
69+
self.doInterCalibration = False
6470

6571
if not self.doTopographicCorrection:
6672
logger.warning("Disable sen2cor topographic correction because main topographic correction is disabled")

sen2like/sen2like/s2l_processes/S2L_TopographicCorrection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ def process(self, product: S2L_Product, image: S2L_ImageFile, band: str) -> S2L_
195195
return out_image
196196

197197
def postprocess(self, product: S2L_Product):
198-
product.metadata.qi["DEM_DATASET"] = self._dem_repository.dataset_name
199-
product.metadata.qi.update(self._stats.val)
198+
if self._stats:
199+
product.metadata.qi["DEM_DATASET"] = self._dem_repository.dataset_name
200+
product.metadata.qi.update(self._stats.val)
200201

201202
def _set_stats(self, factor: NDArray, res: float):
202203
"""Set stats at the given resolution

sen2like/sen2like/sen2like.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,6 @@ def pre_process_atmcor(s2l_product: S2L_Product, tile) -> S2L_Product|None:
130130
else:
131131
logger.info("sen2cor disabled")
132132

133-
# FIXME : ask to the team why we do this because the same call is done before
134-
# if s2l_product is None:
135-
# s2l_product = product.s2l_product_class(product.path)
136-
137-
if not filter_product(s2l_product):
138-
return None
139-
140-
# Disable Atmospheric correction for Level-2A product_urls
141-
# override s2_processing_level because it could be use later for related product search
142-
# (see product_archive)
143-
if s2l_product.mtl.data_type in ('Level-2A', 'L2TP', 'L2A'):
144-
config.overload('s2_processing_level=LEVEL2A')
145-
logger.info("Processing Level-2A product: Atmospheric correction is disabled.")
146-
# do not run SMAC doAtmcor processing block,
147-
s2l_product.context.doAtmcor = False
148-
# intercalibration only for L1C, so disable it
149-
s2l_product.context.doInterCalibration = False
150-
else:
151-
config.overload('s2_processing_level=LEVEL1C')
152-
153133
return s2l_product
154134

155135

@@ -215,10 +195,12 @@ def process_tile(tile: str, search_urls: list[tuple], args: Namespace, start_dat
215195
processing_context
216196
)
217197

218-
# run sen2cor if any and update s2l_product.context
219-
s2l_product = pre_process_atmcor(s2l_product, tile)
198+
if processing_context.doAtmcor:
199+
# run sen2cor if any and update s2l_product.context
200+
s2l_product = pre_process_atmcor(s2l_product, tile)
220201

221-
if not s2l_product:
202+
# sen2cor fail or cloud cover condition not fulfilled
203+
if not s2l_product or not filter_product(s2l_product):
222204
continue
223205

224206
# Configure a product preparator

0 commit comments

Comments
 (0)