-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary_tests.py
More file actions
80 lines (50 loc) · 1.66 KB
/
binary_tests.py
File metadata and controls
80 lines (50 loc) · 1.66 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
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 15 12:28:20 2021
@author: cardoso
"""
import files.misc.fakeCam as fakeCam
import struct
from functools import partial
import numpy as np
import json
import os
savepath=os.path.abspath('C:/Users/cardoso/Documents/')
testpath=os.path.abspath('C:/Users/cardoso/Documents/andor_cam_tests/')
fc=fakeCam.surrogateCam()
fc.SetRandomTracks(5)
fc.GetMostRecentImage()
data=fc._rawimg
npdata=np.reshape(np.array(fc._rawimg, dtype=np.int32),(fc._currentH,fc._currentW))
file1=open(savepath+"/f1.bin",'wb')
sf=str(len(data))+"i"
# file1.write(struct.pack(sf,*data))
dataA=np.asarray(data,dtype=np.int32)
np.asarray(fc._rawimg,dtype=np.int32).tofile(file1)
fc.GetMostRecentImage()
dataB=np.asarray(fc._rawimg,dtype=np.int32)
np.asarray(fc._rawimg,dtype=np.int32).tofile(file1)
file1.close()
# readData=np.emtpy(dtype)
# i=0
with open(testpath+"/1.uvub",'rb') as readFile:
# n = os.fstat(readFile.fileno()).st_size // 8
# print(readFile.fileno(),os.fstat(readFile.fileno()).st_size,os.fstat(readFile.fileno()).st_size // 8)
readData=np.fromfile(readFile,dtype=np.int32)
# readData=np.array('d')
# readData=np.fromfile(readFile,dtype=np.int32)
# readFile.close()
# readData=struct.unpack(sf,struct.calcsize(sf))
# readData=struct.unpack(sf,struct.calcsize(sf))
#json tests
file2=open(testpath+"/bs.dat",'w')
file2.write("#bulshit, bulshit\n#more bulshit\n")
dict2dump={"aya":2, "lolio":3,"uhyeah":5}
json.dump(dict2dump,file2)
file2.close()
with open(testpath+"/bs.dat",'r') as fh:
while True:
line=fh.readline()
if not line.startswith("#"):
break
myDic=json.loads(line)