    
O3_data=[];fastO3_day=[];fastO3_uncorr=[];
O3=[];

for ddd=209;
    jd=num2str(ddd);
    if  ddd<100;
        jd=['0' num2str(ddd)];	
    end;
          
          
    for hhh=0;
    
        hr='00';
        hr2='23';
        jd2=num2str(ddd-1);
        fid1=fopen([way_rawdata, '\GOMECC\day' ,jd2, '\P4_',jd2,hr2]);
        fid2=fopen([way_rawdata, '\GOMECC\day' ,jd, '\P4_',jd,hr]);
        disp(['P4_', jd,hr])
        
        dump=fgetl(fid1);
        dump2=fgetl(fid1);
        ozone_data1=fscanf(fid1, '%f, %f %f', [3,inf]);    
        ozone_data1=ozone_data1';

        time=ozone_data1(:,1)/1000; 
        time=time-time(1);
        slowO3=ozone_data1(:,2);
        fastO3=ozone_data1(:,3);

        time_real1=0:0.1:3599.9;                                                %enlarge vector to 36000 values
        fastO3_real1=interpft(fastO3,36000);
        %fastO3_real=(time,fastO3,time_real','nearest');

        
        dump=fgetl(fid2);
        dump2=fgetl(fid2);
        ozone_data2=fscanf(fid2, '%f, %f %f', [3,inf]);    
        ozone_data2=ozone_data2';
               
        time=ozone_data2(:,1)/1000; 
        time=time-time(1);
        slowO3=ozone_data2(:,2);
        fastO3=ozone_data2(:,3);

        time_real2=0:0.1:3599.9;                                                %enlarge vector to 36000 values
        fastO3_real2=interpft(fastO3,36000);
        %fastO3_real=(time,fastO3,time_real','nearest');

        fastO3_real=[fastO3_real2(35958:36000);fastO3_real1(1:36000-43)];       %lagtime 4.3 s
        
        O3ppb_real=(fastO3_real-2155.44)/3823.13;                               %Calibration average over all calibrations ecxcept Jd 196
        O3mean=tenminmean_GOMECC(O3ppb_real,10,10);
        O3=[O3;O3mean];

        O3_data=[O3_data;ozone_data];
        fastO3_day=[fastO3_day;fastO3_real];%_real
        fastO3_uncorr=[fastO3_uncorr;fastO3];
        
        disp(['Calculating spectra for ',num2str(hhh)])
        [Sw,F]=psd2(detrend(O3ppb_real),length(O3ppb_real),10.);
        [Sws,Fsw]=specsmoo(Sw,10.);
          
        figure; loglog(Fsw(length(Fsw)-31:length(Fsw)),((Fsw(length(Fsw)-31:length(Fsw))).^(-2/3))./(Fsw(length(Fsw)-18).^(-2/3)).*Sws(length(Fsw)-18).*Fsw(length(Fsw)-18),'r');
        hold
        loglog(Fsw,Sws.*Fsw,'g');
            
        title(['O3 Spectra:   Day ',jd,hr]);
        legend('5/3','O3');       xlabel('Frequency in Hz');
        ylabel('Spectrum * Frequency');
        print([way_rawdata, '\GOMECC\Analysis\O3ppb_' jd  '.jpg'],'-djpeg');
    end;     
    
    
    for hhh=1:23;
        hr=num2str(hhh);
        hhh2=hhh-1;
        if hhh<10
           hr=['0' num2str(hhh)];
        end;
        if hhh2<10
           hr2=['0' num2str(hhh2)];
        end;
            
           fid1=fopen([way_rawdata, '\GOMECC\day' ,jd, '\P4_',jd,hr]);
           fid2=fopen([way_rawdata, '\GOMECC\day' ,jd, '\P4_',jd,hr2]);
           disp(['P4_', jd,hr]);

           dump=fgetl(fid1);
           dump2=fgetl(fid1);
           ozone_data1=fscanf(fid1, '%f, %f %f', [3,inf]);    
           ozone_data1=ozone_data1';
            
           time=ozone_data1(:,1)/1000; 
           time=time-time(1);
           slowO3=ozone_data1(:,2);
           fastO3=ozone_data1(:,3);

           time_real=0:0.1:3599.9;                                              %enlarge vector to 36000 values
           fastO3_real1=interpft(fastO3,36000);
           %fastO3_real=(time,fastO3,time_real','nearest');
    
            
           dump=fgetl(fid2);
           dump2=fgetl(fid2);
           ozone_data2=fscanf(fid2, '%f, %f %f', [3,inf]);    
           ozone_data2=ozone_data2';

           time=ozone_data2(:,1)/1000; 
           time=time-time(1);
           slowO3=ozone_data2(:,2);
           fastO3=ozone_data2(:,3);

           time_real=0:0.1:3599.9;                                              %enlarge vector to 36000 values
           fastO3_real2=interpft(fastO3,36000);
           %fastO3_real=(time,fastO3,time_real','nearest');
    
           fastO3_real=[fastO3_real2(35958:36000);fastO3_real1(1:36000-43)];    % lagtime 4.3 s
           
           O3ppb_real=(fastO3_real-2155.44)/3823.13;                            %average over all calibrations ecxcept Jd 196
           O3mean=tenminmean_GOMECC(O3ppb_real,10,10);
           O3=[O3;O3mean];

           O3_data=[O3_data;ozone_data];
           fastO3_day=[fastO3_day;fastO3_real];%_real
           fastO3_uncorr=[fastO3_uncorr;fastO3];
    
           if hhh==12 | hhh==18,
              disp(['Calculating spectra for ',num2str(hhh)])
              [Sw,F]=psd2(detrend(O3ppb_real),length(O3ppb_real),10.);
              [Sws,Fsw]=specsmoo(Sw,10.);
          
              figure; loglog(Fsw(length(Fsw)-31:length(Fsw)),((Fsw(length(Fsw)-31:length(Fsw))).^(-2/3))./(Fsw(length(Fsw)-18).^(-2/3)).*Sws(length(Fsw)-18).*Fsw(length(Fsw)-18),'r');
              hold
              loglog(Fsw,Sws.*Fsw,'g');
            
              title(['O3 Spectra:   Day ',jd,hr]);
              legend('5/3','O3');       xlabel('Frequency in Hz');
              ylabel('Spectrum * Frequency');
              print([way_rawdata, '\GOMECC\Analysis\O3ppb_' jd  '.jpg'],'-djpeg');
           
        end;%end hhh=0 or 12 or 18
    end;    
end;
time=O3_data(:,1)/1000; 
time_uncorr=time-time(1);
time=0:0.1:86399.9;
slowO3=O3_data(:,2);

figure;plot(time,fastO3_day);xlabel('time / s');ylabel('counts / s');title(['fastO3, Julian Day:',jd]);
print([path, '\GOMECC\Auswertung\fastO3_' jd  '.jpg'],'-djpeg');

figure;plot(time,fastO3_day,'.');hold on;plot(time_uncorr,fastO3_uncorr,'r.'); %red points are the uncorrected, original data points
xlabel('time / s');ylabel('counts / s');title(['fastO3_day, Julian Day:',jd]);

figure;plot(time_uncorr,slowO3); %slow Ozone
xlabel('time / s');ylabel('ppb');title(['slow O3, Julian Day:',jd]);

figure;plot(O3,'.'); %plot 10 min mean ozone data
ylabel('ppb');title(['10min mean, Julian Day:',jd]);
print([way_rawdata, '\GOMECC\Analysis\O3ppb_' jd  '.jpg'],'-djpeg');



