licel.py

changeset 4
7f9450f40b1e
parent 2
b11082bfcb4a
child 16
1122ee9ef151
equal deleted inserted replaced
3:42dbb0451ebd 4:7f9450f40b1e
28 28
29 raw_info = {} 29 raw_info = {}
30 channels = {} 30 channels = {}
31 channel_info = [] 31 channel_info = []
32 32
33 f = open(filename, 'r') 33 f = open(filename, 'rb')
34 34
35 #Read the first 3 lines of the header 35 #Read the first 3 lines of the header
36 raw_info = {} 36 raw_info = {}
37 for c1 in range(3): 37 for c1 in range(3):
38 raw_info.update(match_lines(f.readline(), licel_file_header_format[c1])) 38 raw_info.update(match_lines(f.readline(), licel_file_header_format[c1]))
55 # Import the data 55 # Import the data
56 for current_channel_info in channel_info: 56 for current_channel_info in channel_info:
57 raw_data = np.fromfile(f, 'l', int(current_channel_info['DataPoints'])) 57 raw_data = np.fromfile(f, 'l', int(current_channel_info['DataPoints']))
58 a = np.fromfile(f, 'b', 1) 58 a = np.fromfile(f, 'b', 1)
59 b = np.fromfile(f, 'b', 1) 59 b = np.fromfile(f, 'b', 1)
60
60 if (a[0] != 13) | (b[0] != 10): 61 if (a[0] != 13) | (b[0] != 10):
61 print "Warning: No end of line found after record. File could be corrupt" 62 print "Warning: No end of line found after record. File could be corrupt"
62 channel = LicelFileChannel(current_channel_info, raw_data) 63 channel = LicelFileChannel(current_channel_info, raw_data)
63 64
64 channel_name = channel.channel_name 65 channel_name = channel.channel_name

mercurial