Scientific programming in Modula-9 — first steps

↖ contents

8 — Data through zarr

Large scientific arrays live in chunked stores: the array is cut into fixed-size chunks, each compressed and addressable by its coordinates, with small JSON metadata describing shape, dtype and fill. Zarr is the convention the ICOS Carbon Portal serves its data with, over plain HTTPS — and ZarrStore is a complete reader for it: metadata parsed and validated at open, blosc decompression, a chunk cache, and every index checked against the shape the store itself declared.

The store in this chapter is a local replica of the repository's test store, and the sandbox that runs these examples online has no network on purpose -- so the replica is served *inside* the sandbox, on its own private loopback, started beside your cell and gone when it exits. Real chunked data, zero egress, and a tutorial that cannot fail with the portal's next maintenance window. Run locally, serve the store yourself: python3 -m http.server 18931 --directory <dir-holding-co2.zarr>. Against a live portal the only change is the URL — the TLS client underneath verifies certificate and hostname, proven against the standard set of deliberately broken hosts.

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
C8Zarr.m9

expected output:

shape 100 x 50
co2[0,0]   = 394.9816047539
co2[99,49] = 403.8924951332
co2[10,5]  is a gap (deleted chunk, NaN fill)

Three things are new here, and each is the language keeping a promise from an earlier chapter:

  m9c --make -c C8Zarr.m9
  gcc C8Zarr.o ZarrStore.o Json.o Http.o DynStr.o Io.o Fmt.o \
      m9rt.c tcpshim.c tlsshim.c -l:libblosc.so.1 \
      -lssl -lcrypto -lm -o co2

m9c is deliberately not a build system; what it DOES supply by default (include paths, the module closure, the runtime) it will show you with -v.

← Previous: timeseries · Next: preparing data for plotting →