绘制两个具有不同时间格式的文件

Plot two files with different time formats

我从站点(时间戳 %Y-%m-%d %H:%M)获得了数据,我想将其与参考文件(时间戳:%H:%M)进行比较 来自气象站的数据文件每分钟有 1 个条目 参考文件每 15 分钟有一个条目。

我试图将两个文件绘制在同一个轴上,但由于某种原因它不起作用。 我在绘制参考文件时也尝试了 (timecolumn(1, "%H:%M") 命令。

set xdata time
set timefmt "%Y-%m-%d %H:%M"
set format x "%H:%M"
`Set title '24.12.2014'`
set origin 0,0.66
"data_20141224.csv" using 1:25 axes x1y2 linewidth 1 lc rgb 'orange' w l  title 'SolarRadiation',\
"refdat.txt" using (timecolumn(1, "%H:%M")):4 axes x1y2  linewidth 1 lc rgb 'yellow' w l title 'CI Reference'

2.情节(CI参考)从来没有出现在情节上。

气象站输入文件:

2014-12-24 06:00    1.00    0.93    0.93    0.00    9   4.8 4.8 4.8 63
2014-12-24 06:01    1.00    0.93    0.93    0.00    9   4.8 4.8 4.7 63
2014-12-24 06:02    1.00    0.93    0.93    0.00    9   4.7 4.7 4.7 63

参考输入文件:

08:22   56  32  161 54  282 85  29  349
08:37   75  42  228 68  358 112 40  460
08:52   94  51  295 81  425 131 46  539

感谢到目前为止的帮助 这是我输入的内容:

clear
reset
set title "24.12.2014" font "verdana,08"
set xdata time
set timefmt "%Y-%m-%d %H:%M"
set format x "%H:%M" time
set xlabel "Time"
set ylabel "CloudinessIndex" 
set y2label "Irradiance"
set ytics (0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0)
set yrange [0:1]
set ytics nomirror
set y2range [0:1200]
set y2tics (0,100,200,300,400,500,600,700,800,900,1000,1100,1200)
set xrange ['06:00':'22:00']
set autoscale x
set nokey
set grid
#Plot:
plot s=0, "data_20141224.csv" using \
(s==0 ? (s=timecolumn(1,"%Y-%m-%d %H:%M"),0) : (timecolumn(1,"%Y-%m-%d %H:%M")-s)):25 axes x1y2 linewidth 1 lc rgb 'orange' w l title 'SolarRadiation',\
"refdata.txt" using (timecolumn(1,'%H:%M')):4 axes x1y2  linewidth 1 lc rgb 'yellow' w l title 'CI Reference',

它仍然只绘制日志文件中的数据 :-(

要自动偏移第一个数据点的值,您可以执行以下操作:

 plot s=0, datafile using \
    (t=, s==0 ? (s=t,t-s) : t-s) : 2

s=0 是一项任务,gnuplot 不会绘制这些。 using 语句由一个 ternary operator (a?b:c) 和两个 serial evaluation(逗号)组成,仅返回最后一个值。

要偏移日期(因为您只需要白天),您必须使用 floor() 函数将 s 向下舍入到 00:00。 设置正确的文件名和格式字符串变量,然后做

 plot s=0, logfile using \
      (t=timecolumn(1,fstr1), s==0 ? (s=24*3600*floor(t/24/3600),t-s) : t-s) ,\
      reffile using (timecolumn(1,fstr2)):2

现在你的图中应该有两个数据集。做'set format x fstr time'设置,装饰等就大​​功告成了。

如果您想要更简单:只需忽略日志文件中的日期部分:

set xdate time
set timefmt "%H:%M"
set format x "%H:%M" time
plot data using 2:3, ref using 1:2

如果您的时间格式说明符包含 space(例如“%y-%m-%d %H:%M”),gnuplot 会对列重新编号,以便日期仅是一列。否则,您的日志文件中的日期部分将被视为它自己的列,包含未使用的字符串值。