def to_npy_stack(dirname, x, axis=0):
 chunks = tuple(((c if (i == axis) else (sum(c),)) for (i, c) in enumerate(x.chunks)))
 xx = x.rechunk(chunks)
 if (not os.path.exists(dirname)):
  os.path.mkdir(dirname)
 meta = {'chunks': chunks, 'dtype': x.dtype, 'axis': axis}
 with open(os.path.join(dirname, 'info'), 'wb') as f:
  pickle.dump(meta, f)
 name = ('to-npy-stack-' + str(uuid.uuid1()))
 dsk = dict((((name, i), (np.save, os.path.join(dirname, ('%d.npy' % i)), key)) for (i, key) in enumerate(core.flatten(xx._keys()))))
 Array._get(merge(dsk, xx.dask), list(dsk))

def to_npy_stack ( dirname , x , axis = 0 ) : chunks = tuple ( ( ( c if ( i == axis ) else ( sum ( c ) , ) ) for ( i , c ) in enumerate ( x . chunks ) ) ) xx = x . rechunk ( chunks ) if ( not os . path . exists ( dirname ) ) : os . path . mkdir ( dirname ) meta = { 'chunks' : chunks , 'dtype' : x . dtype , 'axis' : axis } with open ( os . path . join ( dirname , 'info' ) , 'wb' ) as f : pickle . dump ( meta , f ) name = ( 'to-npy-stack-' + str ( uuid . uuid1 ( ) ) ) dsk = dict ( ( ( ( name , i ) , ( np . save , os . path . join ( dirname , ( '%d.npy' % i ) ) , key ) ) for ( i , key ) in enumerate ( core . flatten ( xx . _keys ( ) ) ) ) ) Array . _get ( merge ( dsk , xx . dask ) , list ( dsk ) )
write dask array to a stack of .