-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtdoa_ml.py
62 lines (42 loc) · 1.38 KB
/
tdoa_ml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'''
TIME DIFFERENCE OF ARRIVAL (TDOA) LOCALISATION
USING MAXIMUM LIKELIHOOD ESTIMATION
AUTHOR: ABIJITH J KAMATH
abijithj@iisc.ac.in
'''
# %% IMPORT PACKAGES
import os
import numpy as np
from skimage.io import imread
from scipy.io import loadmat
from matplotlib import pyplot as plt
from matplotlib import style
from matplotlib import rcParams
import utils
# %% PLOT SETTINGS
plt.style.use(['science','ieee'])
plt.rcParams.update({
"font.family": "serif",
"font.serif": ["cm"],
"mathtext.fontset": "cm",
"font.size": 11})
# %% LOAD DATA
img = imread('data/mapimage.jpeg')
data = loadmat('./data/TDOA_data.mat')
anchor_location = data['anchor_location'].astype(np.float)
target_location = data['target_location'].astype(np.float)
true_distances = data['true_distances']
noisy_distances = data['noisy_distances']
var_vec = data['sigma2']
# %% ESTIMATE USING MLE
init_pos = np.array([0.0,0.0])[:,np.newaxis]
mle_pos = utils.mle_tdoa(noisy_distances[:,0,0], anchor_location, init_pos,
var=0.001, step_size=.0005, max_iter=100)
# %% PLOT LOCATIONS
os.makedirs('./results', exist_ok=True)
path = './results/'
utils.plot_sensors(target=mle_pos, anchors=anchor_location, image=img,
xaxis_label=r'$x$', yaxis_label=r'$y$', title_text=r'TDOA Localisation using MLE',
marker='+', markersize=11, target_colour='red', legend_label=r'MLE',
show=True, save=path+'mle')
# %%