Skip to content
Snippets Groups Projects
Commit fecd65d1 authored by pascal.mouquet_ird.fr's avatar pascal.mouquet_ird.fr
Browse files

faster QL rvb generation (x60!)

parent 4bd2b2a4
No related branches found
No related tags found
No related merge requests found
......@@ -212,7 +212,7 @@ def create_rvb(
:param out_path: path to the output.
:param out_crs: output CRS.
:param clouds_color: color of the clouds (black or white).
:param out_resolution: output resolution.
:param out_resolution: output resolution (pixel size (m)).
"""
# LOGGER.info("creating colormap")
logger.info("creating rvb QL")
......@@ -243,23 +243,22 @@ def create_rvb(
out_crs = None
print("Invalid CRS: {}\nUsing source raster CRS".format(e))
fact = int(1000 // out_resolution[0])
fact_cld = int(1000 // (2*out_resolution[0]))
logger.info('{} {}'.format(fact, fact_cld))
with rasterio.open(str(raster)) as src:
raster_band = src.read(1)
raster_band = src.read(1, out_shape=(1, int(src.height // fact), int(src.height // fact)))
profile = src.profile
if cloud_mask:
with rasterio.open(str(cloud_mask)) as cld_src:
clouds_band = cld_src.read(1)
# resample cloud_mask to raster grid
cld_reproj = np.empty(raster_band.shape, dtype=np.uint8)
reproject(source=clouds_band,
destination=cld_reproj,
src_transform=cld_src.transform,
src_crs=cld_src.crs,
dst_transform=src.transform,
dst_crs=src.crs,
resampling=Resampling.nearest)
# clouds
cld_reproj = cld_src.read(1, out_shape=(1, int(cld_src.height // fact_cld),
int(cld_src.height // fact_cld)))
cld_band = cld_src.read(1)
logger.info(cld_band.shape)
logger.info(cld_reproj.shape)
raster_band = np.where(cld_reproj == 0, raster_band, 16383)
# band_mask_borders = np.where(raster_band != 32767, raster_band, -10000)
......
......@@ -138,6 +138,11 @@ class Ndvi(Indice):
# # lut_dict=get_colormap(self._colors_table_path.absolute()),
# lut_dict=cmap, clouds_color="white",
# out_path=(self.out_path / quicklook_filename))
#~ create_colormap2(raster=(self.out_path / self.indice_filename),
#~ cloud_mask=self.l2a_product.user_cloud_mask,
#~ # lut_dict=get_colormap(self._colors_table_path.absolute()),
#~ lut_dict=cmap, clouds_color="white",
#~ out_path=(self.out_path / quicklook_filename))
create_rvb(raster=(self.out_path / self.indice_filename),
cloud_mask=self.l2a_product.user_cloud_mask,
# lut_dict=get_colormap(self._colors_table_path.absolute()),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment