Skip to content

Commit

Permalink
Support Netcdf for native load test util
Browse files Browse the repository at this point in the history
Native grid computation code didn't handle netcdf correctly as it assumed that
band path was sufficient, it's not for netdcf, going via BandInfo class and
RasterDatasetDataSource addresses this issue.
  • Loading branch information
Kirill888 committed May 14, 2019
1 parent 936033c commit 51647df
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions datacube/testutils/io.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from ..storage import reproject_and_fuse, measurement_paths
from ..storage._rio import RasterioDataSource
from ..storage import reproject_and_fuse, BandInfo
from ..storage._rio import RasterioDataSource, RasterDatasetDataSource
from ..utils.geometry._warp import resampling_s2rio
from ..storage._read import rdr_geobox
from ..utils.geometry import GeoBox
Expand Down Expand Up @@ -32,8 +32,8 @@ def get_crs(self):
return self.crs


def _raster_metadata(path, band=1):
source = RasterFileDataSource(path, band)
def _raster_metadata(band):
source = RasterDatasetDataSource(band)
with source.open() as rdr:
return SimpleNamespace(dtype=rdr.dtype.name,
nodata=rdr.nodata,
Expand All @@ -45,12 +45,10 @@ def get_raster_info(ds, measurements=None):
:param ds: Dataset
:param measurements: List of band names to load
"""
paths = measurement_paths(ds)

if measurements is None:
measurements = list(paths)
measurements = list(ds.type.measurements)

return {n: _raster_metadata(paths[n])
return {n: _raster_metadata(BandInfo(ds, n))
for n in measurements}


Expand Down

0 comments on commit 51647df

Please sign in to comment.