LOADPATH  = [LOADPATH ':/home/ftp/pub/hmaser/prog:/u1/p/matlab/toolbox/matlab/polyfun'];

data = load_bin_floats('/tmp/.plotrx.tmpfile', 5, 40, 8, 'double');
load /home/ftp/pub/hmaser/prog/rxdiode.mat

maxvoltage = max(table(:,1));
minvoltage = min(table(:,1));

endtime = max(data(:,1));
starttime = endtime - 7;

x2step = 2*24*3600;

data = data(find(data(:,1) >= starttime),:);
data = data(find(data(:,2) > minvoltage),:);
data = data(find(data(:,2) < maxvoltage),:);
data(:,2) = table1(table, data(:,2)*0.988);

starttime = min(data(:,1));

startsec = round((min(data(:,1)) - 51545)*24*60*60);
endsec = round((endtime - 51545)*24*60*60);

printf('set size 1,1\n');
printf('set term pbm color\n');
printf('set output\n');

printf('set rmargin 5\n');

printf('set x2data time\n');
printf('set x2range [%.0f:%.0f]\n', startsec, endsec);
printf('set format x2 \'%%d %%b %%Y\'\n');
printf('set xrange [%f:%f]\n', starttime, endtime);
printf('set xtics nomirror\n');
printf('set x2tics nomirror %.0f, %.0f, %.0f\n', startsec, x2step, endsec);
printf('set nomxtics\n');
printf('set nomx2tics\n');
%printf('set grid\n');
printf('set x2label \'Time [UT]\'\n');
printf('set xlabel \'Time [MJD]\'\n');
printf('set ylabel \'Temperature [K]\' 3\n');
printf('set title \'22 GHz RX physical temperature\'\n');
printf('set time\n');

printf('plot \'-\' notitle with lines\n');

for i = 1:length(data)
  printf('%f %f\n', data(i,1), data(i,2));
end
printf('e\n');
%keyboard

%plot(data(:,1), data(:,2));

