Commit 62a7ca1f authored by Riccardo La Placa's avatar Riccardo La Placa
Browse files

Check there's at least one photon

parent cf97617a
Loading
Loading
Loading
Loading
+132 −126
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ close all

cd /data/Sorgenti/power_dist_test/
diary(['log_pow_dist_',char(datetime('now','Format','dd_MM')),'.log'])
%%
mario = split(ls('*.fits'));
mario = mario(~cellfun('isempty',mario));
mario = sort(mario);
@@ -32,6 +33,7 @@ epsmedio = 0;
mivalues = zeros(length(mario),100);
epsvalues = zeros(length(mario),100);
varvalues = zeros(length(mario),100,3);
%%
for i = 1:length(mario)
    filoc = [pwd,'/',char(mario(i))]
    % filoc = [pwd,'/',mario]
@@ -39,10 +41,13 @@ for i = 1:length(mario)
    % fits.closeFile(file);
    t_raw = fitsread(filoc,"binarytable");
    t_raw = t_raw{1};
    %%
    M=fix((t_raw(end)-t_raw(1))/Tseg)
    for m = 1:M
        disp(['Segment ',num2str(m),' of ',num2str(M),' in file',filoc,' '])
        tsplit = t_raw((t_raw>(t_raw(1)+Tseg*(m-1)))&(t_raw<(t_raw(1)+Tseg*m)));
        if (sum(tsplit)>0)

            % t_raw = t_raw(t_raw<(t_raw(1)+Tseg));
            tsplit = tsplit - tsplit(1);
            Nphot = length(tsplit);
@@ -57,22 +62,22 @@ for i = 1:length(mario)
            end
            Yqlbin(:) = Yqlbin(:)./(Fqlbin(:).*Tseg);

        if (i == 7)
            if (i == 1)
                tiledlayout(2,1)
                nexttile

            yme = mean(Y0(100*Tseg+1:end));
                yme = mean(Y0(500*Tseg+1:end));
                semilogx(Fqlmid,Yqlbin)
                xlim([10 3000])
                ylim([yme*0.8 yme*1.2])
                yline(yme)
            xline(100)
                xline(500)

                nexttile
                xlim([ted(1) ted(end)])
                plot(tm,gather(xtemp))

            pause
                % pause
            end


@@ -174,7 +179,7 @@ for i = 1:length(mario)
                ylim([0.0001 100])
                % legend('abs(extrtot1-datadist)/datadist','abs(extrtot4-datadist)/datadist','abs(extrtot8-datadist)/datadist')
                yline([0.01 0.1 0.5 1.0])
            pause
                % pause
                % end
            else
                disp('Too many counts!')
@@ -183,6 +188,7 @@ for i = 1:length(mario)
            % pause
        end
    end
end
epsmedio = epsmedio/length(mario)
epsnans = epsvalues;
epsnans(epsnans == 0) = NaN;