-
Notifications
You must be signed in to change notification settings - Fork 0
/
beta_ecsin_supp_C.html
6839 lines (6182 loc) · 255 KB
/
beta_ecsin_supp_C.html
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2019-05-28 mar. 16:50 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>The <code>C</code> programs and their use</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Christophe Pouzat" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="content">
<h1 class="title">The <code>C</code> programs and their use</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org8b2bb98">1. Introduction</a>
<ul>
<li><a href="#org882c590">1.1. Why <code>C</code>, <code>gnuplot</code> and the <code>shell</code>?</a></li>
<li><a href="#org59d9875">1.2. Required software and libraries</a></li>
<li><a href="#org6188cda">1.3. A remark on the code presentation</a></li>
</ul>
</li>
<li><a href="#orgfbb7542">2. Definitions of structures and associated functions holding data</a>
<ul>
<li><a href="#org539cd2b">2.1. <code>ADU</code> data</a>
<ul>
<li><a href="#org1f72b35">2.1.1. Data layout in the <code>HDF5</code> files</a></li>
<li><a href="#orgf508e4d">2.1.2. Data layout in the <code>C</code> code</a>
<ul>
<li><a href="#orgba681dc">2.1.2.1. <code>adu</code> type definition</a></li>
<li><a href="#org4c094dc">2.1.2.2. <code>adu_alloc</code> definition</a></li>
<li><a href="#orgd6fc093">2.1.2.3. <code>adu_free</code> definition</a></li>
<li><a href="#org5bbcadc">2.1.2.4. <code>adu_get_set</code> macro definitions</a></li>
<li><a href="#org658e433">2.1.2.5. <code>adu_printf</code> definition</a></li>
<li><a href="#orgd18a99b">2.1.2.6. <code>adu_test</code> program definition</a></li>
<li><a href="#orgf2d4f72">2.1.2.7. <code>adu_test</code> compilation, run, etc</a></li>
</ul>
</li>
<li><a href="#org16ae19a">2.1.3. <code>adu</code> header and source</a></li>
</ul>
</li>
<li><a href="#org5d8a1cb">2.2. <code>DATA</code> Group mapping in <code>C</code> code</a>
<ul>
<li><a href="#org14596b7">2.2.1. <code>adu_vector</code>: an array of <code>adu</code> structures</a>
<ul>
<li><a href="#orgf682ccc">2.2.1.1. <code>adu_vector</code> type definition</a></li>
<li><a href="#org858c6c7">2.2.1.2. <code>adu_vector_alloc</code> definition</a></li>
<li><a href="#orgfbeea49">2.2.1.3. <code>adu_vector_free</code> definition</a></li>
<li><a href="#org84a3b86">2.2.1.4. <code>adu_vector_printf</code> definition</a></li>
<li><a href="#org56191c1">2.2.1.5. <code>data_get_nelt</code></a></li>
<li><a href="#org96317fc">2.2.1.6. <code>adu_vector_read_from_file</code></a></li>
<li><a href="#orga0fee91">2.2.1.7. <code>adu_vector_test</code> program definition</a></li>
<li><a href="#orgca7dd16">2.2.1.8. <code>adu_vector_test</code> compilation, run, etc</a></li>
</ul>
</li>
<li><a href="#orgdc3b6d8">2.2.2. <code>adu_vector</code> header and source</a></li>
</ul>
</li>
<li><a href="#orgd870dce">2.3. <code>DYE</code></a>
<ul>
<li><a href="#org68bedde">2.3.1. DYE parameters in the <code>HDF5</code> files</a></li>
<li><a href="#org3932969">2.3.2. DYE parameters layout in <code>C</code> code</a>
<ul>
<li><a href="#org00c38cc">2.3.2.1. <code>dye</code> type definition</a></li>
<li><a href="#orgcdcdbe3">2.3.2.2. <code><<dye_read_from_file>></code></a></li>
<li><a href="#org1236170">2.3.2.3. <code><<dye_printf>></code></a></li>
<li><a href="#org9f52ab9">2.3.2.4. <code>dye_test</code></a></li>
<li><a href="#orgac31bd5">2.3.2.5. <code>dye_test</code> compilation, run, etc</a></li>
</ul>
</li>
<li><a href="#orgfb6a259">2.3.3. <code>dye</code> header and source</a></li>
</ul>
</li>
<li><a href="#org59cf272">2.4. <code>ILLUMINATION</code></a>
<ul>
<li><a href="#org5f95a39">2.4.1. <code>ILLUMINATION</code> parameters in the <code>HDF5</code> files</a></li>
<li><a href="#orgfa477b6">2.4.2. <code>ILLUMINATION</code> parameters layout in <code>C</code> code</a>
<ul>
<li><a href="#orgf304249">2.4.2.1. <code>illumination</code> type definition</a></li>
<li><a href="#orgd8a55f5">2.4.2.2. <code><<illumination_read_from_file>></code></a></li>
<li><a href="#orge1b125f">2.4.2.3. <code><<illumination_printf>></code></a></li>
<li><a href="#org55d25e5">2.4.2.4. <code>illumination_test</code></a></li>
<li><a href="#org7d64476">2.4.2.5. <code>illumination_test</code> compilation, run, etc</a></li>
</ul>
</li>
<li><a href="#org57feea6">2.4.3. <code>illumination</code> header and source</a></li>
</ul>
</li>
<li><a href="#orga77590f">2.5. <code>CCD</code></a>
<ul>
<li><a href="#orgdbaeb36">2.5.1. <code>CCD</code> parameters in the <code>HDF5</code> files</a></li>
<li><a href="#org5042912">2.5.2. <code>CCD</code> parameters layout in <code>C</code> code</a>
<ul>
<li><a href="#org1aec57c">2.5.2.1. <code>ccd</code> type definition</a></li>
<li><a href="#org922808b">2.5.2.2. <code><<ccd_read_from_file>></code></a></li>
<li><a href="#org1908d46">2.5.2.3. <code><<ccd_printf>></code></a></li>
<li><a href="#org10a6414">2.5.2.4. <code>ccd_test</code></a></li>
<li><a href="#orgf474f23">2.5.2.5. <code>ccd_test</code> compilation, run, etc</a></li>
</ul>
</li>
<li><a href="#orgdfe14dd">2.5.3. <code>ccd</code> header and source</a></li>
</ul>
</li>
<li><a href="#orgbdee825">2.6. Keeping everything in one structure</a>
<ul>
<li><a href="#orgf6a27c5">2.6.1. <code>aba</code> an added buffer approach structure:</a>
<ul>
<li><a href="#org3756893">2.6.1.1. <code>aba</code> type definition</a></li>
<li><a href="#orgabb49c1">2.6.1.2. <code>aba_alloc</code></a></li>
<li><a href="#org16d7b6f">2.6.1.3. <code>aba_free</code></a></li>
<li><a href="#orga50cf78">2.6.1.4. <code>aba_read_from_file</code></a></li>
<li><a href="#org8d433b6">2.6.1.5. <code>aba_printf</code></a></li>
<li><a href="#org24068e0">2.6.1.6. <code>aba_test</code> program definition</a></li>
<li><a href="#org5ac9740">2.6.1.7. <code>aba_test</code> compilation and run</a></li>
</ul>
</li>
<li><a href="#org7982c8e">2.6.2. <code>aba</code> header and source</a></li>
</ul>
</li>
<li><a href="#org1e0a634">2.7. Getting [Fura] estimates</a>
<ul>
<li><a href="#org3c9a42f">2.7.1. <code>time_series</code> structure</a>
<ul>
<li><a href="#org9a727ca">2.7.1.1. <code>ts</code> type definition</a></li>
<li><a href="#org1cdffbc">2.7.1.2. <code>ts_alloc</code></a></li>
<li><a href="#orge8d6bcd">2.7.1.3. <code>ts_free</code></a></li>
<li><a href="#orgf10564b">2.7.1.4. <code>ts_fprintf</code> definition</a></li>
<li><a href="#orgdc020b0">2.7.1.5. <code>ts_vector</code></a></li>
<li><a href="#org5ad2c53">2.7.1.6. <code>ts_vector_alloc</code> definition</a></li>
<li><a href="#org15d452b">2.7.1.7. <code>ts_vector_free</code> definition</a></li>
<li><a href="#org75b700f">2.7.1.8. <code>ts_vector_fprintf</code> definition</a></li>
</ul>
</li>
<li><a href="#org58cd94d">2.7.2. Getting a [Fura] estimation</a>
<ul>
<li><a href="#orgee1fbc0">2.7.2.1. <code>fura_est</code></a></li>
</ul>
</li>
<li><a href="#org57e10d3">2.7.3. <code>fura</code> header and source</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#orgba7f560">3. Working the ratiometric estimator</a>
<ul>
<li><a href="#orgee10be2">3.1. Some analytical details</a></li>
<li><a href="#orgac5bb72">3.2. Goodness of fit functions definitions</a>
<ul>
<li><a href="#orgb372213">3.2.1. <code>C</code> code doing the tests</a>
<ul>
<li><a href="#org2958633">3.2.1.1. <code>AndersonDarling_W2</code> definition</a></li>
<li><a href="#org62629f8">3.2.1.2. <code>adinf</code> definition</a></li>
<li><a href="#org18bd7b8">3.2.1.3. <code>AD_cdf_P</code> definition</a></li>
</ul>
</li>
<li><a href="#orgf1b6410">3.2.2. <code>gof</code> header, source and test</a></li>
</ul>
</li>
<li><a href="#org6cbfbf9">3.3. <code>ratio</code> structure and related functions</a>
<ul>
<li><a href="#org3a0bbf1">3.3.1. <code>C</code> code related to <code>ratio</code> structures</a>
<ul>
<li><a href="#org456e0c3">3.3.1.1. <code>ratio</code> type definition</a></li>
<li><a href="#org61d874c">3.3.1.2. <code>ratio_alloc</code> definition</a></li>
<li><a href="#org75b3062">3.3.1.3. <code>ratio_free</code> definition</a></li>
<li><a href="#org776af6b">3.3.1.4. <code>ratio_get_set</code> macro definitions</a></li>
<li><a href="#org7044468">3.3.1.5. <code>ratio_fprintf</code> definition</a></li>
<li><a href="#orgf748aaa">3.3.1.6. <code>ratio_est</code></a></li>
<li><a href="#orgb4111e9">3.3.1.7. <code>ratio_find_fit_start</code></a></li>
<li><a href="#orgfa63195">3.3.1.8. <code>mono_exp_fit_res</code></a></li>
<li><a href="#org9ce3c85">3.3.1.9. <code>mono_exp_fit_res_fprintf</code></a></li>
<li><a href="#org08f3d43">3.3.1.10. <code>ratio_for_fit</code></a></li>
<li><a href="#org20c7220">3.3.1.11. <code>ratio_residuals</code></a></li>
<li><a href="#org206fc73">3.3.1.12. <code>ratio_fit_callback</code></a></li>
<li><a href="#org3317205">3.3.1.13. <code>ratio_fit</code></a></li>
<li><a href="#org798c77a">3.3.1.14. <code>ratio_test</code></a></li>
<li><a href="#orgabd61fb">3.3.1.15. <code>ratio_test</code> compilation and run</a></li>
</ul>
</li>
<li><a href="#org158204f">3.3.2. <code>ratio</code> header and source</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org90c1bad">4. Building the <code>abaa</code> library</a>
<ul>
<li><a href="#org7546e52">4.1. The <code>abaa.h</code> header file</a></li>
<li><a href="#orge542da2">4.2. The <code>Makefile</code></a>
<ul>
<li><a href="#org0174599">4.2.1. Testing that everything works</a></li>
</ul>
</li>
<li><a href="#orga9bdf37">4.3. The <code>SConstruct</code> file</a></li>
</ul>
</li>
<li><a href="#orgd3e3b9e">5. Our first "user's" program: <code>fit_ratiometric</code></a>
<ul>
<li><a href="#orgb022ce5">5.1. Program's task</a>
<ul>
<li><a href="#org10a85d6">5.1.1. <code>fit_ratiometric</code> code</a>
<ul>
<li><a href="#orgd13b083">5.1.1.1. <code>fit_ratiometric</code> skeleton</a></li>
<li><a href="#org79a8ca2">5.1.1.2. <code><<fit_ratiometric-usage>></code></a></li>
<li><a href="#orgf805b91">5.1.1.3. <code><<fit_ratiometric-args>></code></a></li>
<li><a href="#org725a6fd">5.1.1.4. <code><<fit_ratiometric_g_script>></code></a></li>
<li><a href="#org4a40650">5.1.1.5. <code>fit_ratiometric</code> compilation</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org18f26a5">5.2. Using <code>fit_ratiometric</code></a></li>
</ul>
</li>
<li><a href="#org80c75d5">6. Getting Fura concentration during a stimulation: <code>fura_concentration</code></a>
<ul>
<li><a href="#org56afe51">6.1. Motivation</a>
<ul>
<li><a href="#org938dd87">6.1.1. <code>fura_concentration</code> code</a>
<ul>
<li><a href="#orgb44d3d8">6.1.1.1. <code>fura_concentration</code> skeleton</a></li>
<li><a href="#orgb2ac7a5">6.1.1.2. <code><<fura_concentration-usage>></code></a></li>
<li><a href="#org1c0bf6a">6.1.1.3. </a></li>
<li><a href="#org42749f0">6.1.1.4. <code>fura_concentration</code> compilation</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org30bd292">6.2. Using <code>fura_concentration</code></a></li>
<li><a href="#orgbe7e138">6.3. <code>fura_during_stim</code></a>
<ul>
<li><a href="#orgf865a5e">6.3.1. <code>fura_during_stim</code> code</a>
<ul>
<li><a href="#org7dd6921">6.3.1.1. <code>fura_during_stim</code> skeleton</a></li>
<li><a href="#org09bd5ab">6.3.1.2. <code><<fura_during_stim-usage>></code></a></li>
<li><a href="#org548ac8b">6.3.1.3. <code><<fura_during_stim-args>></code></a></li>
<li><a href="#orga7cb63d">6.3.1.4. <code>fura_during_stim</code> compilation</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org1049f33">6.4. Using <code>fura_during_stim</code></a></li>
</ul>
</li>
<li><a href="#org13cbbda">7. Getting the time constant as a function of \(\kappa_{F}\)</a>
<ul>
<li><a href="#org8d510af">7.1. We start by fitting each of the free transients of data set <code>DA_121219_E1.h5</code></a>
<ul>
<li><a href="#org8f71222">7.1.1. First transient</a></li>
<li><a href="#orgb27c43f">7.1.2. Second transient</a></li>
<li><a href="#org89ed8cb">7.1.3. Third transient</a></li>
</ul>
</li>
<li><a href="#orgfc7b5b6">7.2. Plotting \(\tau\) as a function of \(\kappa_F\)</a></li>
</ul>
</li>
<li><a href="#org74a6e6b">8. A program doing all that at once</a>
<ul>
<li><a href="#orgfeaa307">8.1. The <code>aba_ratio</code> program</a>
<ul>
<li><a href="#orgf4e19e1">8.1.1. <code>aba_ratio</code> code</a>
<ul>
<li><a href="#org1b3a380">8.1.1.1. <code>aba_ratio</code> skeleton</a></li>
<li><a href="#org3047dcf">8.1.1.2. <code><<aba_ratio-usage>></code></a></li>
<li><a href="#org1eb82fe">8.1.1.3. <code><<aba_ratio-args>></code></a></li>
<li><a href="#orgdcca341">8.1.1.4. <code><<aba_ratio-read-data>></code></a></li>
<li><a href="#orgce4031c">8.1.1.5. <code><<aba_ratio-get-loading-curve>></code></a></li>
<li><a href="#org3b6e375">8.1.1.6. <code><<aba_ratio_loading_curve_g_script>></code></a></li>
<li><a href="#org2d9cd87">8.1.1.7. <code><<aba_ratio_ratiometric_estimator>></code></a></li>
<li><a href="#org014763c">8.1.1.8. <code><<aba_ratio_mono_exp_fit>></code></a></li>
<li><a href="#org2994563">8.1.1.9. <code><<aba_ratio_mono_exp_g_script>></code></a></li>
<li><a href="#org7320514">8.1.1.10. <code><<aba_ratio_kappa_Fura>></code></a></li>
<li><a href="#org92706dc">8.1.1.11. <code><<aba_ratio_tau_vs_kappa>></code></a></li>
<li><a href="#orgf34f080">8.1.1.12. <code><<aba_ratio_tau_vs_kappa_g_script>></code></a></li>
<li><a href="#org095766c">8.1.1.13. <code><<wls_fit>></code></a></li>
<li><a href="#orgda4391b">8.1.1.14. <code><<robust_fit>></code></a></li>
<li><a href="#org650a3f2">8.1.1.15. <code>aba_ratio</code> compilation</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org42e3831">8.2. Using <code>aba_ratio</code></a>
<ul>
<li><a href="#orgbf804fc">8.2.1. Getting help</a></li>
<li><a href="#org45f85d5">8.2.2. Running <code>aba_ratio</code></a></li>
<li><a href="#org36e811a">8.2.3. Looking at the results</a>
<ul>
<li><a href="#orgc573e75">8.2.3.1. loading curve</a></li>
<li><a href="#org6d9666c">8.2.3.2. First stimulation fit</a></li>
<li><a href="#org4bd5839">8.2.3.3. Second stimulation fit</a></li>
<li><a href="#org22ff036">8.2.3.4. Third stimulation fit</a></li>
<li><a href="#org8586505">8.2.3.5. \(\tau\) vs \(\kappa_{Fura}\) regression</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org8b2bb98" class="outline-2">
<h2 id="org8b2bb98"><span class="section-number-2">1</span> Introduction</h2>
<div class="outline-text-2" id="text-1">
<p>
We define in this document the <code>C</code> codes / programs developped for the analysis of the "\(\beta\) ecsin" data with the added buffer approach. Examples of use are also included.
</p>
</div>
<div id="outline-container-org882c590" class="outline-3">
<h3 id="org882c590"><span class="section-number-3">1.1</span> Why <code>C</code>, <code>gnuplot</code> and the <code>shell</code>?</h3>
<div class="outline-text-3" id="text-1-1">
<p>
This document is the exploration of an idea: use the shell (<code>bash</code> or <code>zsh</code>) instead of the <code>Python</code> or <code>R</code> command line for interactive analysis and write the short functions performing the actual analysis in <code>C</code>. The motivation for this exploration comes from two books by Ben Klemens: <a href="http://modelingwithdata.org/about_the_book.html">Modeling With Data</a> and <i>21st Century C</i>. The main advantages of <code>C</code> compared to the other two languages are:
</p>
<ul class="org-ul">
<li>Its stability (the programs written here are very likely to run unchanged in 20 years from now; what can be sure that this won't be true with <code>Python</code>).</li>
<li>The development tools that come with it are just spectacular (see the very short and very clear book of Brian Gough <a href="http://www.network-theory.co.uk/docs/gccintro/">An Introduction to GCC</a> to understand what I mean by that).</li>
</ul>
</div>
</div>
<div id="outline-container-org59d9875" class="outline-3">
<h3 id="org59d9875"><span class="section-number-3">1.2</span> Required software and libraries</h3>
<div class="outline-text-3" id="text-1-2">
<p>
Since a <a href="https://en.wikipedia.org/wiki/Bash_(Unix_shell)">Bash</a> or a <a href="https://en.wikipedia.org/wiki/Z_shell">Z shell</a> are going to be used, <code>Windows</code> users will have to install <a href="https://cygwin.com/index.html">Cygwin</a>, <code>Linux</code> and <code>MacOS</code> users should have the <code>bash</code> shell by default and the <code>zsh</code> shell readily available from their package manager. To dig deeper into the amazing possibilities (and spectacular editorial support) of these tools, check <a href="http://www.bash2zsh.com/">From Bash to Z Shell. Conquering the Command Line</a> by Kiddle, Peek and Stephenson.
</p>
<p>
The no-shell codes are going to be written in <code>C</code>, meaning that a <code>C</code> compiler together with the "classical" development tools (<code>make</code>, etc) are required. I'm going to use <a href="https://gcc.gnu.org/"><code>gcc</code></a> here.
</p>
<p>
The heavy computational work is going to be performed mainly by the <a href="http://www.gnu.org/software/gsl/">gsl</a> (the <i>GNU Scientific Library</i>) that is easily installed through your package manager (from now one, for windows users, the "package manager" refers to the one of <code>Cygwin</code>). The graphs are be generated with <a href="http://www.gnuplot.info/">gnuplot</a>; for a quick tutorial check <a href="http://physicspmb.ukzn.ac.za/index.php/Gnuplot_tutorial">http://physicspmb.ukzn.ac.za/index.php/Gnuplot_tutorial</a>, for an easy to navigate set of (sophisticated) recipes check <a href="http://www.gnuplotting.org/">http://www.gnuplotting.org/</a>. The data sets are in <a href="https://www.hdfgroup.org/HDF5/">HDF5</a> format and the <code>C</code> library, as well as the command line tools, developed by the HDF5 group are going to be heavily used here.
</p>
</div>
</div>
<div id="outline-container-org6188cda" class="outline-3">
<h3 id="org6188cda"><span class="section-number-3">1.3</span> A remark on the code presentation</h3>
<div class="outline-text-3" id="text-1-3">
<p>
The <a href="https://en.wikipedia.org/wiki/Literate_programming">literate programming</a> approach is used here. This means that the code is broken into "manageable" pieces that are individually explained (when just reading the code is not enough), they are then pasted together to give the code that will actually get compiled. These manageable pieces are called blocks and each block gets a name like: <code><<name-of-the-block>></code> upon definition. It is then referred to by this name when used in subsequent codes. See Schulte, Davison, Dye and Dominik (2010) <a href="https://www.jstatsoft.org/article/view/v046i03">A Multi-Language Computing Environment for Literate Programming and Reproducible Research </a>for further explanations. The code blocks also include documentation in <a href="http://www.stack.nl/~dimitri/doxygen/index.html">Doxygen</a> format and we try to avoid writing twice the same thing, in the text and in the documentation. So if something is "missing" from the text description, please check the documentation within the block first to see if what you're looking for is there.
</p>
</div>
</div>
</div>
<div id="outline-container-orgfbb7542" class="outline-2">
<h2 id="orgfbb7542"><span class="section-number-2">2</span> Definitions of structures and associated functions holding data</h2>
<div class="outline-text-2" id="text-2">
</div>
<div id="outline-container-org539cd2b" class="outline-3">
<h3 id="org539cd2b"><span class="section-number-3">2.1</span> <code>ADU</code> data</h3>
<div class="outline-text-3" id="text-2-1">
</div>
<div id="outline-container-org1f72b35" class="outline-4">
<h4 id="org1f72b35"><span class="section-number-4">2.1.1</span> Data layout in the <code>HDF5</code> files</h4>
<div class="outline-text-4" id="text-2-1-1">
<p>
Our data stored in <code>HDF5</code> format contain the actual <code>ADU</code> recordings in Groups called <code>DATA</code>. Each of those groups contains three datasets:
</p>
<dl class="org-dl">
<dt><code>ADU</code></dt><dd>an array of integers with 7 columns and as many rows as there were measurements. The first column is the <code>time_index</code> column, the second contains the <code>ADU340</code> measurements (measurements at 340 nm in the ROI), then comes the <code>ADU340B</code> measurements (measurements at 340 nm in the ROB), the <code>ADU360</code> measurements (at 360 nm in the ROI), the <code>ADU360B</code> measurements (at 360 nm in the ROB), the <code>ADU380</code> measurements (at 380 nm in the ROI), the <code>ADU380B</code> measurements (at 380 nm in the ROB).</dd>
<dt><code>TIME_DELTA</code></dt><dd>a scalar (see below).</dd>
<dt><code>TIME_OFFSET</code></dt><dd>a scalar (see below).</dd>
</dl>
<p>
To get the real time of each measurement, multiply the first column of <code>ADU</code> by <code>TIME_DELTA</code> and add <code>TIME_OFFSET</code>. The other columns of the <code>ADU</code> matrix contain the "raw" readings of the <code>P</code> of <code>P_B</code> pixels from the CCD chip.
</p>
</div>
</div>
<div id="outline-container-orgf508e4d" class="outline-4">
<h4 id="orgf508e4d"><span class="section-number-4">2.1.2</span> Data layout in the <code>C</code> code</h4>
<div class="outline-text-4" id="text-2-1-2">
<p>
We will store these data in <code>double</code> format in a new type of structure called <code>adu</code>. Each of the seven column will become a single pointer to a <a href="https://www.gnu.org/software/gsl/manual/html_node/Vectors.html#Vectors"><code>gsl_vector</code></a>. We define this structure in a specific code block in the next section.
</p>
</div>
<div id="outline-container-orgba681dc" class="outline-5">
<h5 id="orgba681dc"><span class="section-number-5">2.1.2.1</span> <code>adu</code> type definition</h5>
<div class="outline-text-5" id="text-2-1-2-1">
<div class="org-src-container">
<pre class="src src-C" id="org07829d3">/** @brief Structure holding arrays of gsl_vectors each vector contains
* ADU measurements from at a specific wavelength from a
* specific loaction (ROI or ROB).
*/
typedef struct
{
gsl_vector * ADU340; //!< measurements at 340 nm from ROI
gsl_vector * ADU340B; //!< measurements at 340 nm from ROB
gsl_vector * ADU360; //!< measurements at 360 nm from ROI
gsl_vector * ADU360B; //!< measurements at 360 nm from ROB
gsl_vector * ADU380; //!< measurements at 380 nm from ROI
gsl_vector * ADU380B; //!< measurements at 380 nm from ROB
gsl_vector * TIME; //!< time (in s) of measurements
} adu;
</pre>
</div>
</div>
</div>
<div id="outline-container-org4c094dc" class="outline-5">
<h5 id="org4c094dc"><span class="section-number-5">2.1.2.2</span> <code>adu_alloc</code> definition</h5>
<div class="outline-text-5" id="text-2-1-2-2">
<p>
It will be helpful to have an <code>alloc</code> function for <code>adu</code> structures:
</p>
<div class="org-src-container">
<pre class="src src-C" id="org7972880">/** @brief Allocates an [adu](@ref adu)
*
* The function allocates memory for an [adu](@ref adu) structure
*
* @param[in] n_obs the number of measurements / obserations
* @returns a pointer to an allocated [adu](@ref adu)
*/
adu * adu_alloc(size_t n_obs) {
adu * res = malloc(sizeof(adu));
res->ADU340 = gsl_vector_alloc(n_obs);
res->ADU340B = gsl_vector_alloc(n_obs);
res->ADU360 = gsl_vector_alloc(n_obs);
res->ADU360B = gsl_vector_alloc(n_obs);
res->ADU380 = gsl_vector_alloc(n_obs);
res->ADU380B = gsl_vector_alloc(n_obs);
res->TIME = gsl_vector_alloc(n_obs);
return res;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd6fc093" class="outline-5">
<h5 id="orgd6fc093"><span class="section-number-5">2.1.2.3</span> <code>adu_free</code> definition</h5>
<div class="outline-text-5" id="text-2-1-2-3">
<p>
It will also be helpful to have a <code>free</code> function for <code>adu</code> structures:
</p>
<div class="org-src-container">
<pre class="src src-C" id="org087c398">/** @brief Frees an [adu](@ref adu)
@param[in,out] adu_ptr a pointer to an allocated [adu](@ref adu) structure
@returns 0 if everything goes fine
*/
int adu_free(adu * adu_ptr) {
gsl_vector_free(adu_ptr->ADU340);
gsl_vector_free(adu_ptr->ADU340B);
gsl_vector_free(adu_ptr->ADU360);
gsl_vector_free(adu_ptr->ADU360B);
gsl_vector_free(adu_ptr->ADU380);
gsl_vector_free(adu_ptr->ADU380B);
gsl_vector_free(adu_ptr->TIME);
free(adu_ptr);
return 0;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org5bbcadc" class="outline-5">
<h5 id="org5bbcadc"><span class="section-number-5">2.1.2.4</span> <code>adu_get_set</code> macro definitions</h5>
<div class="outline-text-5" id="text-2-1-2-4">
<p>
We define next <code>macros</code> with arguments giving an easy way to get and set values of specific members of <code>adu</code> structure:
</p>
<div class="org-src-container">
<pre class="src src-C" id="org9bf8906">/** @def adu_get(adu,member,i)
* @brief A macro that returns value at index \a i of
* member \a member from \a adu structure
*/
#define adu_get(adu,member,i) gsl_vector_get(adu->member,i)
/** @def adu_set(adu,member,i,x)
* @brief A macro that sets value at index \a i of
* member \a member from \a adu structure at \a x
*/
#define adu_set(adu,member,i,x) gsl_vector_set(adu->member,i,x)
</pre>
</div>
</div>
</div>
<div id="outline-container-org658e433" class="outline-5">
<h5 id="org658e433"><span class="section-number-5">2.1.2.5</span> <code>adu_printf</code> definition</h5>
<div class="outline-text-5" id="text-2-1-2-5">
<p>
We now define a function that prints to the <code>stdout</code> the content of an <code>adu</code> structure:
</p>
<div class="org-src-container">
<pre class="src src-C" id="org93de697">/** @brief Prints [adu](@ref adu) content to stdout
@param[in] padu a pointer to an [adu](@ref adu) structure
@return 0 if everything goes fine
*/
int adu_printf(adu * padu) {
size_t nobs=(padu)->TIME->size;
printf("# Time ADU340 ADU340B ADU360 ADU360B ADU380 ADU380B\n");
for (size_t i=0; i<nobs; i++) {
printf("%9.9g %8d %8d %8d %8d %8d %8d\n",
adu_get((padu),TIME,i),
(int) adu_get(padu,ADU340,i),
(int) adu_get(padu,ADU340B,i),
(int) adu_get(padu,ADU360,i),
(int) adu_get(padu,ADU360B,i),
(int) adu_get(padu,ADU380,i),
(int) adu_get(padu,ADU380B,i));
}
printf("\n\n");
return 0;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd18a99b" class="outline-5">
<h5 id="orgd18a99b"><span class="section-number-5">2.1.2.6</span> <code>adu_test</code> program definition</h5>
<div class="outline-text-5" id="text-2-1-2-6">
<p>
We now define a short program <code>adu_test</code> allowing us to test the functions we just defined. We store this program is a sub-directory called <code>code</code>.
</p>
<div class="org-src-container">
<pre class="src src-C" id="org6743135">/** @file adu_test.c
* @brief Test program for adu structure and related
* functions.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gsl/gsl_vector.h>
<<adu-type-definition>>
<<adu_alloc>>
<<adu_free>>
<<adu_get_set>>
<<adu_printf>>
int main()
{
// Allocate an adu with 2 observations
adu * adu_ptr = adu_alloc(2);
printf("Allocated adu_ptr with two elements.\n");
printf("Setting values of ADU340 field.\n");
adu_set(adu_ptr,ADU340,0,1.0);
adu_set(adu_ptr,ADU340,1,2.0);
printf("Setting values of ADU340B field.\n");
adu_set(adu_ptr,ADU340B,0,3.0);
adu_set(adu_ptr,ADU340B,1,4.0);
printf("Setting values of ADU360 field.\n");
adu_set(adu_ptr,ADU360,0,5.0);
adu_set(adu_ptr,ADU360,1,6.0);
printf("Setting values of ADU360B field.\n");
adu_set(adu_ptr,ADU360B,0,7.0);
adu_set(adu_ptr,ADU360B,1,8.0);
printf("Setting values of ADU380 field.\n");
adu_set(adu_ptr,ADU380,0,9.0);
adu_set(adu_ptr,ADU380,1,10.0);
printf("Setting values of ADU380B field.\n");
adu_set(adu_ptr,ADU380B,0,11.0);
adu_set(adu_ptr,ADU380B,1,12.0);
printf("Setting values of TIME field.\n");
adu_set(adu_ptr,TIME,0,1.5);
adu_set(adu_ptr,TIME,1,2.5);
printf("The content of the structure is.\n");
adu_printf(adu_ptr);
// free allocated adu
adu_free(adu_ptr);
printf("Freed adu_ptr. Don't forget running valgrind!\n");
return 0;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf2d4f72" class="outline-5">
<h5 id="orgf2d4f72"><span class="section-number-5">2.1.2.7</span> <code>adu_test</code> compilation, run, etc</h5>
<div class="outline-text-5" id="text-2-1-2-7">
<p>
We compile the code with:
</p>
<div class="org-src-container">
<pre class="src src-sh" id="orge099712">gcc -Wall -g -o code/adu_test code/adu_test.c -lgsl -lgslcblas -lm -std=gnu11
</pre>
</div>
<p>
We run it with:
</p>
<div class="org-src-container">
<pre class="src src-sh" id="org6d887b0">./code/adu_test
</pre>
</div>
<pre class="example">
Allocated adu_ptr with two elements.
Setting values of ADU340 field.
Setting values of ADU340B field.
Setting values of ADU360 field.
Setting values of ADU360B field.
Setting values of ADU380 field.
Setting values of ADU380B field.
Setting values of TIME field.
The content of the structure is.
# Time ADU340 ADU340B ADU360 ADU360B ADU380 ADU380B
1.5 1 3 5 7 9 11
2.5 2 4 6 8 10 12
Freed adu_ptr. Don't forget running valgrind!
</pre>
<p>
We run it with <a href="http://valgrind.org/">Valgrind</a> to make sure that all the allocated memory has been freed upon program termination:
</p>
<div class="org-src-container">
<pre class="src src-sh" id="orga35ef75">valgrind ./code/adu_test
</pre>
</div>
<pre class="example">
==14941== Memcheck, a memory error detector
==14941== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==14941== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==14941== Command: ./code/adu_test
==14941==
Allocated adu_ptr with two elements.
Setting values of ADU340 field.
Setting values of ADU340B field.
Setting values of ADU360 field.
Setting values of ADU360B field.
Setting values of ADU380 field.
Setting values of ADU380B field.
Setting values of TIME field.
The content of the structure is.
# Time ADU340 ADU340B ADU360 ADU360B ADU380 ADU380B
1.5 1 3 5 7 9 11
2.5 2 4 6 8 10 12
Freed adu_ptr. Don't forget running valgrind!
==14941==
==14941== HEAP SUMMARY:
==14941== in use at exit: 0 bytes in 0 blocks
==14941== total heap usage: 23 allocs, 23 frees, 4,656 bytes allocated
==14941==
==14941== All heap blocks were freed -- no leaks are possible
==14941==
==14941== For counts of detected and suppressed errors, rerun with: -v
==14941== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
</pre>
<p>
We are happy!
</p>
</div>
</div>
</div>
<div id="outline-container-org16ae19a" class="outline-4">
<h4 id="org16ae19a"><span class="section-number-4">2.1.3</span> <code>adu</code> header and source</h4>
<div class="outline-text-4" id="text-2-1-3">
<p>
We define two code blocks for later use when we will define a library. Code block <code><<adu.h>></code> contains the types, macros and function prototypes we just defined.
</p>
<div class="org-src-container">
<pre class="src src-C" id="org57aefaf"><<adu-type-definition>>
adu * adu_alloc(size_t n_obs);
int adu_free(adu * adu_ptr);
<<adu_get_set>>
int adu_printf(adu * padu);
</pre>
</div>
<p>
Code block <code><<adu.c>></code> contains the function definitions <i>per se</i> and gets stored in file <code>code/adu.c</code>:
</p>
<div class="org-src-container">
<pre class="src src-C" id="orgb8cabae">/** \file adu.c
\brief Definitions of functions related to [adu](@ref adu) structures
*/
#include "abaa.h"
<<adu_alloc>>
<<adu_free>>
<<adu_printf>>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org5d8a1cb" class="outline-3">
<h3 id="org5d8a1cb"><span class="section-number-3">2.2</span> <code>DATA</code> Group mapping in <code>C</code> code</h3>
<div class="outline-text-3" id="text-2-2">
</div>
<div id="outline-container-org14596b7" class="outline-4">
<h4 id="org14596b7"><span class="section-number-4">2.2.1</span> <code>adu_vector</code>: an array of <code>adu</code> structures</h4>
<div class="outline-text-4" id="text-2-2-1">
<p>
We will create a data type called <code>adu_vector</code> holding an array whose successive elements will be <code>adu</code> structures. Element 0 of our array will contain the <code>load</code> dataset and the following elements will contain the <code>stim1</code>, <code>stim2</code>, etc. datasets.
</p>
</div>
<div id="outline-container-orgf682ccc" class="outline-5">
<h5 id="orgf682ccc"><span class="section-number-5">2.2.1.1</span> <code>adu_vector</code> type definition</h5>
<div class="outline-text-5" id="text-2-2-1-1">
<div class="org-src-container">
<pre class="src src-C" id="org00492d6">/** @brief Structure holding arrays of `adu` structures .
*/
typedef struct
{
size_t nelt; //!< number of elements in the vector
adu ** adu_v; //!< array of pointers to adu structures
} adu_vector;
</pre>
</div>
</div>
</div>
<div id="outline-container-org858c6c7" class="outline-5">
<h5 id="org858c6c7"><span class="section-number-5">2.2.1.2</span> <code>adu_vector_alloc</code> definition</h5>
<div class="outline-text-5" id="text-2-2-1-2">
<p>
It will be helpful to have an <code>alloc</code> function for <code>adu_vector</code> structures:
</p>
<div class="org-src-container">
<pre class="src src-C" id="org7c3a6f5">/** @brief Allocates an adu_vector
*
* The function allocates memory for an adu_vector structure