mirror of
https://github.com/eddyem/tsys01.git
synced 2026-01-31 20:35:04 +03:00
fix bug in logger
This commit is contained in:
parent
32fef9cc9f
commit
74c21e8b0f
14
m-files/plotdt.m
Normal file
14
m-files/plotdt.m
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
function plotdt(T, idxsch)
|
||||||
|
idxsch *= 2;
|
||||||
|
difrns = T(:,idxsch-1)-T(:,idxsch);
|
||||||
|
D = median(difrns);
|
||||||
|
sgn = '+';
|
||||||
|
if(D < 0) sgn = '-'; endif
|
||||||
|
sigma = std(difrns);
|
||||||
|
printf("T_1(%d) = T_0(%d) %c%.4f +- %.4f\n", idxsch, idxsch, sgn, abs(D), sigma);
|
||||||
|
plot(T(:,1), medfilt1(D-difrns, 5));
|
||||||
|
%plot(T(:,1), T(:,idxsch)-T(:,idxsch-1)+D);
|
||||||
|
xlabel("T, ^\\circ{}C");
|
||||||
|
ylabel(sprintf("T_1-T_0%c%.4f", sgn, abs(D)));
|
||||||
|
title(sprintf("Temperature difference for pair %d (\\sigma=%.4f)", idxsch/2, sigma));
|
||||||
|
endfunction
|
||||||
14
m-files/plotpair.m
Normal file
14
m-files/plotpair.m
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
function plotpair(T, idxsch1, idxsch2)
|
||||||
|
i1 = 2*idxsch1-1;
|
||||||
|
i2 = 2*idxsch2-1;
|
||||||
|
difrns = T(:,i1)-T(:,i2);
|
||||||
|
D = median(difrns);
|
||||||
|
sigma = std(difrns);
|
||||||
|
sgn = '+';
|
||||||
|
if(D < 0) sgn = '-'; endif
|
||||||
|
printf("T_0(%d) = T_0(%d) %c%.4f +- %.4f\n", idxsch2, idxsch1, sgn, abs(D), sigma);
|
||||||
|
plot(T(:,1), medfilt1(D-difrns, 5));
|
||||||
|
xlabel("T, ^\\circ{}C");
|
||||||
|
ylabel(sprintf("T(%d_0) - T(%d_0) %c %.4f", idxsch2, idxsch1, sgn, abs(D)));
|
||||||
|
title(sprintf("Temperature difference for sensors %d_0 and %d_0 (\\sigma=%.4f)", idxsch2, idxsch1, sigma));
|
||||||
|
endfunction
|
||||||
49
m-files/readtemp.m
Normal file
49
m-files/readtemp.m
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
function [tm T goodrecs diffs] = readtemp(name)
|
||||||
|
% return arrays of unix time & temperatures from file `name`
|
||||||
|
% substitute missed values by interpolation
|
||||||
|
T = dlmread(name);
|
||||||
|
nrecs = size(T, 1);
|
||||||
|
nsensors = size(T, 2) - 1;
|
||||||
|
if(nrecs < 2 || nsensors < 2) return; endif
|
||||||
|
tm = T(:, 1);
|
||||||
|
tm -= tm(1);
|
||||||
|
T(:,1) = [];
|
||||||
|
goodrecs = [];
|
||||||
|
% interpolate missing values
|
||||||
|
for N = 1:nsensors
|
||||||
|
term = T(:, N);
|
||||||
|
badidxs = find(term < -275.);
|
||||||
|
bads = size(badidxs, 1);
|
||||||
|
if(bads > nrecs/2)
|
||||||
|
printf("%d: all (or almost all) data records are bad\n", N);
|
||||||
|
continue;
|
||||||
|
elseif(bads) % some records are bad, try to make interpolation
|
||||||
|
printf("%d: %d bad records\n", N, bads);
|
||||||
|
tmx = tm; Tx = term;
|
||||||
|
tmx(badidxs) = [];
|
||||||
|
Tx(badidxs) = [];
|
||||||
|
T(:, N) = interp1(tmx, Tx, tm, "spline");
|
||||||
|
endif
|
||||||
|
goodrecs = [goodrecs N];
|
||||||
|
endfor
|
||||||
|
% remove strings with NANs
|
||||||
|
ii = find(isnan(T));
|
||||||
|
s = size(T, 1);
|
||||||
|
idxs = ii - s*floor((ii-1)/s);
|
||||||
|
T(idxs, :) = [];
|
||||||
|
tm(idxs) = [];
|
||||||
|
diffs = T - median(T,2);
|
||||||
|
% now remove bad records
|
||||||
|
for N = goodrecs
|
||||||
|
term = abs(diffs(:, N));
|
||||||
|
badidxs = find(term > 3.);
|
||||||
|
bads = size(badidxs, 1);
|
||||||
|
if(bads)
|
||||||
|
tmx = tm; Tx = T(:, N);
|
||||||
|
tmx(badidxs) = [];
|
||||||
|
Tx(badidxs) = [];
|
||||||
|
T(:, N) = interp1(tmx, Tx, tm);
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
diffs = T - median(T,2);
|
||||||
|
endfunction
|
||||||
29
m-files/testval.m
Normal file
29
m-files/testval.m
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
function v = testval()
|
||||||
|
K = [34100, 22617, 15996, 7338, 5714];
|
||||||
|
printf("RAW\t\tdouble\tint\n");
|
||||||
|
for raw = 8000000:100000:10000000;
|
||||||
|
ii = getint(K, raw);
|
||||||
|
s = sign(ii);
|
||||||
|
ii = abs(ii);
|
||||||
|
f = floor(ii/100);
|
||||||
|
printf("%10d\t%.2f\t%d.%02d\n", raw, getdouble(K, raw), f*s, ii-100*f);
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function T = getdouble(K, raw)
|
||||||
|
val = raw/256.;
|
||||||
|
T = K(1)*(-1.5e-2) + 0.1e-5*val*(K(2) + 1e-5*val*(K(3)*(-2) + 1e-5*val*(4*K(4) + 1e-5*val*(-2)*K(5))));
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function T = getint(K, raw)
|
||||||
|
val = int64(raw);
|
||||||
|
mul = int64([0, 1, -2, 4, -2]);
|
||||||
|
tmp = int64(0);
|
||||||
|
for j = 5:-1:2
|
||||||
|
tmp /= 100000;
|
||||||
|
tmp += mul(j) * K(j);
|
||||||
|
tmp *= val;
|
||||||
|
tmp /= 256;
|
||||||
|
endfor
|
||||||
|
T = double(tmp*1e-4 + (-1.5)*K(1));
|
||||||
|
endfunction
|
||||||
Loading…
x
Reference in New Issue
Block a user