How to concatenate arrays using dask
Often we've got several arrays hold on on disk that we would like to stack along and consider jointly massive array. this is common with geospatial data we might have several HDF5/NetCDF files on disk, one for each day, however we would like to try to to operations that span multiple days.
For concatenating we can use the functions `da.stack, da.concatenate, and da.block`.
import dask.array as da import numpy as np
We will create two sample dask arrays with chunks of size (1,2) for showing how they can be concatenated
array_0 = da.from_array(np.zeros((12, 16)), chunks=(1, 2)) array_1 = da.from_array(np.ones((12, 16)) , chunks=(1, 2))
Concatenating arrays by applying the predefined function.
data = [array_0, array_1] x = da.concatenate(data, axis=1) x.shape