Commit 12a02e25 authored by Gilles Guitton's avatar Gilles Guitton

- mappers Sentinel-2 : use tuple of slices rather than list of slices.

parent 80a99b25
......@@ -483,7 +483,7 @@ class SAFEMSIL1CGranuleFile(AbstractMapper):
yindmin = int(np.maximum(0, np.floor(ymaxind)))
yindmax = int(np.minimum(self._attrs['ncols'], np.ceil(yminind)))
# Create tight slices (equivalent to view slices in other mappers)
slices = [slice(yindmin, yindmax, 1), slice(xindmin, xindmax, 1)]
slices = (slice(yindmin, yindmax, 1), slice(xindmin, xindmax, 1))
dimsizes = [self._attrs['ncols'], self._attrs['nrows']]
self._tight_slices = Slices(slices, dimsizes)
# Update attributes
......@@ -629,9 +629,9 @@ class SAFEMSIL1CGranuleFile(AbstractMapper):
epsg = self.read_global_attribute('horizontal_cs_code')
proj = pyproj.Proj(init=epsg)
shp = slices.shape()
y = np.tile(self.read_values('y', slices=[slices[0]])[:, np.newaxis],
y = np.tile(self.read_values('y', slices=(slices[0],))[:, np.newaxis],
(1, shp[1]))
x = np.tile(self.read_values('x', slices=[slices[1]])[np.newaxis, :],
x = np.tile(self.read_values('x', slices=(slices[1],))[np.newaxis, :],
(shp[0], 1))
lon, lat = proj(x, y, inverse=True)
if fieldname == 'lon':
......@@ -712,8 +712,8 @@ class SAFEMSIL1CGranuleFile(AbstractMapper):
nodatavalue=float(fillvalue))
indmin = [i.min() for i in ind]
indmax = [i.max() + 1 for i in ind]
rel_slices = Slices([slice(indmin[0], indmax[0]),
slice(indmin[1], indmax[1])],
rel_slices = Slices((slice(indmin[0], indmax[0]),
slice(indmin[1], indmax[1])),
det_ind.shape)
abs_slices = rel_slices.absolute_slices(slices)
target_ds = self._get_gdal_dataset_from_slices(abs_slices,
......@@ -954,8 +954,8 @@ class SAFEMSIL1CGranuleFile(AbstractMapper):
tuple: bbox expressed as (lonmin, latmin, lonmax, latmax)
"""
dimsizes = self.get_full_dimensions('lon').values()
slices = [slice(None, None, dimsizes[0] - 1),
slice(None, None, dimsizes[1] - 1)]
slices = (slice(None, None, dimsizes[0] - 1),
slice(None, None, dimsizes[1] - 1))
lon = self.read_values('lon', slices=slices)
lat = self.read_values('lat', slices=slices)
return (lon.min(), lat.min(), lon.max(), lat.max())
......
......@@ -283,9 +283,9 @@ class SAFEMSIL1CStitchedFile(AbstractMapper):
epsg = self.read_global_attribute('horizontal_cs_code')
proj = pyproj.Proj(init=epsg)
shp = slices.shape()
y = np.tile(self.read_values('y', slices=[slices[0]])[:, np.newaxis],
y = np.tile(self.read_values('y', slices=(slices[0],))[:, np.newaxis],
(1, shp[1]))
x = np.tile(self.read_values('x', slices=[slices[1]])[np.newaxis, :],
x = np.tile(self.read_values('x', slices=(slices[1],))[np.newaxis, :],
(shp[0], 1))
lon, lat = proj(x, y, inverse=True)
if fieldname == 'lon':
......@@ -500,8 +500,8 @@ class SAFEMSIL1CStitchedFile(AbstractMapper):
tuple: bbox expressed as (lonmin, latmin, lonmax, latmax)
"""
dimsizes = self.get_full_dimensions('lon').values()
slices = [slice(None, None, dimsizes[0] - 1),
slice(None, None, dimsizes[1] - 1)]
slices = (slice(None, None, dimsizes[0] - 1),
slice(None, None, dimsizes[1] - 1))
lon = self.read_values('lon', slices=slices)
lat = self.read_values('lat', slices=slices)
return (lon.min(), lat.min(), lon.max(), lat.max())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment