我正在处理来自记录器的 1Hz 时间戳(变量 'timestamp_1hz'),该记录器并非每秒都在同一时间记录(差异从 0.984 到 1.094 不等,但如果记录器打嗝,有时是 0.5 或几秒)。1Hz数据集用于构建10分钟平均数据集,每10分钟间隔必须有600条记录。因为记录器并不是每秒都在同一时间记录,所以时间戳会慢慢漂移到 1 秒标记。当时间戳超过 0 标记以及 0.5 标记时,就会出现问题。
我尝试了各种方法来预处理时间戳。它们之间大约 1 秒的时间戳应该被认为是有效的。一些例子包括:
% simple
% this screws up around half second and full second values
rawseconds = raw_1hz_new(:,6)+(raw_1hz_new(:,7)./1000);
rawsecondstest = rawseconds;
rawsecondstest(:,1) = floor(rawseconds(:,1))+ rawseconds(1,1);
% more complicated
% this screws up if there is missing data, then the issue compounds because k+1 timestamp is dependent on k timestamp
rawseconds = raw_1hz_new(:,6)+(raw_1hz_new(:,7)./1000);
A = diff(rawseconds);
numcheck = rawseconds(1,1);
integ = floor(numcheck);
fract = numcheck-integ;
if fract>0.5
rawseconds(1,1) = rawseconds(1,1)-0.5;
end
for k=2:length(rawseconds)
rawsecondstest(k,1) = rawsecondstest(k-1,1)+round(A(k-1,1));
end
我想预处理时间戳,然后使用“相交”将其与连续的 1Hz 时间戳进行比较,以找到丢失、重复等数据,例如:
% pull out the time stamp (round to 1hz and convert to serial number)
timestamp_1hz=round((datenum(raw_1hz_new(:,[1:6])))*86400)/86400;
% calculate new start time and end time to find contig time
starttime=min(timestamp_1hz);
endtime=max(timestamp_1hz);
% determine the contig time
contigtime=round([floor(mean([starttime endtime])):1/86400:ceil(mean([starttime endtime]))-1/86400]'*86400)/86400;
% find indices where logger time stamp matches real time and puts
% the indices of a and b
clear Ia Ib Ic Id
[~,Ia,Ib]=intersect(timestamp_1hz,contigtime);
% find indices where there is a value in real time that is not in
% logger time
[~,Ic] = setdiff(contigtime,timestamp_1hz);
% finds the indices that are unique
[~,Id] = unique(timestamp_1hz);
您可以在此处下载 10 天的 raw_1hz_new 时间戳。任何帮助或提示将不胜感激!