Commit 041df593 authored by Riccardo La Placa's avatar Riccardo La Placa
Browse files

Changes I should have committed at the end of July

parent 4a1b61ca
Loading
Loading
Loading
Loading
+26 −8
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ for i = 1:length(mario)
    [xtemp,~]=(histcounts(t_raw,ted));
    xtemp = gpuArray(xtemp);
    Y0 = abs(fft(xtemp));
    Y0 = 2.0.*(Y0(2:N/2+1).^2)./Y0(1);
    Y0 = 2.0.*(Y0(1:N/2+1).^2)./Y0(1);
end


@@ -37,20 +37,38 @@ end
% mean(xtemp)
% round(length(xtemp(xtemp == 0)))/N
% ptot0 = length(xtemp(xtemp == 0))/N;
% mi = -ln(ptot0)
% mi = -log(ptot0)
% mi = -log(ptot0);
% exp(-mi)-ptot0
% creps = 1 - (length(xtemp(xtemp == 1))/N)/(mi*ptot0);
% ncross = 8;
% crn = 8;
% ncr = 8;
% epscr = 1 - (length(xtemp(xtemp == 1))/N)/(mi*ptot0);
% clear creps ncross crn
% pcr = 1- (1-epscr)^(1/ncr)
% expec1 = 1+ epscr + (3*(ncr-1)/(2*ncr))*epscr^2;
% var1 = epscr + (epscr^2)*(7-9/ncr)/2;
% enf = 1 + var1/(expec1^2);
pcr = 1- (1-epscr)^(1/ncr);
expec1 = 1+ epscr + (3*(ncr-1)/(2*ncr))*epscr^2;
var1 = epscr + (epscr^2)*(7-9/ncr)/2;
enf = 1 + var1/(expec1^2);
expectot = expec1*mi;
vartot = var1*mi + mi*expec1^2;
% qcr = (1-epscr)^(1/8)
% expec8L = 1*(1-epscr) + 2*(8*pcr*qcr^14) + 3*(84*(pcr^2)*(qcr^20)) + 4*24*(pcr^3)*(qcr^24)*(1+3*qcr+38*qcr^2)
% expec8L = 1*(1-epscr) + 2*(8*pcr*qcr^14) + 3*(84*(pcr^2)*(qcr^20))
% expec8L = 1*(1-epscr) + 2*(8*pcr*qcr^14) + 3*(84*(pcr^2)*(qcr^20)) + 4*24*(pcr^3)*(qcr^24)*(1+3*qcr+38*qcr^2) + 4*(pcr^4)*(qcr^30)*(180+540*qcr+2521*qcr2)
% expec8L = 1*(1-epscr) + 2*(8*pcr*qcr^14) + 3*(84*(pcr^2)*(qcr^20)) + 4*24*(pcr^3)*(qcr^24)*(1+3*qcr+38*qcr^2) + 4*(pcr^4)*(qcr^30)*(180+540*qcr+2521*qcr^2)
% p8l1 = (1-epscr);
% p8l2 = (8*pcr*qcr^14);
% p8l3 = (84*(pcr^2)*(qcr^20));
p8l(1) = (1-epscr);
p8l(2) = (8*pcr*qcr^14);
p8l(3) = (84*(pcr^2)*(qcr^20));
p8l(4) = 24*(pcr^3)*(qcr^24)*(1+3*qcr+38*qcr^2);
p8l(5) = 4*(pcr^4)*(qcr^30)*(180+540*qcr+2521*qcr^2);
r8l = p8l(5)/(1-sum(p8l(1:4)))
% expec8L = 1*(1-epscr) + 2*(8*pcr*qcr^14) + 3*(84*(pcr^2)*(qcr^20)) + 4*24*(pcr^3)*(qcr^24)*(1+3*qcr+38*qcr^2) + p8l(5)*(1+4*r8l)/r8l^2
% sum(p8l(:))
for k = 6:10
p8l(k) = p8l(5)*(1-r8l)^(k-5);
end

% load('counts_check_Tseg_490_.mat')
% Y0 = 2.0.*(abs(fft(x(:,1))).^2)./sum(x(:,1));
+26 −13
Original line number Diff line number Diff line
@@ -190,8 +190,8 @@ end

% Parameters for Sco X-1
 % s 
f_max = 600
f_min = 550
f_max = 250
f_min = 100
f_step = 1/Tseg
f_gr = (f_min:f_step:f_max).';
% Porb = 68023.919 % s
@@ -370,7 +370,7 @@ tm=gpuArray(tm);
nibank = gpuArray(combinations(nis{:}).Variables);
% Lambda = zeros(length(f_gr),length(nibank),'single','gpuArray'); % MATLAB
% stores array elements in a column-major layout
Lambda = zeros(length(f_gr),length(nibank),'single');
Lambda = zeros(length(f_gr),length(nibank),'single','gpuArray');
F1=gpuArray((0:N-1)./(N*dt_psd)).';
f_ind = zeros(1,length(f_gr),'uint32');
for n = 1:length(f_gr)
@@ -490,7 +490,7 @@ end
%% 

%%
tic
%tic
% nisearcher = KDTreeSearcher(nibank,'BucketSize',100);
nisearcher = KDTreeSearcher(gather(nibank),'BucketSize',100);
%% The line above will have to be substituted with something along the lines
@@ -500,9 +500,20 @@ nisearcher = KDTreeSearcher(gather(nibank),'BucketSize',100);
% nisearcher = ExhaustiveSearcher(nibank,'Distance',gdistance);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

nodesnum = length(porb_gr)*length(a_gr)*length(tasc_gr)*length(f_gr);
nodesmem = (nodesnum*8.0)/1024^3; %->to bytes -> to GBs

memthres = 44.0 - (length(f_gr)*length(nibank)*8.0)/1024^3;

if (nodesmem > memthres)

end


parbank = combinations(porb_gr,a_gr,tasc_gr).Variables;
%bestpar = zeros(1,5);
toc
%toc

parno = length(parbank);
if (nino<intmax('uint16'))
@@ -618,19 +629,22 @@ disp(['The number of combinations of ni combinations actually walked is ',num2st
disp(['therefore, when considering just them instead, Σ_max corresponds to a false alarm probability of ',num2str(pfamax2),','])
disp(['while the multi-trial threshold for a false alarm probability = ',num2str(pfa),' is eq. to ',num2str(sigmastar2),'.']);


memused = whos('totlam').bytes;

memused = whos;
summina = 0;
for k = 1:length(memused)
summina = summina + memused(k).bytes;
end
clear memused
%inKB = memused/1024;
%inMB = memused/1024^2;
inGB = memused/1024^3;
inGB = summina/1024^3;
%fprintf("The workspace will need %.5f KB or %.5f MB or %.5f GB of memory", inKB, inMB, inGB)

timerapp = 44.0*memused/670891259696.0;
timerapp = 24.0*summina/518260001575;

% disp(bestpar);
% save('C:\Users\Filippo\Desktop\XMM_Jxxx\risultelli.mat');
disp(['I am about to save around ',num2str(1.6*inGB),' GB of data, it should take roughly ',num2str(round(timerapp)),' minutes.']);
disp(['I am about to save around ',num2str(round(inGB)),' GB of data (+ headers), it should take roughly ',num2str(round(timerapp)),' minutes.']);
save([pathfi,'risultelli_test_',char(datetime('now','Format','dd_MM')),'_',num2str(Tseg),'s_amax',num2str(a_max),'_fmax',num2str(f_max),'.mat'],"-v7.3","-nocompression");
disp(['Results saved in ',pathfi,'risultelli_test_',char(datetime('now','Format','dd_MM')),'_',num2str(Tseg),'s_amax',num2str(a_max),'_fmax',num2str(f_max),'.mat']);
%% 
@@ -711,8 +725,7 @@ function res = delta_ni(mu_s,s,g)
end

function res = delta_ni_new(s,Tcoh)

    res = 0.5*(factorial(s-1))/(Tcoh^s);
    res = 0.5.*(factorial(s-1))./(Tcoh.^s);
end

function res = deltasc(asenc,porb,fspin,toff,tseg,M,eqtol)