Skip to content

Commit 582632a

Browse files
Merge branch 'develop'
2 parents fd1c6f6 + 75997f6 commit 582632a

File tree

19 files changed

+103
-81
lines changed

19 files changed

+103
-81
lines changed

prisma4sen2like/prisma/adapter.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def interpolate_gps_position(v):
9595
for rec in u[1:]:
9696
i = np.where(v == rec)[0][0]
9797
indice.append(i)
98-
print(indice)
9998
x_0 = np.linspace(1, v.shape[0], v.shape[0])
10099
# linear interpolation :
101100
x = np.array(indice)
@@ -357,9 +356,9 @@ def _extract_mask(self, grid, values: list[int], output_file_path: str) -> NDArr
357356
dest_mask[mask == val] = 1
358357
logger.debug(dest_mask[dest_mask == val])
359358

360-
logger.info("NB maked px %s", len(dest_mask[dest_mask >= 1]))
359+
logger.debug("NB maked px %s", len(dest_mask[dest_mask >= 1]))
361360

362-
logger.info("maked px %s", dest_mask[dest_mask >= 1])
361+
logger.debug("maked px %s", dest_mask[dest_mask >= 1])
363362

364363
image = Image.fromarray(dest_mask)
365364
image.save(output_file_path)
@@ -472,8 +471,6 @@ def _compute_orbital_model(self):
472471
pos_y = interpolate_gps_position(np.array(list(self._product.product["Info/Ancillary/PVSdata/Wgs84_pos_y"])))
473472
pos_z = interpolate_gps_position(np.array(list(self._product.product["Info/Ancillary/PVSdata/Wgs84_pos_z"])))
474473

475-
print(pos_x[0], pos_y[0], pos_z[0])
476-
477474
lat_lon_grids = self._product.lat_lon_grids
478475

479476
lat = np.pi / 180.0 * np.rot90(lat_lon_grids[0], k=-1)
@@ -511,7 +508,6 @@ def _compute_orbital_model(self):
511508
r = res / res2
512509
zenith = (np.arccos(res / res2)) * 180 / np.pi
513510
# zenith -> off nadir
514-
print(f"zenith {np.mean(zenith)}")
515511

516512
# compute azimuth:
517513
# consider directionnal vector (d)
@@ -528,14 +524,9 @@ def _compute_orbital_model(self):
528524

529525
azimuth[azimuth < 0] = azimuth[azimuth < 0] + 360
530526

531-
print(f"azimuth {np.mean(azimuth)}")
532-
533527
self._viewing_zenith_angle = np.mean(zenith)
534528
self._viewing_azimuth_angle = np.mean(azimuth)
535529

536-
print(f"Sun_azimuth_angle {self._product.product.attrs['Sun_azimuth_angle']}")
537-
print(f"Sun_zenith_angle {self._product.product.attrs['Sun_zenith_angle']}")
538-
539530
@property
540531
def viewing_angle_grid(self) -> AngleGrid:
541532
# _viewing_zenith_angle and _viewing_azimuth_angle

prisma4sen2like/prisma/spectral_aggregation_functions.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,31 @@ def generate_aggregation_coefficients_prisma_s2(product_file):
3636
n_detectors = 1000
3737

3838
# Compute spectral aggregation coefficients (PRISMA => S2-MSI-A)
39-
index_start_vnir = 96
40-
index_stop_vnir = 162
41-
index_start_swir = 81
42-
index_stop_swir = 254
43-
prisma_vnir_wl = product_file["KDP_AUX/Cw_Vnir_Matrix"][:, index_start_vnir:index_stop_vnir]
44-
prisma_vnir_fwhm = product_file["KDP_AUX/Fwhm_Vnir_Matrix"][:, index_start_vnir:index_stop_vnir]
45-
prisma_swir_wl = product_file["KDP_AUX/Cw_Swir_Matrix"][:, index_start_swir:index_stop_swir]
46-
prisma_swir_fwhm = product_file["KDP_AUX/Fwhm_Swir_Matrix"][:, index_start_swir:index_stop_swir]
39+
40+
# Read matrix of central wavelength and fwhm for each detector (case of not coregistered products)
41+
# This part is commented as not used when working with coregistered products (HCO)
42+
# This part could be uncommented in future if working with not coregistered products.
43+
# index_start_vnir = 96
44+
# index_stop_vnir = 162
45+
# index_start_swir = 81
46+
# index_stop_swir = 254
47+
# prisma_vnir_wl = product_file["KDP_AUX/Cw_Vnir_Matrix"][:, index_start_vnir:index_stop_vnir]
48+
# prisma_vnir_fwhm = product_file["KDP_AUX/Fwhm_Vnir_Matrix"][:, index_start_vnir:index_stop_vnir]
49+
# prisma_swir_wl = product_file["KDP_AUX/Cw_Swir_Matrix"][:, index_start_swir:index_stop_swir]
50+
# prisma_swir_fwhm = product_file["KDP_AUX/Fwhm_Swir_Matrix"][:, index_start_swir:index_stop_swir]
51+
52+
# For coregistered cubes (HCO), read central wavelength and fwhm (VNIR & SWIR) using
53+
# the GLOBAL attributes: List_Cw_Vnir, List_Fwhm_Vnir, List_Cw_Swir, List_Fwhm_Swir
54+
prisma_vnir_wl_list = np.float32(product_file.attrs.get("List_Cw_Vnir"))
55+
prisma_vnir_fwhm_list = np.float32(product_file.attrs.get("List_Fwhm_Vnir"))
56+
prisma_swir_wl_list = np.float32(product_file.attrs.get("List_Cw_Swir"))
57+
prisma_swir_fwhm_list = np.float32(product_file.attrs.get("List_Fwhm_Swir"))
58+
59+
# Replicate prisma_vnir_wl values per column with single List_cw_vnir value
60+
prisma_vnir_wl = np.tile(prisma_vnir_wl_list, (n_detectors, 1))
61+
prisma_vnir_fwhm = np.tile(prisma_vnir_fwhm_list, (n_detectors, 1))
62+
prisma_swir_wl = np.tile(prisma_swir_wl_list, (n_detectors, 1))
63+
prisma_swir_fwhm = np.tile(prisma_swir_fwhm_list, (n_detectors, 1))
4764

4865
n_bands_prisma_vnir = prisma_vnir_wl.shape[1]
4966
n_bands_prisma_swir = prisma_swir_wl.shape[1]

prisma4sen2like/prisma/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"""version info module."""
1919

2020

21-
__version__ = "00.01.00"
21+
__version__ = "00.01.01"

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

0 commit comments

Comments
 (0)