def load_data(sub_tile_slice, sources):
"""
Load a masked chunk of data from the datacube, based on a specification and list of datasets in `sources`.
:param sub_tile_slice: A portion of a tile, tuple coordinates
:param sources: a dictionary containing `data`, `spec` and `masks`
:return: :class:`xarray.Dataset` containing loaded data. Will be indexed and sorted by time.
"""
datasets = [load_masked_data(sub_tile_slice, source_prod)
for source_prod in sources] # list of datasets
datasets = _remove_emptys(datasets)
if len(datasets) == 0:
raise EmptyChunkException()
# TODO: Add check for compatible data variable attributes
# flags_definition between pq products is different and is silently dropped
datasets = xarray.concat(datasets, dim='time') # Copies all the data
if len(datasets.time) == 0:
raise EmptyChunkException()
# sort along time dim
return datasets.isel(time=datasets.time.argsort()) # Copies all the data again
评论列表
文章目录