-
Notifications
You must be signed in to change notification settings - Fork 2
/
timeplot.gpl
executable file
·130 lines (110 loc) · 8.96 KB
/
timeplot.gpl
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
#!/usr/bin/gnuplot
reset;
set encoding utf8;
LABEL=system("cat in/nGeigie_map.csv|cut -d, -f1-10|grep -P '^" . ID . ",' |perl -MText::ParseWords -CS -ne '@R="ewords(\",\", 0, $_); print \"$R[4], $R[5]\n\"'");
DRE2CPM=system("cat in/nGeigie_map.csv|cut -d, -f1,3|grep -P '^" . ID . ",' |cut -d, -f2");
DRE2CPM=DRE2CPM + 0.0;
CPM2DRE=1.0 / DRE2CPM;
DATAFILE=sprintf("cache/%d.csv", ID);
OUTFILE=sprintf("out/%d.png", ID);
OUTFILE_window=sprintf("out/%d_window.png", ID);
OUTFILE_table=sprintf("tmp/%d.data", ID);
# This converts the time string in column COL to a number of seconds
iso2s(COL) = strptime("%Y-%m-%dT%H:%M:%S" . CONFIG_TZ, strcol(COL));
s2iso(seconds) = strftime("%Y-%m-%dT%H:%M:%S" . CONFIG_TZ, seconds);
set datafile separator ",";
# set palette
set cbtics (0.03, 0.14, 0.43, 1.65, 65.54);
set palette model RGB;
set palette file "cyanhalo_lut_4xlog10.csv" u 1:2:3;
set cbrange [0.03: 65.54];
unset colorbox;
set key autotitle columnheader top right;
set grid xtics front;
S_START=strptime("%Y-%m-%dT%H:%M:%S" . CONFIG_TZ, PERIOD_START);
S_END=strptime("%Y-%m-%dT%H:%M:%S" . CONFIG_TZ, PERIOD_END);
END_YEAR=system("TZ=" . CONFIG_TIMEZONE . " date +%Y --date='" . PERIOD_END . "'");
set xrange [ S_START : S_END ]; # set xlabel "timestamp";
stats DATAFILE u (iso2s(1)):2 nooutput;
three_sigma_percent=sprintf("±%0.1f%%", 100.0 * 3.0 * STATS_stddev_y / STATS_mean_y);
min_y = (1.2 * STATS_min_y < STATS_mean_y - 4.1 * STATS_stddev_y) ? 1.2 * STATS_min_y : STATS_mean_y - 4.1 * STATS_stddev_y; min_y = (min_y > 0) ? min_y : 0;
max_y = (1.2 * STATS_max_y > STATS_mean_y + 4.1 * STATS_stddev_y) ? 1.2 * STATS_max_y : STATS_mean_y + 4.1 * STATS_stddev_y;
#min_y = 0; max_y = 350;
set yrange [min_y: max_y]; set ytics nomirror textcolor rgb "dark-green"; set label 31 "{/*1.1 CPM}" at graph 0.0, 1.04 right textcolor rgb "dark-green";
set arrow 1 nohead front from graph 0, graph 0 to graph 0, graph 1 lc rgb "dark-green";
set y2range [min_y * CPM2DRE: max_y * CPM2DRE]; set y2tics nomirror textcolor rgb "blue"; set label 32 "{/*1.1 μSv/h}" at graph 1.0, graph 1.04 left textcolor rgb "blue";
set arrow 2 nohead front from graph 1, graph 0 to graph 1, graph 1 lc rgb "blue";
set xdata time; set timefmt "%Y-%m-%dT%H:%M:%S" . CONFIG_TZ; set format x "%Y-%m-%d\n%H:%M " . CONFIG_TZ;
set format y "% 0.0f"; set format y2 "%0.2f";
# Huge PNGs for gamma.tar.bz
FONT="Arial Unicode MS";
set term png enhanced transparent nointerlace truecolor butt font FONT . ",12" size CONFIG_WIDTH_HUGE, CONFIG_HEIGHT_HUGE;
set output sprintf("out/%d_%dx%d.png", ID, CONFIG_WIDTH_HUGE, CONFIG_HEIGHT_HUGE);
set object 1 rectangle from "2013-01-01", STATS_mean_y - 3.0 * STATS_stddev_y to "2033-01-01", STATS_mean_y + 3.0 * STATS_stddev_y back fc rgb "cyan" fillstyle solid 0.2 border lc rgb "cyan";
set title sprintf("&{%0.2f±%0.2f μSv/h (%0.1f±%0.1f CPM), total %d measurements}", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE, STATS_mean_y, 3.0 * STATS_stddev_y, STATS_records) font FONT . ",12";
set label 1 sprintf("%0.2f±%0.2f μSv/h &{(%0.1f±%0.1f CPM), total %d measurements}", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE, STATS_mean_y, 3.0 * STATS_stddev_y, STATS_records) at screen 0.5, screen 0.97 center font FONT . ",12" tc rgb "blue";
set label 2 sprintf("&{%0.2f±%0.2f μSv/h (}%0.1f±%0.1f CPM&{), total %d measurements}", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE, STATS_mean_y, 3.0 * STATS_stddev_y, STATS_records) at screen 0.5, screen 0.97 center font FONT . ",12" tc rgb "dark-green";
set label 3 sprintf("&{%0.2f±%0.2f μSv/h }(&{%0.1f±%0.1f CPM}), total %d measurements", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE, STATS_mean_y, 3.0 * STATS_stddev_y, STATS_records) at screen 0.5, screen 0.97 center font FONT . ",12" tc rgb "black";
set label 4 sprintf("%d: %0.2f μSv/h", ID, STATS_mean_y * CPM2DRE) at graph 0.0235, graph 0.970 font FONT . ",18" textcolor rgb "dark-gray";
set label 5 sprintf("%d: %0.2f μSv/h", ID, STATS_mean_y * CPM2DRE) at graph 0.0240, graph 0.968 font FONT . ",18" textcolor rgb "#FF0066";
set label 6 LABEL at graph 0.0240, graph 0.94 font FONT . ",18" noenhanced textcolor rgb "#FF0066";
set style line 1 lc rgb "orange";
plot \
DATAFILE u 1:2 w p ls 1 notitle, \
DATAFILE u 1:($4*CPM2DRE):($4*CPM2DRE) axes x1y2 w l lw 2 palette title "24-bin SMA [= 2 h ]", \
DATAFILE u 1:($3*CPM2DRE):($3*CPM2DRE) axes x1y2 w l lw 1 lc rgbcolor "#000000" notitle, \
-100 w filledcurves fc rgb "cyan" fs transparent solid 0.2 title "±3{/Arial-Unicode-MS σ} area [= " . three_sigma_percent . " ]";
unset for [i in "1"] object i; unset title; unset for [i in "1 2 3 4 5 6"] label i;
# Large PNGs for gamma.tar.bz
FONT="Arial Unicode MS";
set term png enhanced notransparent nointerlace truecolor butt font FONT . ",8" size CONFIG_WIDTH_BIG, CONFIG_HEIGHT_BIG background "#ffffef";
set output OUTFILE;
set object 1 rectangle from "2013-01-01", STATS_mean_y - 3.0 * STATS_stddev_y to "2033-01-01", STATS_mean_y + 3.0 * STATS_stddev_y back fc rgb "cyan" fillstyle solid 0.2 border lc rgb "cyan";
set title sprintf("&{%0.2f±%0.2f μSv/h (%0.1f±%0.1f CPM), total %d measurements}", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE, STATS_mean_y, 3.0 * STATS_stddev_y, STATS_records) font FONT . ",9";
set label 1 sprintf("%0.2f±%0.2f μSv/h &{(%0.1f±%0.1f CPM), total %d measurements}", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE, STATS_mean_y, 3.0 * STATS_stddev_y, STATS_records) at screen 0.5, screen 0.93 center font FONT . ",9" tc rgb "blue";
set label 2 sprintf("&{%0.2f±%0.2f μSv/h (}%0.1f±%0.1f CPM&{), total %d measurements}", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE, STATS_mean_y, 3.0 * STATS_stddev_y, STATS_records) at screen 0.5, screen 0.93 center font FONT . ",9" tc rgb "dark-green";
set label 3 sprintf("&{%0.2f±%0.2f μSv/h }(&{%0.1f±%0.1f CPM}), total %d measurements", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE, STATS_mean_y, 3.0 * STATS_stddev_y, STATS_records) at screen 0.5, screen 0.93 center font FONT . ",9" tc rgb "black";
set label 4 sprintf("%d: %0.2f μSv/h", ID, STATS_mean_y * CPM2DRE) at graph 0.0235, graph 0.930 font FONT . ",15" textcolor rgb "dark-gray";
set label 5 sprintf("%d: %0.2f μSv/h", ID, STATS_mean_y * CPM2DRE) at graph 0.0240, graph 0.925 font FONT . ",15" textcolor rgb "#FF0066";
set label 6 LABEL at graph 0.0240, graph 0.84 font FONT . ",9" noenhanced textcolor rgb "#FF0066";
set style line 1 lc rgb "orange";
plot \
DATAFILE u 1:2 w p ls 1 notitle, \
DATAFILE u 1:($4*CPM2DRE):($4*CPM2DRE) axes x1y2 w l lw 2 palette title "24-bin SMA [= 2 h ]", \
DATAFILE u 1:($3*CPM2DRE):($3*CPM2DRE) axes x1y2 w l lw 1 lc rgbcolor "#000000" notitle, \
-100 w filledcurves fc rgb "cyan" fs transparent solid 0.2 title "±3{/Arial-Unicode-MS σ} area [= " . three_sigma_percent . " ]";
unset for [i in "1"] object i; unset title; unset for [i in "1 2 3 4 5 6"] label i;
unset for [i in "1 2"] arrow i;unset for [i in "31 32"] label i;
# small PNGs for tilemap, make sure they are OK at half resolution
FONT="Futura ND";
set term pngcairo enhanced color solid notransparent background "#ffffff" font FONT . ",14" linewidth 2 butt size CONFIG_WIDTH_SMALL, CONFIG_HEIGHT_SMALL;
set output sprintf("out/%d_%dx%d.png", ID, CONFIG_WIDTH_SMALL, CONFIG_HEIGHT_SMALL);
unset title;
set yrange [-0.1:+1.1]; set ytics mirror; set label 31 "μSv/h" at graph 0.0, graph 1.0 right offset -0.5, 0.5; set format y "%0.2f";
set grid x y;
set format x "%m/%d"; set xtics offset 0, graph 0.03; set xlabel END_YEAR offset 0,1;
set label 32 sprintf("%d", ID) at graph 0.5, graph 0.5 center font FONT . ",100" back textcolor rgb "#dddddd";
plot \
DATAFILE u 1:($4*CPM2DRE):($4*CPM2DRE) w l lw 1 palette notitle;
unset for [i in "31 32"] label i; unset xlabel;
# save uSv/h data for ALL.png
set format x "%Y-%m-%dT%H:%M:%S" . CONFIG_TZ; set format y "%0.3f";
uSv_h = sprintf("%0.2f ± %0.2f", STATS_mean_y * CPM2DRE , 3.0 * STATS_stddev_y * CPM2DRE);
set table OUTFILE_table;
plot DATAFILE u 1:($4*CPM2DRE) title sprintf("%d: %s (%s) [@%d]", ID, uSv_h, three_sigma_percent, DRE2CPM);
unset table;
# update window graphs
FONT="Arial Unicode MS";
set term png enhanced notransparent nointerlace truecolor butt font FONT . ",12" size CONFIG_WIDTH_HUGE, CONFIG_HEIGHT_HUGE background "white";
set output OUTFILE_window;
win_default=5;
set title "Update window for sensor " . ID .", in number of intervals (default τ= ". win_default . " min)";
set label 15 sprintf("%d: %0.2f μSv/h", ID, STATS_mean_y * CPM2DRE) at graph 0.0240, graph 0.968 font FONT . ",18" textcolor rgb "#FF0066";
set label 16 LABEL at graph 0.0240, graph 0.94 font FONT . ",18" noenhanced textcolor rgb "#FF0066";
set format x "%m/%d"; set xtics offset 0, graph 0.03; set xlabel END_YEAR offset 0,1;
unset y2tics;
# default update in minutes
set yrange[0:20]; set ytics 0, 1; set format y "%.0fτ";
plot \
"< perl -ne 'print unless /^$/;' " . DATAFILE u 1:($5/60/win_default) w fsteps lw 1 lc rgb "blue" notitle;
unset ytics; unset y2tics; unset ylabel; unset title; unset for [i in "15 16"] label i;