Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132923 views
License: OTHER
1
import h5py
2
from glob import glob
3
import os
4
5
filenames = sorted(glob(os.path.join('data', 'weather-big', '*.hdf5')))
6
dsets = [h5py.File(filename, mode='r')['/t2m'] for filename in filenames]
7
8
import dask.array as da
9
arrays = [da.from_array(dset, chunks=(500, 500)) for dset in dsets]
10
11
x = da.stack(arrays, axis=0)
12
13
result = x[:, ::2, ::2]
14
15
da.to_hdf5(os.path.join('data', 'myfile.hdf5'), '/output', result)
16
17