csv Gnuplot时间列包含少量测量值,一个数据包含“天溢出”

mjqavswn  于 2022-12-20  发布在  其他
关注(0)|答案(1)|浏览(101)

我做了一些电池放电的测量。现在我想用Gnuplot来绘制它们。问题是,其中一个测量开始得很晚,我的24小时时钟“溢出”了。
下面是我的问题的一个例子-. csv-测量数据:

Time;Voltage;Current;Charge;Power;Energy;Temperature
...
23:59:54;3.2387;0.6989;0.039;2.264;0.127;22.0
23:59:55;3.2387;0.6989;0.039;2.264;0.128;22.0
23:59:56;3.2387;0.6989;0.039;2.264;0.129;22.0
23:59:57;3.2387;0.6989;0.04;2.264;0.129;22.0
23:59:58;3.2387;0.6992;0.04;2.264;0.13;22.0
23:59:59;3.2386;0.6989;0.04;2.263;0.13;22.0
00:00:00;3.2386;0.6992;0.04;2.264;0.131;22.0
00:00:01;3.2386;0.6989;0.04;2.263;0.132;22.0
00:00:02;3.2386;0.6992;0.041;2.264;0.132;22.0
00:00:04;3.2386;0.6992;0.041;2.264;0.133;22.5
00:00:05;3.2386;0.6989;0.041;2.263;0.134;22.5
00:00:06;3.2386;0.6989;0.041;2.263;0.134;22.5
00:00:07;3.2386;0.6989;0.041;2.263;0.135;22.0

其他数据不是在两天之间测量的。
使用以下Gnuplot代码:

set grid
set title 'Entladungen der Batterie über Zeit'
set tics nomirror
set title font ",12"
set ylabel 'U/V' font ",12"
set key box font ",12"
set xtics time
set xlabel 'time' font ",12"
set border 11
set border lw 2
set xtics font ",8"
set term wxt size 1200, 460
myFmt = "%H:%M:%S"
set datafile separator ";"
set format x "%tH:%M:%S" #timedate
set yrange[2.6:3.7]

plot 'Entadung_4,2A_Temp_22,5C°.csv' u (t=timecolumn(1,myFmt), $0==0?t01=t:0, t-t01):2 every ::2::1061 lt 7 lc "blue" with lines      ti "Entladung bei 3C", \
     'Entadung_2,8A_Temp_22,5C°.csv' u (t=timecolumn(1,myFmt), $0==0?t02=t:0, t-t02):2 every ::2::1604 lt 7 lc "web-green" with lines ti "Entladung bei 2C", \
     'Entadung_1,4A_Temp_22,0C°.csv' u (t=timecolumn(1,myFmt), $0==0?t03=t:0, t-t03):2 every ::2::3267 lt 7 lc "red" with lines      ti "Entladung bei 1C",\
     'Entadung_0,7A_Temp_22,0C°.csv' u (t=timecolumn(1,myFmt), $0==0?t04=t:0, t-t04):2 every ::2::6696 lt 7 lc "yellow" with lines ti "Entladung bei 0,5C", \
     'Entadung_0,28A_Temp_22,0C°.csv' u (t=timecolumn(1,myFmt), $0==0?t05=t:0, t-t05):2 every ::2::16977 lt 7 lc "black" with lines      ti "Entladung bei 0,2C",\
     'Entadung_0,14A_Temp_22,5C°.csv' u (t=timecolumn(1,myFmt), $0==0?t06=t:0, t-t06):2 every ::2::33731 lt 7 lc "violet" with lines      ti "Entladung bei 0,1C"

我得到了这个输出:

情节需要23个小时,并从每个时间步中减去ist。所以我得到负时间。。
有人知道,我怎么能只对这一个数据使用偏移量,而其他数据保持不变?
我本来以为黄色的图会在红色和黑色的图之间。

u3r8eeie

u3r8eeie1#

不幸的是,您没有记录日期。如果您记录了日期,就不会有这个问题了。
但你可以解释午夜过境点与一个小的补充。

  • 在plot命令之前指定t1=NaNtd=0
  • 在plot命令(循环)中,分配t0=t1,然后直接分配t1=timecolumn(...)。因此,t0始终保留以前的值,t1始终保留当前值
  • 每次t1<t0(即跨越午夜)将td增加一天,即td=td+secsPerDay(每天的秒数),并将td添加到您的绘图值。
  • 此外,如果您使用%tH作为x时间格式,则在测量运行超过24小时的情况下,小时数不会在24小时时换行(选中help time_specifiers)。
    • 脚本:**
### account for midnight crossings
reset session

$Data <<EOD
23:59:00   3.7
01:59:00   3.6
12:00:00   3.5
23:00:00   3.4
02:30:00   3.3
13:00:00   3.2
23:00:00   3.1
03:00:00   3.0
14:00:00   2.9
EOD

myFmt = "%H:%M:%S"
secsPerDay = 3600*24

set xlabel "hours:min"
set format x "%tH:%M" timedate

set multiplot layout 2,1

    plot $Data u (t=timecolumn(1,myFmt), $0==0? t01=t:0, t-t01):2 w lp pt 7 lc "red" ti "as is"
    
    plot t1=(td=0,NaN) $Data u (t0=t1,t1=timecolumn(1,myFmt), $0==0? t01=t1:0, \
         t1<t0?td=td+secsPerDay:0, t1-t01+td):2 w lp pt 7 lc "blue" ti "add day offset"
    
unset multiplot
### end of script
    • 结果:**

相关问题