def _write_thumbnail(task: AlchemistTask, dataset_assembler: DatasetAssembler): if task.settings.output.preview_image is not None: dataset_assembler.write_thumbnail(*task.settings.output.preview_image) elif task.settings.output.preview_image_singleband is not None: dataset_assembler.write_thumbnail_singleband( **task.settings.output.preview_image_singleband )
def _unpack_products(p: DatasetAssembler, product_list: Iterable[str], h5group: h5py.Group) -> None: """ Unpack and package the NBAR and NBART products. """ # listing of all datasets of IMAGE CLASS type img_paths = _find_h5_paths(h5group, "IMAGE") for product in product_list: with do(f"Starting {product}", heading=True): for pathname in [ p for p in img_paths if "/{}/".format(product.upper()) in p ]: with do(f"Path {pathname!r}"): dataset = h5group[pathname] band_name = utils.normalise_band_name( dataset.attrs["alias"]) write_measurement_h5( p, f"{product}:{band_name}", dataset, overview_resampling=Resampling.average, file_id=_file_id(dataset), ) if (p.platform, product) in _THUMBNAILS: red, green, blue = _THUMBNAILS[(p.platform, product)] with do(f"Thumbnailing {product}"): p.write_thumbnail(red, green, blue, kind=product, static_stretch=(1, 3000))
def _unpack_products(p: DatasetAssembler, product_list: Iterable[str], h5group: h5py.Group) -> None: """ Unpack and package the NBAR and NBART products. """ # listing of all datasets of IMAGE CLASS type img_paths = _find_h5_paths(h5group, "IMAGE") for product in product_list: with sub_product(product, p): for pathname in [ p for p in img_paths if f"/{product.upper()}/" in p ]: with do(f"Path {pathname!r}"): dataset = h5group[pathname] band_name = utils.normalise_band_name( dataset.attrs["alias"]) write_measurement_h5( p, f"{product}:{band_name}", dataset, overview_resampling=Resampling.average, file_id=_file_id(dataset), ) if product in _THUMBNAILS: red, green, blue = _THUMBNAILS[product] with do(f"Thumbnailing {product}"): p.write_thumbnail( red, green, blue, static_stretch=(1, 3000), # Because of our strange sub-products and filename standards, we want the # 'kind' to be included in the recorded thumbnail accessory metadata, # but not in the filename. # So we manually calculate a filename without the 'kind' field included. kind=product, path=p.names.thumbnail_filename(), )