Commit 5f9ce155 authored by Riccardo La Placa's avatar Riccardo La Placa
Browse files

First nearest neighbour search tests (THEY PRINT A LOT OF TEXT, but the...

First nearest neighbour search tests (THEY PRINT A LOT OF TEXT, but the results do not appear to be completely stupid at first glance)
Time of observation cut to 15 min to run the tests on this pc
Metric used is still euclidean during the search (but I have a feeling this should not be the end one)
parent ea84a252
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ tic
finame = 'EPN_0744840201_bary.fits';
t_raw = fitsread([pathfi,finame],"binarytable");
t_raw = t_raw{1};
t_raw = t_raw(t_raw>=t_raw(1) & t_raw<t_raw(1)+900);
% info = fitsinfo(finame).BinaryTable.Keywords;
% for i = 1:length(info)
%     if (isequal(info{i},'TIMEDEL'))
@@ -21,7 +22,6 @@ t_raw = t_raw{1};
%%%%%%%%%%%%%%%%
toc

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lines added just to test what was done until now
% Parameters for J1023_B_2017_Bary.fits
@@ -61,7 +61,7 @@ a_max = max(a_gr);
tasc_min = min(tasc_gr);
tasc_max = max(tasc_gr);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%NOTE: t0 used to define the orbital phase γ is equal to the mid point
@@ -197,11 +197,9 @@ for s = 1:s_s
    nis{s}=franco;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nis{s_s+1}=f_gr.';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
toc

tic
@@ -248,10 +246,8 @@ for m=1:M
        % Careful! ni_0 still needs to be defined (it's the spin freq. 
        % currently being considered)
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        nizero = nibank(i,s_s+1);
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % tau = zeros(N,1);
        % tic
        % for j = 1:N
@@ -302,14 +298,25 @@ for m=1:M

end


nisearcher = KDTreeSearcher(nibank,'BucketSize',100);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
parbank = combinations(f_gr,porb_gr,a_gr,tasc_gr).Variables;
for i=1:length(parbank)
    curpar = parbank(i,:);
    % Move from ν,P,a,T_asc to ν,Ω,a,γ 
    curpar(2) = 2*pi/curpar(2);
    curpar(4) = curpar(2)*(t0 - curpar(4));
    curni=zeros(1,s_s+1);
    for s=1:s_s
        curni(s) = (curpar(2)^s)*sin(curpar(4)-0.5*s*pi);
    end
    curni=curni.*curpar(1).*curpar(2);
    curni(s_s+1) = curpar(1);


    [Idx,D] = knnsearch(nisearcher,curni)
    nibank(Idx,:)
    curpar(1)
end

%% Finire domani