Skip to content

Commit 150eb50

Browse files
Update the reading of spectral response, i.e. central wavelength (cw) and fwhm for HCO coregistered products
1 parent c3c4db1 commit 150eb50

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
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"

0 commit comments

Comments
 (0)