Repository navigation
Expand file tree
/
Copy pathmanip.py
More file actions
88 lines (67 loc) · 1.92 KB
/
Copy pathmanip.py
File metadata and controls
88 lines (67 loc) · 1.92 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env pypy
import os
import time
import tqdm
import multiprocessing as mp
from bitstring import ConstBitStream
from PIL import Image
# 70
# 80
#horizontal= 70
#horizontal= 270
#horizontal= 207
#STAMP = "3162099"
#STAMP = "749113"
STAMP = "1297209"
def handleDump(fileObj):
tech = []
raw = ConstBitStream(fileObj)
try:
while True:
tech.append(raw.read('floatle:32'))
except:
pass
del(raw)
return tech
def processing(params):
pStamp = params[0]
pI = params[1]
pJ = params[2]
VER = params[3]
HOR = params[4]
PXLS = params[5]
filen = open( 'SAMPLE_{0}_{1}_{2}.dmp'.format(pStamp, str(pI), str(pJ) ), 'rb')
## put data in RAM
tech = handleDump(filen)
filen.close()
del(filen)
## DATA MANIP START
average = sum(tech)/float(len(tech))
colour = int( (average/100)*255 )
hold = [ pStamp, pI, pJ, VER, HOR, colour ]
del(tech)
return hold
#print("{0} : [{1},{2}]".format(average,pI,pJ)) # DEBUG
if __name__ == '__main__':
VERTICAL = 80
HORIZONTAL = 270
IMG = Image.new('RGB', (HORIZONTAL, VERTICAL), 'black')
PIXELS = IMG.load()
# create file processing queue
DUMPS = []
for i in xrange(HORIZONTAL):
for j in xrange(VERTICAL):
DUMPS.append([ STAMP, i, j, VERTICAL, HORIZONTAL, 0])
# create threadpool and process the data
pewl = mp.Pool(3)
print("processing...")
for PXL in tqdm.tqdm(pewl.imap_unordered(processing, DUMPS), total=len(DUMPS)):
# correcting for even vertical pixel data being generated
# from and upward sweep of the antenna, and vice versa for the odd case
if PXL[1]/2 == PXL[1]/2.0:
reverse = 0
else:
reverse = VERTICAL - 1
PIXELS[ HORIZONTAL-1-PXL[1], abs(PXL[2] - reverse) ] = (PXL[5], PXL[5], PXL[5])
print("done.")
IMG.show()