Scientific programming in Modula-9 — first steps

↖ contents

10 — A real dataset, end to end

Everything the eight chapters built, on real data: nine years of hourly CO2 measured 150 m above the forest at the ICOS station Hyltemossa (HTM, southern Sweden), read straight out of the Carbon Portal's zarr service, quality-controlled by the station's own flags, decomposed by ordinary least squares into a linear trend plus annual and semiannual harmonics, and plotted.

The data is the ICOS ObsPack collection (CC BY 4.0, doi:10.18160/JZ2X-GZGU), served at zarr.icos-cp.eu. The sandbox behind this page serves a raw byte mirror of the three HTM arrays — the portal's own objects, undecoded — so the program below runs here without network, and runs unchanged on your machine against the live service:

m9c --make -c C10Icos.m9
cc C10Icos.o ZarrStore.o Json.o Http.o Mat.o Math.o Plot.o \
   DynStr.o Io.o Fmt.o m9rt.c tcpshim.c tlsshim.c fmtshim.c \
   -lblosc -lssl -lcrypto -lm -o co2fit
./co2fit https://zarr.icos-cp.eu/icos-obspack.zarr

Same bytes in, same numbers out — that is what the mirror being the live store's own objects buys.

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
C10Icos.m9

expected output:

hours in the window 72456 (of 84672 in the store)
mean 2021.5        419.92 umol/mol
trend              2.529 umol/mol per year
annual amplitude   9.01 (peak to trough 18.02)
semiannual         2.62
wrote /tmp/htm.svg, 3748547 bytes

nine years of CO2 at Hyltemossa: every QC-passed hour a dot, the monthly means and the six-coefficient Fourier fit over them

What the numbers say: CO2 at Hyltemossa climbs about 2.5 umol/mol a year, and the forest breathes an 18 umol/mol seasonal swing around that climb — summer drawdown, winter release — with a semiannual correction of a couple of umol/mol shaping the shoulders. The plot draws every QC-passed hour as a small black dot, with the monthly means and the six-coefficient fit over them — nine years of raw observations and their summary in one picture.

Worth noticing on the way out:

← Previous: preparing data for plotting