-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUltravision.py
More file actions
57 lines (29 loc) · 984 Bytes
/
Ultravision.py
File metadata and controls
57 lines (29 loc) · 984 Bytes
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
import numpy as np
def ReadScan(flname, datatype=np.float):
"""
Reads text file output from the Ultravision software, path specified
by flname. Format of flname is header for beam 1 (18 lines), N A-scans for beam 1,
header for beam 2 (18 lines), N A-Scans for beam 2, ... Returns
numpy array of shape (Number of Beams , Number of AScan Points, Number of Scans)
"""
# fl = open(flname,'rb')
fl = open(flname,'r')
D = fl.readlines()
fl.close()
H = 19
L = len(D)
# N = int(D[5])
N = int(D[5].split('\t')[-1].split('\n')[0])
B = int(L/(H+N))
Data = []
for b in range(B):
istart = int(H+b*(H+N))
iend = int(istart+N)
DD = D[istart:iend]
Data.append([list(np.fromstring(DDD, sep=' ', dtype=datatype)) for DDD in DD])
Data = np.swapaxes(np.array(Data),1,2)
# if Data.shape[0]==0:
#
# Data = Data[0,:,:]
#
return Data