How to use the datacube.api.workflow.format_date function in datacube

To help you get started, we’ve selected a few datacube examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GeoscienceAustralia / agdc / api-examples / source / main / python / workflow / wetness_with_stats.py View on Github external
def output(self):

        from datacube.api.workflow import format_date
        from datacube.api.utils import get_satellite_string

        acq_min = format_date(self.acq_min)
        acq_max = format_date(self.acq_max)

        filename = "{satellites}_WETNESS_STATISTICS_{x:03d}_{y:04d}_{acq_min}_{acq_max}.tif".format(
            satellites=get_satellite_string(self.satellites), x=self.x, y=self.y, acq_min=acq_min, acq_max=acq_max
        )

        filename = os.path.join(self.output_directory, filename)

        return luigi.LocalTarget(filename)
github GeoscienceAustralia / agdc / api-examples / source / main / python / workflow / wetness_with_stats.py View on Github external
def get_statistic_filename(self, statistic, ulx, uly, lrx, lry):
        from datacube.api.utils import get_satellite_string
        from datacube.api.workflow import format_date

        # if statistic in [Statistic.PERCENTILE_25, Statistic.PERCENTILE_50, Statistic.PERCENTILE_75,
        #                  Statistic.PERCENTILE_90, Statistic.PERCENTILE_95]:
        #     statistic_name = "PERCENTILE"
        # else:
        #     statistic_name = statistic.name
        statistic_name = statistic.name

        filename = "{satellites}_WETNESS_{statistic}_{x:03d}_{y:04d}_{acq_min}_{acq_max}_{ulx:04d}_{uly:04d}_{lrx:04d}_{lry:04d}.npy".format(
            satellites=get_satellite_string(self.satellites), statistic=statistic_name,
            x=self.x, y=self.y, acq_min=format_date(self.acq_min), acq_max=format_date(self.acq_max),
            ulx=ulx, uly=uly, lrx=lrx, lry=lry)
        return os.path.join(self.output_directory, filename)
github GeoscienceAustralia / agdc / api / source / main / python / datacube / api / workflow / band_stack.py View on Github external
def output(self):

        from datacube.api.workflow import format_date
        from datacube.api.utils import get_satellite_string

        acq_min = format_date(self.acq_min)
        acq_max = format_date(self.acq_max)

        dataset_type_string = {
            DatasetType.ARG25: "NBAR",
            DatasetType.PQ25: "PQA",
            DatasetType.FC25: "FC",
            DatasetType.WATER: "WATER",
            DatasetType.NDVI: "NDVI",
            DatasetType.EVI: "EVI",
            DatasetType.NBR: "NBR",
            DatasetType.TCI: "TCI",
            DatasetType.DSM: "DSM"
        }[self.dataset_type]

        if self.mask_pqa_apply and self.mask_wofs_apply:
            dataset_type_string += "_WITH_PQA_WATER"
github GeoscienceAustralia / agdc / api-examples / source / main / python / workflow / pixel_statistics.py View on Github external
def output(self):

        from datacube.api.workflow import format_date
        from datacube.api.utils import get_satellite_string

        acq_min = format_date(self.acq_min)
        acq_max = format_date(self.acq_max)

        filename = "{satellites}_OUTPUT_{x:03d}_{y:04d}_{acq_min}_{acq_max}_{band}_{ulx:04d}_{uly:04d}_{lrx:04d}_{lry:04d}.tif".format(
            satellites=get_satellite_string(self.satellites), x=self.x, y=self.y, acq_min=acq_min, acq_max=acq_max,
            band=self.band,
            ulx=self.x_offset, uly=self.y_offset,
            lrx=(self.x_offset + self.chunk_size_x),
            lry=(self.y_offset + self.chunk_size_y)
        )

        filename = os.path.join(self.output_directory, filename)

        return luigi.LocalTarget(filename)
github GeoscienceAustralia / agdc / api-examples / source / main / python / workflow / pixel_statistics.py View on Github external
def output(self):

        from datacube.api.workflow import format_date
        from datacube.api.utils import get_satellite_string

        acq_min = format_date(self.acq_min)
        acq_max = format_date(self.acq_max)

        filename = "{satellites}_OUTPUT_{x:03d}_{y:04d}_{acq_min}_{acq_max}_{band}.tif".format(
            satellites=get_satellite_string(self.satellites), x=self.x, y=self.y, acq_min=acq_min, acq_max=acq_max,
            band=self.band
        )

        filename = os.path.join(self.output_directory, filename)

        return luigi.LocalTarget(filename)
github GeoscienceAustralia / agdc / api / source / main / python / datacube / api / utils.py View on Github external
(mask_vector_apply and "_VECTOR" or "")

    ext = {OutputFormat.GEOTIFF: "tif", OutputFormat.ENVI: "dat"}[output_format]

    if season:
        filename_template = "{satellite}_{dataset}_{x:03d}_{y:04d}_{acq_min}_{acq_max}_{season_name}_{season_start}_{season_end}_{band}_STACK.{ext}"

        season_name, (season_start_month, season_start_day), (season_end_month, season_end_day) = season

        _, _, include = build_date_criteria(acq_min, acq_max, season_start_month, season_start_day, season_end_month, season_end_day)

        season_start = "{month}_{day:02d}".format(month=season_start_month.name[:3], day=season_start_day)
        season_end = "{month}_{day:02d}".format(month=season_end_month.name[:3], day=season_end_day)

        filename = filename_template.format(satellite=satellite_str, dataset=dataset_type_str, x=x, y=y,
                                            acq_min=format_date(acq_min), acq_max=format_date(acq_max),
                                            season_name=season.name, season_start=season_start, season_end=season_end,
                                            band=band.name, ext=ext)
    else:
        filename_template = "{satellite}_{dataset}_{x:03d}_{y:04d}_{acq_min}_{acq_max}_{band}_STACK.{ext}"

        filename = filename_template.format(satellite=satellite_str, dataset=dataset_type_str, x=x, y=y,
                                            acq_min=format_date(acq_min), acq_max=format_date(acq_max),
                                            band=band.name, ext=ext)

    return filename
github GeoscienceAustralia / agdc / api-examples / source / main / python / workflow / wetness_stack.py View on Github external
print "+++", filename

            log_mem("Before get data")

            data = read_dataset_data(filename, bands=[TciBands.WETNESS])

            log_mem("After get data")

            band = raster.GetRasterBand(index)

            band.SetDescription(os.path.basename(filename))
            band.SetNoDataValue(numpy.nan)
            band.WriteArray(data)
            band.ComputeStatistics(True)
            band.SetMetadata({"ACQ_DATE": format_date(tile.end_datetime), "SATELLITE": tile.datasets[DatasetType.TCI].satellite.name})

            band.FlushCache()
            del band

        raster.FlushCache()
        del raster
github GeoscienceAustralia / agdc / api / source / main / python / datacube / api / workflow / band_stack.py View on Github external
def output(self):

        from datacube.api.workflow import format_date
        from datacube.api.utils import get_satellite_string

        acq_min = format_date(self.acq_min)
        acq_max = format_date(self.acq_max)

        dataset_type_string = {
            DatasetType.ARG25: "NBAR",
            DatasetType.PQ25: "PQA",
            DatasetType.FC25: "FC",
            DatasetType.WATER: "WATER",
            DatasetType.NDVI: "NDVI",
            DatasetType.EVI: "EVI",
            DatasetType.NBR: "NBR",
            DatasetType.TCI: "TCI",
            DatasetType.DSM: "DSM"
        }[self.dataset_type]

        if self.mask_pqa_apply and self.mask_wofs_apply:
            dataset_type_string += "_WITH_PQA_WATER"
github GeoscienceAustralia / agdc / api-examples / source / main / python / workflow / bare_soil.py View on Github external
def get_dataset_filename(self, dataset):

        from datacube.api.workflow import format_date
        from datacube.api.utils import get_satellite_string

        satellites = get_satellite_string(self.satellites)

        acq_min = format_date(self.acq_min)
        acq_max = format_date(self.acq_max)

        return os.path.join(self.output_directory,
            "{satellites}_{dataset}_{x:03d}_{y:04d}_{acq_min}_{acq_max}.tif".format(
            satellites=satellites,
            dataset=dataset,
            x=self.x, y=self.y,
            acq_min=acq_min,
            acq_max=acq_max))
github GeoscienceAustralia / agdc / api-examples / source / main / python / workflow / observation_count.py View on Github external
def output(self):

        from datacube.api.workflow import format_date
        from datacube.api.utils import get_satellite_string

        satellites = get_satellite_string(self.satellites)

        acq_min = format_date(self.acq_min)
        acq_max = format_date(self.acq_max)

        filename = os.path.join(self.output_directory,
                                "{satellites}_OBSCOUNT_{x:03d}_{y:04d}_{acq_min}_{acq_max}.tif".format(
                                    satellites=satellites,
                                    x=self.x, y=self.y,
                                    acq_min=acq_min,
                                    acq_max=acq_max))

        return luigi.LocalTarget(filename)