Example #1
0
    def setUpClass(cls):
        """
        Creates GeoTIFF test, multiple single-time and single-variable NetCDF and single multi-time and
        multi-variable NetCDF data.
        """

        setup_gt_test_data()
        setup_nc_multi_test_data()
        setup_nc_single_test_data()
Example #2
0
    def setUp(self):
        """
        Retrieves test data filepaths and auxiliary data and creates temporary reference data as NumPy arrays,
        xarray arrays and Pandas data frames.
        """

        self.gt_filepaths, self.timestamps = setup_gt_test_data()
        self.nc_filepaths, _ = setup_nc_multi_test_data()
        self.nc_filepath, _ = setup_nc_single_test_data()

        self.lon = 5.
        self.lat = 44.
        sref = osr.SpatialReference()
        sref.ImportFromEPSG(4326)
        self.sref = sref
        row = 970
        col = 246
        self.x = 4323250.
        self.y = 1314750.

        self.ref_np_ar = (np.array([[[row + col] * 4]]).T +
                          np.arange(0, 4)[:, None, None]).astype(float)
        xr_ar = xr.DataArray(data=da.array(
            self.ref_np_ar.astype(float)).rechunk((1, 1, 1)),
                             coords={
                                 'time': self.timestamps,
                                 'y': [self.y],
                                 'x': [self.x]
                             },
                             dims=['time', 'y', 'x'])
        self.ref_xr_ds = xr.Dataset(data_vars={'1': xr_ar})
        self.ref_pd_df = self.ref_xr_ds.to_dataframe()
Example #3
0
    def setUp(self):
        """
        Retrieves test data filepaths and auxiliary data and creates temporary reference data as NumPy arrays,
        xarray arrays and Pandas data frames.
        """

        self.gt_filepaths, self.timestamps = setup_gt_test_data()
        self.nc_filepaths, _ = setup_nc_multi_test_data()
        self.nc_filepath, _ = setup_nc_single_test_data()

        row = 246
        col = 970
        x = 4323250.
        y = 1314750.
        row_size = 10
        col_size = 16
        sres = 500.

        # define bounding boxes
        # general bounding box for reading data
        x_min = x
        x_max = x + col_size * sres
        y_min = y - row_size * sres
        y_max = y
        self.bbox = [(x_min, y_min), (x_max, y_max)]
        # defines bounding box being partially outside the tile (lower right corner)
        x_lr = 4800000.0
        y_lr = 1200000.0
        x_min = x_lr - col_size * sres
        x_max = x_lr + 2 * col_size * sres
        y_min = y_lr - 2 * row_size * sres
        y_max = y_lr + row_size * sres
        self.partial_outside_bbox = [(x_min, y_min), (x_max, y_max)]
        self.outside_bbox = [(0, 0), (1, 1)]

        rows, cols = np.meshgrid(np.arange(row, row + row_size),
                                 np.arange(col, col + col_size),
                                 indexing='ij')
        xs = np.arange(x, x + col_size * sres, sres)
        ys = np.arange(y, y - row_size * sres, -sres)
        base_np_ar_2D = rows + cols
        base_np_ar = np.stack([base_np_ar_2D] * 4, axis=0)
        self.ref_np_ar_area = (base_np_ar +
                               np.arange(0, 4)[:, None, None]).astype(float)
        xr_ar = xr.DataArray(data=da.array(
            self.ref_np_ar_area.astype(float)).rechunk(
                (1, row_size, col_size)),
                             coords={
                                 'time': self.timestamps,
                                 'y': ys,
                                 'x': xs
                             },
                             dims=['time', 'y', 'x'])
        self.ref_xr_ds_area = xr.Dataset(data_vars={'1': xr_ar})
        self.ref_pd_df_area = self.ref_xr_ds_area.to_dataframe()
Example #4
0
    def setUp(self):
        """
        Retrieves test data filepaths and auxiliary data and creates temporary reference data as NumPy arrays,
        xarray arrays and Pandas data frames.
        """

        self.gt_filepaths, self.timestamps = setup_gt_test_data()
        self.nc_filepaths, _ = setup_nc_multi_test_data()
        self.nc_filepath, _ = setup_nc_single_test_data()

        self.row = 970
        self.col = 246
        self.row_size = 10
        self.col_size = 16
        x = 4323250.
        y = 1314750.
        sres = 500.

        self.ref_np_ar = (np.array([[[self.row + self.col] * 4]]).T +
                          np.arange(0, 4)[:, None, None]).astype(float)
        xr_ar = xr.DataArray(data=self.ref_np_ar.astype(float),
                             coords={
                                 'time': self.timestamps,
                                 'y': [y],
                                 'x': [x]
                             },
                             dims=['time', 'y', 'x'])
        self.ref_xr_ds = xr.Dataset(data_vars={'1': xr_ar})
        self.ref_pd_df = self.ref_xr_ds.to_dataframe()
        rows, cols = np.meshgrid(np.arange(self.row, self.row + self.row_size),
                                 np.arange(self.col, self.col + self.col_size),
                                 indexing='ij')
        xs = np.arange(x, x + self.col_size * sres, sres)
        ys = np.arange(y, y - self.row_size * sres, -sres)
        base_np_ar_2D = rows + cols
        base_np_ar = np.stack([base_np_ar_2D] * 4, axis=0)
        self.ref_np_ar_area = (base_np_ar +
                               np.arange(0, 4)[:, None, None]).astype(float)
        xr_ar = xr.DataArray(data=da.array(
            self.ref_np_ar_area.astype(float)).rechunk(
                (1, self.row_size, self.col_size)),
                             coords={
                                 'time': self.timestamps,
                                 'y': ys,
                                 'x': xs
                             },
                             dims=['time', 'y', 'x'])
        self.ref_xr_ds_area = xr.Dataset(data_vars={'1': xr_ar})
        self.ref_pd_df_area = self.ref_xr_ds_area.to_dataframe()
Example #5
0
    def setUp(self):
        """ Retrieves test data filepaths and auxiliary data. """

        self.filepaths, self.timestamps = setup_gt_test_data()
        self.data_dirpath = os.path.join(dirpath_test(), 'data',
                                         'Sentinel-1_CSAR')
Example #6
0
    def setUpClass(cls):
        """ Creates GeoTIFF test data. """

        setup_gt_test_data()
Example #7
0
    def setUp(self):
        """ Retrieves test data filepaths and auxiliary data. """

        self.gt_filepaths, self.timestamps = setup_gt_test_data()