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.mean(axis=0)
14
15
from matplotlib import pyplot as plt
16
fig = plt.figure(figsize=(16, 8))
17
plt.imshow(result, cmap='RdBu_r')
18
19
result = x[0] - x.mean(axis=0)
20
fig = plt.figure(figsize=(16, 8))
21
plt.imshow(result, cmap='RdBu_r')
22
23