# Plot one day's heat battery target (and grid intensity and threshold) # May be used to plot a full (previous) and current (partial day). # Plot in banner (800x200) and thumbnail (80x20) formats. # Input of form: #2022-02-24T10:51Z MT 0 GI 168 IT 50 F X ES 1 #2022-02-24T11:01Z MT 0 GI 167 IT 50 F - ES 5 #2022-02-24T11:11Z MT 0 GI 161 IT 50 F BX ES 5 #2022-02-24T11:21Z MT 0 GI 155 IT 50 F BX ES 5 set timefmt "%Y-%m-%dT%H:%MZ" set datafile missing "-" # Draw thumbnail PNG and extract stats first. set output "out/tmp/_heatbatterytarget-tn.tmp.png" set terminal png small size 80,20 # Could select more detailed timestamp for intra-day data periods. set xdata time set noxtics set noytics set noborder set rmargin 0 set tmargin 0 set bmargin 0 set lmargin 0 plot ".work/_heatbatterytarget.log" \ using 1:3 smooth bezier notitle with lines lw 3 xmax = GPVAL_DATA_X_MAX xmaxsd = strftime("%Y-%m-%d", xmax) xmaxst = strftime("%H:%MZ", xmax) #show variables all # Draw main PNG output. set output "out/tmp/_heatbatterytarget.tmp.png" set terminal png size 800,200 #set terminal png size 640,240 #set format x "%m/%d" set format x "%m-%d\n%H%MZ" #set format x "%H%MZ" #set title "Heat Battery % Fill Target vs Grid Intensity and Threshold" set label "Heat Battery Target\nto\n".xmaxsd." ".xmaxst at screen 1, screen .3 right set key outside set key right #set key box set border #set lmargin 1.5 unset lmargin set rmargin 30 set tmargin 0.5 set bmargin 2.5 set grid xtics y2tics set yrange [0:100] #set xtics rotate set format y "%g%%" set xtics set ytics set y2tics set format y2 "%ggCO2/kWh" #set tics scale 3 # Don't show default ES 1 state. # Define a function to map strings to colours ES state. # Red=full=5, green=divert=3, yellow=boost=4, rest grey? Status 1=Paused, 3=Diverting, 4=Boost, 5=Max Temp Reached, 6=Stopped map_colour_ES(es) = ( \ es == 6 ? 0x000000 : \ es == 5 ? 0xff0000 : \ es == 4 ? 0xfebe00 : \ es == 3 ? 0x00ff00 : \ 0x666666) # Map colour for grid intensity from flags. # Green if flags contain "G". # Red if flags contain "R". # Default yellow. map_colour_F(str) = ( \ 0 != strstrt(str, "G") ? 0x00ff00 : \ 0 != strstrt(str, "R") ? 0xff0000 : \ 0xfebe00) plot ".work/_heatbatterytarget.log" \ using 1:(($11!=1)?($11*10):NaN):(map_colour_ES($11)) title "eddi state" with points lc rgb variable, \ "" using 1:7 title "Int Thrshld" with lines axes x1y2 lc black, \ "" using 1:5:(map_colour_F(stringcolumn(9))) title "Grid Int" with lines axes x1y2 lw 2 lc rgb variable, \ "" using 1:3 title "max % fill" with lines lw 3 ## Now create larger image. #set terminal png size 1280,480 #set output ".work/multisensortempL.png" #set noytics ##set y2tics 1 #plot for [i=2:8] ".work/multisensortemp.dat" \ # using 1:(column(i)/16) title columnheader(i) with lines axes x1y2 lw 1