TUW-GEO / repurpose

Routines for the conversion of image formats to time series and vice versa.
Other
4 stars 4 forks source link

Check for CellGrid in Img2Ts is wrong #12

Closed s-scherrer closed 3 years ago

s-scherrer commented 3 years ago

The constructor of Img2Ts does the following check on the target_grid:

        # if the target grid is not a cell grid make it one
        # default is just one cell for the
        # this is just a dirty hack until grids have a method
        # to check their grid type
        if (type(self.target_grid) == grids.BasicGrid or
            (pygeogrids.grids.BasicGrid in type(self.target_grid).__bases__ and
             len(type(self.target_grid).__bases__))) == 1:

            self.target_grid = self.target_grid.to_cell_grid(cellsize_lat=cellsize_lat,
                                                             cellsize_lon=cellsize_lon)

However, when using a CellGrid, the condition evaluates to True. Therefore the target_grid is again converted to a cell_grid, but probably with different cellsizes.

I would propose to instead test whether the expected functions of the target grid are available, e.g. get_cells, or whether it has the attribute arrcell.