-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSD_perASIC.py
executable file
·71 lines (58 loc) · 2.16 KB
/
SD_perASIC.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
#SD_perASIC.py created by BWM 11/17/22
#program to create average standard deviation on 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((numImagesF,8,512,512),dtype=np.double)
backStack = np.zeros((numImagesB,8,512,512),dtype=np.double)
##################################
#Adjust for clipping
##################################
clipHigh = 1e8
clipLow = 0
#read all the image files
for fIdex in range(numImagesB):
payloadB = BKL.keckFrame(backImage)
backStack[payloadB[5]-1,(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[5]-1,(payload[3]-1)%8,:,:] += np.resize(payload[4],[512,512])
standDev = np.zeros((8,512,512),dtype=np.double)
DiffStack = foreStack-backStack
asicSDs = np.zeros((8,16),dtype=np.int16)
#how many pixels in from edge
margin = 3
for cap in range(8):
PerCapImage = DiffStack[:,cap,:,:]
standDev[cap,:,:] += np.std(PerCapImage, axis=0)
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)
asicSDs[cap,AsicCount] += perAsicAvg
AsicCount +=1
dataWrite = np.savetxt(fname='asicSDs.txt',X=asicSDs, delimiter=',' )