Exemple #1
0
def run(level1: Path, output: Path, h5_file: Path, products: Sequence[str],
        with_oa: bool):
    if products:
        products = set(p.lower() for p in products)
    else:
        products = wagl.DEFAULT_PRODUCTS
    with rasterio.Env():
        for granule in wagl.Granule.for_path(h5_file,
                                             level1_metadata_path=level1):
            with wagl.do(
                    f"Packaging {granule.name}. (products: {', '.join(products)})",
                    heading=True,
                    fmask=bool(granule.fmask_image),
                    fmask_doc=bool(granule.fmask_doc),
                    gqa=bool(granule.gqa_doc),
                    oa=with_oa,
            ):
                dataset_id, dataset_path = wagl.package(
                    out_directory=output,
                    granule=granule,
                    included_products=products,
                    include_oa=with_oa,
                )
                secho(
                    f"Created folder {click.style(str(dataset_path), fg='green')}"
                )
Exemple #2
0
    def run(self):
        # TODO; the package_file func can accept additional fnames for yamls etc
        wagl_fname = Path(self.input()['wagl'].path)
        fmask_img_fname = Path(self.input()['fmask']['image'].path)
        fmask_doc_fname = Path(self.input()['fmask']['metadata'].path)
        gqa_doc_fname = Path(self.input()['gqa'].path)

        md = {}
        for eods_granule in Granule.for_path(wagl_fname,
                                             granule_names=[self.granule],
                                             fmask_image_path=fmask_img_fname,
                                             fmask_doc_path=fmask_doc_fname,
                                             gqa_doc_path=gqa_doc_fname):

            ds_id, md_path = package(Path(self.pkgdir), eods_granule,
                                     self.products)

            md[ds_id] = md_path

        if self.cleanup:
            shutil.rmtree(self.workdir)

        with self.output().temporary_path() as out_fname:
            with open(out_fname, 'w') as outf:
                data = {
                    'params': self.to_str_params(),
                    # JSON can't serialise the returned Path obj
                    'packaged_datasets':
                    {str(k): str(v)
                     for k, v in md.items()},
                }
                json.dump(data, outf)
    def run(self):
        # TODO; the package_file func can accept additional fnames for yamls etc
        wagl_fname = Path(self.input()["wagl"].path)
        fmask_img_fname = Path(self.input()["fmask"]["image"].path)
        fmask_doc_fname = Path(self.input()["fmask"]["metadata"].path)
        gqa_doc_fname = Path(self.input()["gqa"].path)
        if self.yamls_dir is None or self.yamls_dir == "":
            level1_metadata_path = None
        else:
            level1_metadata_path = Path(self.yamls_dir)

        tesp_doc_fname = Path(self.workdir) / "{}.tesp.yaml".format(
            self.granule)
        with tesp_doc_fname.open("w") as src:
            yaml.safe_dump(_get_tesp_metadata(), src)

        md = {}
        for eods_granule in Granule.for_path(
                wagl_fname,
                granule_names=[self.granule],
                fmask_image_path=fmask_img_fname,
                fmask_doc_path=fmask_doc_fname,
                gqa_doc_path=gqa_doc_fname,
                tesp_doc_path=tesp_doc_fname,
                level1_metadata_path=level1_metadata_path,
        ):

            if self.non_standard_packaging:
                ds_id, md_path = package_non_standard(Path(self.pkgdir),
                                                      eods_granule)
            else:
                ds_id, md_path = package(
                    Path(self.pkgdir),
                    eods_granule,
                    product_maturity=self.product_maturity,
                    included_products=self.products,
                )

            md[ds_id] = md_path
            STATUS_LOGGER.info(
                "packaged dataset",
                granule=self.granule,
                level1=self.level1,
                dataset_id=str(ds_id),
                dataset_path=str(md_path),
            )

        if self.cleanup:
            shutil.rmtree(self.workdir)

        with self.output().temporary_path() as out_fname:
            with open(out_fname, "w") as outf:
                data = {
                    "params": self.to_str_params(),
                    # JSON can't serialise the returned Path obj
                    "packaged_datasets":
                    {str(k): str(v)
                     for k, v in md.items()},
                }
                json.dump(data, outf)
Exemple #4
0
def run(
    level1: Path,
    output: Path,
    h5_file: Path,
    products: Sequence[str],
    with_oa: bool,
    product_maturity: wagl.ProductMaturity,
    allow_missing_provenance: bool,
    oa_resolution: Optional[float],
    contiguity_resolution: Optional[float],
):
    if products:
        products = {p.lower() for p in products}
    else:
        products = wagl.DEFAULT_PRODUCTS

    if oa_resolution is not None:
        oa_resolution = (oa_resolution, oa_resolution)
    if contiguity_resolution is not None:
        contiguity_resolution = (contiguity_resolution, contiguity_resolution)

    with rasterio.Env(GDAL_PAM_ENABLED=False):
        for granule in wagl.Granule.for_path(
                h5_file,
                level1_metadata_path=level1,
                allow_missing_provenance=allow_missing_provenance,
        ):
            with wagl.do(
                    f"Packaging {granule.name}. (products: {', '.join(products)})",
                    heading=True,
                    fmask=bool(granule.fmask_image),
                    fmask_doc=bool(granule.fmask_doc),
                    gqa=bool(granule.gqa_doc),
                    oa=with_oa,
            ):
                dataset_id, dataset_path = wagl.package(
                    out_directory=output,
                    granule=granule,
                    product_maturity=product_maturity,
                    included_products=products,
                    include_oa=with_oa,
                    oa_resolution=oa_resolution,
                    contiguity_resolution=contiguity_resolution,
                )
                secho(
                    f"Created folder {click.style(str(dataset_path), fg='green')}"
                )