Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ling Sun
Viterbi_Sideband
Commits
1081f013
Commit
1081f013
authored
Jul 29, 2016
by
Ling Sun
Browse files
modify descriptions and comments
parent
21c5f04b
Changes
6
Hide whitespace changes
Inline
Sidebyside
argmax.m
0 → 100644
View file @
1081f013
function
j
=
argmax
(
L
)
% ARGMAX Index j of the maximum value in L.
[
~
,
j
]
=
max
(
L
);
\ No newline at end of file
binaryfilter.m
View file @
1081f013
function
[
b
,
h
]
=
binaryfilter
(
f
,
f0
,
P
,
a0
)
% BINARYFILTER Generate the Besselweighted matched filter (also generate Comb filter)
% BINARYFILTER Generate Besselweighted matched filter
% (also generate Comb filter)
%
% Note
% 
% Fstat power is concentrated at [c c]/P where c = 2*pi*a0*f0.
% Use fixed f0 (mean value of the subband) to setup matched filter.
%
% I/O Spec
% ========
% Input:
% f  Frequency bin list (i.e. hidden stats)
% f0  Mean frequency for each subband
% P  Orbit period
% a0  Projected orbital semimajor axis (i.e. asini)
%
% Inputs:
% f  Frequency bin list (i.e. hidden stats)
% f0  Mean frequency for each subband
% P  Orbit period
% a0  Projected orbital semimajor axis (i.e. asini)
%
% Outputs:
% b  Besselweighted matched filter
% h  Comb filter (not used in the current search)
% Output:
% b  Besselweighted matched filter
% h  Comb matched filter (not used in the current search)
% Fstat power concentrated at [c c]/P where c = 2*pi*a0*f0
% f0 is fixed to setup matched filter for each 1Hz subband
c
=
2
*
pi
*
a0
*
f0
;
%
M
ake
it slightly wider than c
%
T
ake
a wider range [N N] for calculation
N
=
ceil
(
c
)
+
100
;
n
=

N
:
N
;
b0
=
besselj
(
n
,
c
);
M
=
length
(
f
);
% Identify the indices to place the matched filter in the 1Hz band
% k indicates the interpolated indices at query points n/P using nearest interpolation, 1 is the extrapval for out of range values
% Identify the indices to place the matched filter in the subband.
% k indicates the interpolated indices at query points n/P,
% using nearest interpolation. Set extrapval to 1 for out of range values.
k
=
interp1
(
f

mean
(
f
),
1
:
M
,
n
/
P
,
'nearest'
,
1
);
% Initialise the
1Hz band
matched filter
% Initialise the matched filter
for the whole subband
b
=
zeros
(
M
,
1
);
% Place the filter
b
(
k
)
=
abs
(
b0
)
.^
2
;
%
h is
comb matched filter,
not used in the
search
%
Set
comb matched filter,
which can be used for a Cstat
search
h
=
zeros
(
M
,
1
);
h
(
k
)
=
1
;
functions/argmax.m
deleted
100644 → 0
View file @
21c5f04b
function j = argmax(L);
[~,j] = max(L);
\ No newline at end of file
readfstats.m
View file @
1081f013
function
[
f
,
X
,
N
,
T
]
=
readfstats
(
dirName
,
startFreq
,
steps
)
% READFSTATS Read Fstat files
% READFSTATS Read Fstat files for all steps
%
% Note
% 
% Fstat file name should follow the format:
% Fstat<start freq><step index>.dat
% <step index> start from 0.
%
% Inputs:
% dirName  Directory of Fstat files
% startFreq  Start frequency of the Fstat
% steps  Total number of steps
% Fstat file name should follow the format: Fstat<start freq><step index>.dat
% I/O Spec
% ========
% Input:
% dirName  Directory of Fstat files
% startFreq  Start frequency marking the Fstat file name
% steps  Total number of steps
%
% Output
s
:
%
f
 Frequency bins
%
X
 Fstat values
%
N  N
umber of bins
%
T
 Total number of steps
% Output:
%
f
 Frequency bins
%
X
 Fstat values
%
N  Total n
umber of bins
%
T
 Total number of steps
X
=
[];
...
...
@@ 23,7 +30,7 @@ for n = 1:steps
X
(:,
n
)
=
fstatData
(:,
7
);
f
=
fstatData
(:,
1
);
catch
disp
(
n
)
disp
(
sprintf
(
'Failed to read step %g'
,
n
)
)
end
end
...
...
search_O1.m
View file @
1081f013
...
...
@@ 3,14 +3,15 @@ function search_O1(freq,idx)
% The search is separated into parallel 1Hz subjobs.
% The start frequency for each subjob is the overal start frequency plus job index.
%
% Inputs:
% freq  Start frequency for all the parallel jobs
% idx  Job index
% Start frequency for each subjob: freq + idx
% I/O Spec
% ========
% Input:
% freq  Start frequency for all the parallel jobs
% idx  Condor job index
% Note: Start frequency for each subjob: freq + idx
%
% Outputs:
% Save output files to the output directory.
% Output:
% Save output files to the output directory.
format
long
g
...
...
@@ 28,7 +29,7 @@ steps = 13
% Read Fstats
tic
[
f
,
X
]
=
readfstats
(
dirName
,
startFreq
,
steps
);
[
f
,
X
]
=
readfstats
(
dirName
,
startFreq
,
steps
);
toc
fmean
=
f
(
1
)
+
0.5
;
% Take the mean value of each 1Hz subband
...
...
@@ 46,7 +47,7 @@ for m=1:length(g)
for
n
=
1
:
steps
Y
(:,
n
)
=
fftshift
(
ifft
(
fft
(
X
(:,
n
))
.*
fft
(
b
)));
end
% Viterbi tracking
[
path0
(
m
,:),
delta
,
psi
,
sc
(
m
)]
=
viterbi_colFLT
(
3
,
Y
);
toc
end
...
...
viterbi_colFLT.m
View file @
1081f013
function
[
path
,
delta
,
psi
,
score
]
=
viterbi_colFLT
(
M
,
obslik
)
% VITERBI_COLFLT Find the mostprobable (Viterbi) path through the HMM states (frequency bins).
% VITERBI_COLFLT Find the mostprobable (Viterbi) path
% through the HMM states (frequency bins).
%
% Inputs:
% M  One dimension of the colfilt matrix, in the current model M=3,
% but keep it as an input for generic purpose
% obslik  Observation likelihood, i.e. Fstat
% I/O Spec
% ========
% Input:
% M  One dimension of the colfilt matrix, in the current model M=3.
% Keep it as an input for generic purpose.
% obslik  Observation likelihood, i.e. Fstat
%
% Output
s
:
% path(
n,
t)  The
nth best
path, where path(
n,
1), path(
n,
2) ... path(
n,
T) stands
for
% the frequency bin index for each step
in the nth best path
.
% delta(j,t)  Max probability of the sequence
of length t1 and then going to state j
%
psi(j,t)  The best predecessor state, given that we ended up in
state j
at t
%
score

Number of standard deviations abo
ve th
e mean value of log likelihood
%
of paths to all the states at the final step
% Output:
%
path(t)
 The
optimal
path, where path(1), path(2)
,
...
,
path(T) stands
%
for
the frequency bin index for each step.
%
delta(j,t)  Max probability of the sequence
till step t1
%
and then go to
state j
%
psi(j,t)

The best predecessor state, gi
ve
n
th
at it ends up in state j at t
%
score
 Number of standard deviations above the mean value of log
%
likelihood of paths to all the states at the final step
if
round
(
M
/
2
)
==
M
/
2
M
=
M
+
1
;
...
...
@@ 31,21 +34,22 @@ path = zeros(1,T);
% compares all three possible paths for each step and the operation
% is efficient.
cor
=
(
0
:
Q

1
)
'
(
M

1
)/
2
;
% correction term for each bin
% Set correction term for each bin
cor
=
(
0
:
Q

1
)
'
(
M

1
)/
2
;
% Initialisation
t
=
1
;
delta
(:,
t
)
=
obslik
(:,
t
);
% Recursion and Termination
disp
(
'forward'
)
for
t
=
2
:
T
delta
(:,
t
)
=
colfilt
(
delta
(:,
t

1
),[
M
1
],
'sliding'
,
@
max
)
+
obslik
(:,
t
);
psi
(:,
t
)
=
colfilt
(
delta
(:,
t

1
),[
M
1
],
'sliding'
,
@
argmax
)
+
cor
;
end
%
Sort the paths
%
Optimal path backtracking
disp
(
'backward'
)
% Only identify the optimal path
[
sc
,
path
(
T
)]
=
max
(
delta
(:,
T
));
score
=
(
sc

mean
(
delta
(:,
T
)))/
std
(
delta
(:,
T
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment