Пример #1
0
    def __init__(self,
                 product,
                 geobox,
                 times,
                 resampling=None,
                 style=None,
                 bands=None,
                 **kwargs):
        super(DataStacker, self).__init__(**kwargs)
        self._product = product
        self.cfg = product.global_cfg
        self._geobox = geobox
        self._resampling = resampling if resampling is not None else Resampling.nearest
        if style:
            self._needed_bands = style.needed_bands
        elif bands:
            self._needed_bands = [
                self._product.band_idx.band(b) for b in bands
            ]
        else:
            self._needed_bands = self._product.band_idx.native_bands.index

        self.raw_times = times
        if self._product.is_month_time_res:
            self._times = list([month_date_range(t) for t in times])
            self.group_by = group_by_statistical()
        elif self._product.is_year_time_res:
            self._times = list([year_date_range(t) for t in times])
            self.group_by = group_by_statistical()
        else:
            self._times = list(
                [local_solar_date_range(geobox, t) for t in times])
            self.group_by = "solar_day"
Пример #2
0
 def search_times(self, t, geobox):
     if self.is_month_time_res:
         return month_date_range(t)
     elif self.is_year_time_res:
         return year_date_range(t)
     else:
         return local_solar_date_range(geobox, t)
 def search_times(self, t, geobox=None):
     if self.is_month_time_res:
         return month_date_range(t)
     elif self.is_year_time_res:
         return year_date_range(t)
     else:
         if not geobox:
             bbox = self.ranges["bboxes"][self.native_CRS]
             geobox = create_geobox(self.native_CRS, bbox["left"],
                                    bbox["bottom"], bbox["right"],
                                    bbox["top"], 1, 1)
         return local_solar_date_range(geobox, t)
Пример #4
0
def test_time_search():
    cfg = get_config()
    lyr = list(cfg.product_index.values())[0]
    time = lyr.ranges["times"][-1]
    geom = box(lyr.bboxes["EPSG:4326"]["bottom"],
               lyr.bboxes["EPSG:4326"]["left"], lyr.bboxes["EPSG:4326"]["top"],
               lyr.bboxes["EPSG:4326"]["right"], "EPSG:4326")

    time_rng = local_solar_date_range(MockGeobox(geom), time)
    with cube() as dc:
        sel = mv_search_datasets(dc.index,
                                 MVSelectOpts.COUNT,
                                 times=[time_rng],
                                 layer=lyr)
        assert sel > 0