2023-07-28 19:01:51 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
# -*- sh -*-
|
|
|
|
|
|
|
|
|
|
cat <<EOT
|
|
|
|
|
Content-type: text/html
|
|
|
|
|
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
|
<title>RPiRENA Data</title>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
2023-09-19 10:37:32 +00:00
|
|
|
<h1>Live plots of CHAOS-Jr on $(hostname)</h1>
|
2023-07-28 19:01:51 +00:00
|
|
|
<ul>
|
|
|
|
|
<li/><a href="rpirena?old">Show</a> the plots already processed (default).
|
|
|
|
|
<li/><a href="rpirena?plot">Process</a> new data and show the plots. May time out for big files.
|
|
|
|
|
<li/><a href="rpirena?trigger">Start processing</a> data, without waiting.
|
|
|
|
|
<li/><a href="rpirena-control">RPiRENA control.</a>
|
|
|
|
|
<li/><a href="/data/">Data Files.</a>
|
|
|
|
|
</ul>
|
|
|
|
|
EOT
|
|
|
|
|
|
|
|
|
|
exec 2>&1
|
2023-09-30 23:02:22 +00:00
|
|
|
if [ -x ./rpirena.py ]
|
|
|
|
|
then
|
|
|
|
|
data=./data
|
|
|
|
|
else
|
|
|
|
|
data=../../www/data
|
|
|
|
|
cd /home/$(hostname)/stephan/rpirena || exit
|
|
|
|
|
fi
|
|
|
|
|
lf=${data}/rpirena-cgi.log
|
|
|
|
|
lkf=${data}/rpirena-cgi.lock
|
2023-07-28 19:01:51 +00:00
|
|
|
|
|
|
|
|
declare -a QUERY=(${QUERY_STRING//&/ })
|
|
|
|
|
ACTION=${QUERY[0]}
|
|
|
|
|
[ -z "$ACTION" ] && TARGET="" || TARGET=${QUERY[-1]}
|
|
|
|
|
[ "$TARGET" = "$ACTION" ] && TARGET=""
|
|
|
|
|
[ -z "$ACTION" ] && ACTION=old
|
|
|
|
|
|
|
|
|
|
echo "$REMOTE_ADDR $HTTP_USER_AGENT $QUERY_STRING $ACTION $TARGET" >>$lf
|
|
|
|
|
[ -f "$lkf" ] && cat "$lkf" 2>/dev/null
|
|
|
|
|
[ -z "$TARGET" ] || cat <<EOF
|
|
|
|
|
<p/>Actions for the selected old data file:
|
|
|
|
|
<a href="rpirena?plot&$TARGET">plot</a>
|
|
|
|
|
<a href="rpirena?old&$TARGET">old</a>
|
|
|
|
|
<a href="rpirena?trigger&$TARGET">trigger</a>
|
|
|
|
|
<a href="rpirena?replot&$TARGET">replot</a>
|
|
|
|
|
<a href="rpirena?nomake&$TARGET">nomake</a>
|
|
|
|
|
EOF
|
|
|
|
|
cat <<EOF
|
|
|
|
|
<p/>Beware of the fake hwclock of the Raspberry Pi, the times in the filenames may be fake.
|
2023-09-18 10:34:01 +00:00
|
|
|
<p/>You may need to reload the page in your browser to see the latest plots (Ctrl-Shift-R).
|
2023-07-28 19:01:51 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
if [ "$ACTION" = "trigger" ]
|
|
|
|
|
then
|
|
|
|
|
export QUERY_STRING="replot&$TARGET"
|
2023-09-30 23:02:22 +00:00
|
|
|
nohup ../../www/cgi/rpirena > ${data}/rpirena-trigger.log 2>&1 &
|
2023-07-28 19:01:51 +00:00
|
|
|
ACTION="old"
|
|
|
|
|
fi
|
|
|
|
|
if [ "$ACTION" = "restart" ]
|
|
|
|
|
then
|
|
|
|
|
echo restart > auto-run
|
|
|
|
|
export ACTION="old"
|
|
|
|
|
fi
|
|
|
|
|
if [ "$ACTION" = "stop" ]
|
|
|
|
|
then
|
|
|
|
|
echo stop > auto-run
|
|
|
|
|
export ACTION="old"
|
|
|
|
|
fi
|
|
|
|
|
|
2023-09-30 23:02:22 +00:00
|
|
|
fn=${data}/$TARGET
|
|
|
|
|
[ -f $fn ] || fn=$(ls -1 ${data}/20??-??-??T??:??:??Z.EI | tail -1)
|
2023-07-28 19:01:51 +00:00
|
|
|
bfn=$(basename $fn .EI)
|
2023-09-30 23:02:22 +00:00
|
|
|
pfn=${data}/$bfn
|
2023-07-28 19:01:51 +00:00
|
|
|
sfn=${pfn}-spectra.png
|
|
|
|
|
hfn=${pfn}-hk.png
|
|
|
|
|
cfn=${pfn}-counts.png
|
2023-09-18 10:34:01 +00:00
|
|
|
ffn=${pfn}-fish.png
|
2023-07-28 19:01:51 +00:00
|
|
|
|
|
|
|
|
REPLOT=$ACTION
|
|
|
|
|
[ -f "$fn" -a "$fn" -nt "$sfn" -a "$ACTION" = "plot" ] && REPLOT=replot
|
|
|
|
|
if [ -f "$fn" -a "$REPLOT" = "replot" ] && dotlockfile -r 0 $lkf
|
|
|
|
|
then
|
|
|
|
|
trap "rm $lkf" EXIT
|
|
|
|
|
date +"Processing $bfn since %Y-%m-%d %H:%M:%S UTC" > $lkf
|
|
|
|
|
|
|
|
|
|
date +"Plot $bfn %Y-%m-%d %H:%M:%S" >>$lf
|
|
|
|
|
|
2023-09-18 10:34:01 +00:00
|
|
|
[ "$ACTION" = "nomake" ] || make UNIT=CHAOS ${pfn}.EmV ${pfn}.hist ${pfn}.HK ${pfn}.CP ${pfn}.FISH >>$lf 2>&1
|
2023-07-28 19:01:51 +00:00
|
|
|
|
|
|
|
|
cat <<EOT | gnuplot >>$lf 2>&1
|
2023-09-18 10:34:01 +00:00
|
|
|
print "plot fish"
|
|
|
|
|
set title "$(hostname) RPiRENA $bfn" noenh
|
|
|
|
|
set xrange [3:7]
|
|
|
|
|
set yrange [-2:2]
|
|
|
|
|
set cbrange [0.5:*]
|
|
|
|
|
set log cb
|
|
|
|
|
set xlab "E_{BGO}"
|
|
|
|
|
set ylab "E_A/E_C"
|
|
|
|
|
set grid front
|
|
|
|
|
set timestamp "%Y-%m-%d %H:%M:%S"
|
|
|
|
|
set term png size 1024,768
|
|
|
|
|
set out "${ffn}-new"
|
|
|
|
|
set xtics ("1MeV" 3, "10 MeV" 4, "100MeV" 5, "1GeV" 6, "10GeV" 7)
|
|
|
|
|
set ytics ("0.01" -2, "0.1" -1, "1" 0, "10" 1, "100" 2)
|
|
|
|
|
plot "${pfn}.FISH" nonuniform matrix not with image
|
|
|
|
|
unset out
|
|
|
|
|
reset
|
|
|
|
|
|
2023-07-28 19:01:51 +00:00
|
|
|
print "plot spectra"
|
|
|
|
|
set title "$(hostname) RPiRENA $bfn" noenh
|
|
|
|
|
set xrange [-10:160]
|
|
|
|
|
set yrange [-10:160]
|
|
|
|
|
set y2range [0.9:*]
|
|
|
|
|
set log y2
|
|
|
|
|
set ytics nomirror
|
|
|
|
|
set y2tics
|
|
|
|
|
set xlab "pulse height [mV]"
|
|
|
|
|
set ylab "pulse height [mV]"
|
|
|
|
|
set y2lab "[counts/mV]"
|
|
|
|
|
set grid
|
|
|
|
|
set timestamp "%Y-%m-%d %H:%M:%S"
|
|
|
|
|
set term png size 1024,768
|
|
|
|
|
set out "${sfn}-new"
|
|
|
|
|
plot \
|
|
|
|
|
"$pfn.EmV" u "AA":"CC" tit "A vs C" with d, \
|
|
|
|
|
"$pfn.EmV" u "B1":"B2" tit "B_1 vs B_2" with d, \
|
|
|
|
|
for [c in "AA CC B1 B2"] "$pfn.hist" u "mV":c axis x1y2 tit c w histeps
|
|
|
|
|
unset out
|
|
|
|
|
|
|
|
|
|
print "plot HK"
|
|
|
|
|
set xrange [*:*]
|
|
|
|
|
set xtics timedate
|
|
|
|
|
set format x "%d.%m.\n%Hh%M" time
|
|
|
|
|
set yrange [0:10<*<100]
|
|
|
|
|
set y2range [*:*]
|
|
|
|
|
unset log y2
|
|
|
|
|
set xlab "time [UTC]"
|
|
|
|
|
set ylab "[V] [10nA]"
|
|
|
|
|
set y2lab "[°C]"
|
|
|
|
|
set term png
|
|
|
|
|
set out "${hfn}-new"
|
|
|
|
|
array HN[8] = [ "V_{CORE}", "V_{CC}", "V_{IO}", "V_{PRIM}", "T_{FPGA}", "T_{OUT}", "T_{EBOX}", "I_{BIAS}" ]
|
|
|
|
|
plot \
|
|
|
|
|
for [c=8:8] "<tail -n +25 ${pfn}.HK" u 2:(column(2+c)/10) axis x1y1 tit HN[c] with l lt c, \
|
|
|
|
|
for [c=1:4] "<tail -n +25 ${pfn}.HK" u 2:2+c axis x1y1 tit HN[c] with l lt c lw 2, \
|
|
|
|
|
for [c=5:7] "<tail -n +25 ${pfn}.HK" u 2:2+c axis x1y2 tit HN[c] with l lt c lw 2
|
|
|
|
|
unset out
|
|
|
|
|
|
|
|
|
|
print "plot Counts"
|
|
|
|
|
set yrange [0.9:*]
|
|
|
|
|
set log y
|
|
|
|
|
set xlab "time [UTC]"
|
|
|
|
|
set ylab "[counts/min]"
|
2024-01-24 14:48:32 +00:00
|
|
|
set log y2
|
2023-07-28 19:01:51 +00:00
|
|
|
set y2lab "p [mbar]"
|
2024-01-24 14:48:32 +00:00
|
|
|
set y2range [0.1<*:*<1100] noextend
|
2023-07-28 19:01:51 +00:00
|
|
|
set term png
|
|
|
|
|
set out "${cfn}-new"
|
|
|
|
|
array CN[13] = ["A", "C", "B_1", "B_2", "AB_1B_2C (L)", "B_1B_2 (L)", "A", "C", "B_1", "B_2", "AC", "B_1B_2", "L_3"]
|
|
|
|
|
plot \
|
|
|
|
|
for [c=1:4] "<tail -n +3 ${pfn}.CP" u 19:(column(2+c)*60./\$17) tit "L_1[".(c-1)."]: ".CN[c+0] with l lt c+1 lw 0.5, \
|
|
|
|
|
for [c=5:12] "<tail -n +3 ${pfn}.CP" u 19:(column(2+c)*60./\$17) tit "L_2[".(c-5)."]: ".CN[c+0] with steps lt c-3 lw 1, \
|
|
|
|
|
"<tail -n +3 ${pfn}.CP" u 19:18 axis x1y2 notit "pressure" with l lt 5 lw 2, \
|
|
|
|
|
"<tail -n +3 ${pfn}.CP" u 19:18 axis x1y2 tit "pressure" with l lt 1 lw 0.8
|
|
|
|
|
|
|
|
|
|
unset out
|
|
|
|
|
|
|
|
|
|
EOT
|
|
|
|
|
mv -v $sfn-new $sfn >>$lf 2>&1
|
|
|
|
|
mv -v $hfn-new $hfn >>$lf 2>&1
|
|
|
|
|
mv -v $cfn-new $cfn >>$lf 2>&1
|
2023-09-18 10:34:01 +00:00
|
|
|
mv -v $ffn-new $ffn >>$lf 2>&1
|
2023-07-28 19:01:51 +00:00
|
|
|
|
|
|
|
|
rm -f $lkf
|
|
|
|
|
trap EXIT
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cat <<EOT
|
|
|
|
|
<h3>File: $bfn</h3>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><a href="/data/$bfn.CP">Count Rates</a>, <a href="/README.txt">README</a>
|
|
|
|
|
<li><a href="/data/$bfn.HK">Housekeeping</a>
|
|
|
|
|
<li><a href="/data/$bfn.EI">Raw Data</a>
|
|
|
|
|
</ul>
|
2023-09-18 10:34:01 +00:00
|
|
|
<p/><img src="/data/$bfn-fish.png"/>
|
2023-07-28 19:01:51 +00:00
|
|
|
<p/><img src="/data/$bfn-spectra.png"/>
|
|
|
|
|
<p/><img src="/data/$bfn-hk.png"/>
|
|
|
|
|
<p/><img src="/data/$bfn-counts.png"/>
|
|
|
|
|
|
|
|
|
|
<h2>Older Spectra:</h2>
|
|
|
|
|
<ul>
|
|
|
|
|
EOT
|
2023-09-30 23:02:22 +00:00
|
|
|
cd ${data}
|
2023-07-28 19:01:51 +00:00
|
|
|
ls -r1 20??-??-??T??:??:??Z.EI | xargs -i echo '<li> <a href="rpirena?old&{}">{}</a>'
|
|
|
|
|
cat <<EOT
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</p><img WIDTH=100% src="/data/IMG_4666-scaled.jpg"/>
|
|
|
|
|
</p><img WIDTH=100% src="/data/IMG_4667-scaled.jpg"/>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
EOT
|