@@ -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 ]
0 commit comments