forked from inaos/iron-array-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiarray_mean_disk.py
More file actions
80 lines (62 loc) · 2.12 KB
/
Copy pathiarray_mean_disk.py
File metadata and controls
80 lines (62 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from time import time
t0 = time()
import iarray as ia
t = time() - t0
print("iarray import time ->", round(t, 3))
#ia_precip = ia.open("precip-3m.iarr")
#chunkshape = ia_precip.chunkshape[1:]
#blockshape = ia_precip.blockshape[1:]
#print("-->", ia_precip.info)
# precip1 = ia_precip[0].copy(chunkshape=chunkshape, blockshape=blockshape)
# precip2 = ia_precip[1].copy(chunkshape=chunkshape, blockshape=blockshape)
# precip3 = ia_precip[2].copy(chunkshape=chunkshape, blockshape=blockshape)
# print("1 -->", precip1.info)
# precip1 = ia_precip[0].copy()
# precip2 = ia_precip[1].copy()
# precip3 = ia_precip[2].copy()
# print("1 -->", precip1.info)
# ia.save(precip1, "precip1.iarr")
# ia.save(precip2, "precip2.iarr")
# ia.save(precip3, "precip3.iarr")
#@profile
def iarray_open_data():
precip1 = ia.open("precip1.iarr")
precip2 = ia.open("precip2.iarr")
precip3 = ia.open("precip3.iarr")
return precip1, precip2, precip3
t0 = time()
precip1, precip2, precip3 = iarray_open_data()
t = time() - t0
print("open time ->", round(t, 3))
print("2 -->", precip1.info)
chunkshape = precip1.chunkshape
blockshape = precip1.blockshape
storage = ia.Storage(chunkshape=precip1.chunkshape, blockshape=precip1.blockshape)
#cfg = ia.Config(nthreads=14, storage=storage, clevel=1, codec=ia.Codecs.ZSTD, filters=[ia.Filters.BITSHUFFLE])
cfg = ia.Config(storage=storage)
@profile
def iarray_mean_disk(expr):
with ia.config(urlpath="mean-3m.iarr", cfg=cfg) as cfg2:
expr_val = expr.eval(cfg=cfg2)
return expr_val
t0 = time()
mean_expr = (precip1 + precip2 + precip3) / 3
t = time() - t0
print("mean expr time ->", round(t, 3))
t0 = time()
mean_disk = iarray_mean_disk(mean_expr)
t = time() - t0
print("mean eval time ->", round(t, 3))
mean_disk.info
@profile
def iarray_trans_disk(expr):
with ia.config(urlpath="trans-3m.iarr", cfg=cfg) as cfg2:
expr_val = expr.eval(cfg=cfg2)
return expr_val
trans_expr = (
ia.tan(precip1) * (ia.sin(precip1) * ia.sin(precip2) + ia.cos(precip2)) + ia.sqrt(precip3) * 2
)
t0 = time()
trans_val = iarray_trans_disk(trans_expr)
t = time() - t0
print("trans eval time ->", round(t, 3))