glu=[datenum(string(readcell('Clarity_Export_GRATA_PAMELA_2023-12-14_133024.csv',...
    'Range','B3304:B3381'))),readmatrix('Clarity_Export_GRATA_PAMELA_2023-12-14_133024.csv','Range','H3304:H3381')];
fs=[datenum([2023 12 12 17 34 00;...
    2023 12 12 17 54 00;...
    2023 12 12 18 17 00;...
    2023 12 12 18 37 00;...
    2023 12 12 18 58 00;...
    2023 12 12 19 19 00;...
    2023 12 12 19 41 00;...
    2023 12 12 20 03 00;...
    2023 12 12 20 23 00;...
    2023 12 12 20 46 00;...
    2023 12 12 21 07 00;...
    2023 12 12 21 29 00;...
    2023 12 12 21 51 00;...
    2023 12 12 22 13 00;...
    2023 12 12 22 34 00]),...
    [91;82;93;98;169;205;199;200;246;226;230;225;215;215;219]];

tnom=-30+10.24/2:.0025:-10.24/2;
p=dir('pam*');

for i=1:length(p)
    filets(i)=datenum(str2num(p(i).name(5:8)),...
        str2num(p(i).name(10:11)),...
        str2num(p(i).name(13:14)),...
        str2num(p(i).name(16:17)),...
        str2num(p(i).name(19:20)),...
        str2num(p(i).name(22:23)));
    spects(i,:)=filets(i)+tnom/24/3600;
end

t=spects';
glufit=t(:);
glufit(:,2)=splinapp([glu(:,1)-5/24/60;fs(:,1)],[glu(:,2);fs(:,2)],ones(93,1)*5e5,glufit(:,1));
p2p=max(glufit(:,2))-min(glufit(:,2));
plot(glu(:,1)-5/24/60,glu(:,2),'o:',fs(:,1),fs(:,2),'o:',glufit(:,1),(glufit(:,2)-p2p)*1.1+p2p);grid;shg

save glu glu fs filets spects glufit
