def test_sub_area(self, adef): """Sub area slicing.""" area = mock.MagicMock() area.pixel_size_x = 1.5 area.pixel_size_y = 1.5 area.pixel_upper_left = (0, 0) area.area_id = 'fakeid' area.name = 'fake name' area.proj_id = 'fakeproj' area.proj_dict = {'fake': 'dict'} hf.get_sub_area(area, slice(1, 4), slice(0, 3)) adef.assert_called_once_with('fakeid', 'fake name', 'fakeproj', {'fake': 'dict'}, 3, 3, (0.75, -3.75, 5.25, 0.75))
def _get_slices(self, area): """Get the slices of raw data covering area. Args: area: the area to slice. Returns: slice_kwargs: kwargs to pass on to loading giving the span of the data to load. area: the trimmed area corresponding to the slices. """ slice_kwargs = {} if area is not None and self._area is not None: try: slices = get_area_slices(area, self._area) area = get_sub_area(area, *slices) slice_kwargs['xslice'], slice_kwargs['yslice'] = slices except (NotImplementedError, AttributeError): logger.info("Cannot compute specific slice of data to load.") return slice_kwargs, area
def _get_slices(self, area): """Get the slices of raw data covering area. Args: area: the area to slice. Returns: slice_kwargs: kwargs to pass on to loading giving the span of the data to load. area: the trimmed area corresponding to the slices. """ slice_kwargs = {} if area is not None and self._area is not None: try: slices = get_area_slices(area, self._area) area = get_sub_area(area, *slices) slice_kwargs['xslice'], slice_kwargs['yslice'] = slices except (NotImplementedError, AttributeError): LOG.info("Cannot compute specific slice of data to load.") return slice_kwargs, area