Skip to content

Commit

Permalink
Switch to delayed reading for sentinel 2
Browse files Browse the repository at this point in the history
glymur isn't thread safe, from_array can't work
  • Loading branch information
mraspaud committed May 14, 2018
1 parent dacf154 commit b3c532c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions satpy/readers/safe_msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
# import xml.etree.ElementTree as ET

import glymur
# import numpy as np
import numpy as np
# from osgeo import gdal
from xarray import DataArray
from dask.array import from_array
from dask.array import from_delayed
from dask import delayed

from satpy import CHUNK_SIZE
# from geotiepoints.geointerpolator import GeoInterpolator
Expand Down Expand Up @@ -64,8 +65,9 @@ def get_dataset(self, key, info):
bitdepth = max(bitdepth, seg.bitdepth[0])
except AttributeError:
pass
# jp2.dtype = (np.uint8 if bitdepth <= 8 else np.uint16)
data = from_array(jp2[:], chunks=CHUNK_SIZE) / QUANTIFICATION_VALUE * 100
jp2.dtype = (np.uint8 if bitdepth <= 8 else np.uint16)
data = from_delayed(delayed(jp2.read)(), jp2.shape, jp2.dtype)
data = data.rechunk(CHUNK_SIZE) / QUANTIFICATION_VALUE * 100

proj = DataArray(data, dims=['y', 'x'])
proj.attrs = info.copy()
Expand Down

0 comments on commit b3c532c

Please sign in to comment.