-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDarkCurrentPerAsic.py
executable file
·72 lines (58 loc) · 2.07 KB
/
DarkCurrentPerAsic.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
63
64
65
66
67
68
69
70
71
#DarkCurrentPerAsic.py created by BWM 11/17/22
#program to create Dark currents on a per ASIC basis
import numpy as np
import Big_keck_load as BKL
import os
import matplotlib.pyplot as plt
import sys
import tkinter.filedialog as fd
def file_select(Type):
filename = fd.askopenfilename(
title = "Open " + str(Type),
initialdir = "/mnt/raid/keckpad",
)
return filename
backFile = file_select("Background File")
foreFile = file_select("Foreground File")
#foreFile = "/Volumes/BMARTIN/set-Geod/run-f3ms/frames/f3ms_00000001.raw"
#backFile = "/Volumes/BMARTIN/set-Geod/run-b3ms/frames/b3ms_00000001.raw"
cwd = os.getcwd()
foreImage = open(foreFile,"rb")
backImage = open(backFile,"rb")
numImagesF = int(os.path.getsize(foreFile)/(1024+512*512*2))
numImagesB = int(os.path.getsize(backFile)/(1024+512*512*2))
foreStack = np.zeros((8,512,512),dtype=np.double)
backStack = np.zeros((8,512,512),dtype=np.double)
integTime= 1e-3 #time in s
##################################
#Adjust for clipping
##################################
clipHigh = 1e8
clipLow = 0
#read all the image files
for fIdex in range(numImagesB):
payloadB = BKL.keckFrame(backImage)
backStack[(payloadB[3]-1)%8,:,:] += np.resize(payloadB[4],[512,512])
avgBack = backStack/(numImagesB/8.0)
for fIdex in range(numImagesF):
payload = BKL.keckFrame(foreImage)
foreStack[(payload[3]-1)%8,:,:] += np.resize(payload[4],[512,512])
avgFore = foreStack/(numImagesB/8.0)
FmB = avgFore-avgBack
asicDCs = np.zeros((8,16),dtype=np.int16)
#how many pixels in from edge
margin = 3
for cap in range(8):
PerCapImage = FmB[cap,:,:]
AsicCount = 0
for pS in range (4):
startPixX = pS * 128
endPixX = startPixX + 127
for pSY in range (4):
startPixY = pSY * 128
endPixY = startPixY + 127
perAsicAvg = np.average(PerCapImage[startPixX+margin:endPixX-margin,startPixY+margin:endPixY-margin])
#print (perAsicAvg)
asicDCs[cap,AsicCount] += perAsicAvg/integTime
AsicCount +=1
dataWrite = np.savetxt(fname='asicDCs.txt',X=asicDCs, delimiter=',' )