Skip to content

Commit

Permalink
Merge pull request #145 from slaclab/beamtime_nov_8th_merge_dev
Browse files Browse the repository at this point in the history
 Merge beamtime november 8 2024 branch into development
  • Loading branch information
nstelter-slac authored Nov 16, 2024
2 parents 3621f7c + a932698 commit 376d27a
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 10 deletions.
2 changes: 1 addition & 1 deletion calibrationSuite/detectorInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def setup_epixUHR(self):
self.preferredCommonMode = "clusterCommonMode" ## not yet defined
self.clusterShape = [3, 3]
self.gainMode = None ## high, medium, low, lower
self.aduPerKeV = 40 ## high gain; medium is down by 2.8
self.aduPerKeV = 3 ## high gain; medium is down by 2.8
self.seedCut = 2
self.neighborCut = 0.25 ## ditto

Expand Down
17 changes: 9 additions & 8 deletions config_files/epixUHRSuiteConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
##for i in [0, 2, 3]:##range(0, 3):
## for 41-c00-01
m = 0
for r in range(11, 60):
for c in range(49):
if r%12 == 0 and c%6 == 0:
for r in range(109, 157):
for c in range(48):
if r%12 == 11 and c%6 == 0:
singlePixelArray.append([m, r, c])
singlePixelArray.append([m, 12*7, 60])
singlePixelArray.append([m, 13*7, 60+12])
singlePixelArray.append([m, 14*7, 60+24])

m = 3
for r in range(8, 57):
for c in range(10, 59):
if r%12 == 0 and c%6 == 0:
for r in range(111, 159):
for c in range(10, 58):
if r%12 == 11 and c%6 == 0:
singlePixelArray.append([m, r, c])
singlePixelArray.append([m, 12*7, 60])
singlePixelArray.append([m, 13*7, 60+12])
Expand All @@ -38,12 +38,13 @@
##"detectorVersion": 1, ## new firmware
"exp": "rixx1005922",
"location": "RixEndstation",
"analyzedModules": [0, 1, 2, 3],
"analyzedModules": [0, 3],
"seedCut": 40, ## pure guess
"neighborCut": 10, ##pure guess
"fluxSource": "MfxDg1BmMon",
# "fluxSource": "MfxDg2BmMon",
"fluxChannels": [15], ## or 11 if we see saturation
"fluxChannels": [11], ## 8 Nov
##"fluxChannels": range(0,16), ## direct beam, 11 Nov?
# "fluxSign": 1, ## for dg2
"fluxSign": -1,
"singlePixels": singlePixelArray,
Expand Down
Binary file modified data/epixUHR_asic0_offSensor_fullRoi.npy
Binary file not shown.
Binary file modified data/epixUHR_asic0_sensor_fullRoi.npy
Binary file not shown.
Binary file modified data/epixUHR_asic0_sensor_pietroPixelRoi.npy
Binary file not shown.
Binary file modified data/epixUHR_asic3_offSensor_fullRoi.npy
Binary file not shown.
Binary file modified data/epixUHR_asic3_sensor_fullRoi.npy
Binary file not shown.
Binary file modified data/epixUHR_asic3_sensor_pietroPixelRoi.npy
Binary file not shown.
18 changes: 18 additions & 0 deletions setup_epixUHR.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Setup environment variables


# current_dir=$(pwd)
git_project_root_dir=$(git rev-parse --show-toplevel)
# so scripts can find the calibrationSuite library code
export PYTHONPATH="$PYTHONPATH:$git_project_root_dir"
echo "PYTHONPATH = $PYTHONPATH"

# so output folders are written in a shared location
export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/results/"
echo "OUTPUT_ROOT = $OUTPUT_ROOT"

# point to which config file to use
export SUITE_CONFIG="$git_project_root_dir/config_files/epixUHRSuiteConfig.py"
##export SUITE_CONFIG="$git_project_root_dir/config_files/epix100SuiteConfig.py"
echo "SUITE_CONFIG = $SUITE_CONFIG"
94 changes: 94 additions & 0 deletions standalone_scripts/cmCorrectAlexData.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import numpy as np
import sys
import matplotlib.pyplot as plt

nCols = 384
nRows = 192
nBanksRow = 4
nRowsPerBank = int(nRows/nBanksRow)


def colCommonModeCorrection(frame, arbitraryCut=1000):
for c in range(nCols):
rowOffset = 0
for b in range(0, nBanksRow):
if True:
colCM = np.median(
frame[rowOffset : rowOffset + nRowsPerBank, c][
frame[rowOffset : rowOffset + nRowsPerBank, c] < arbitraryCut
]
)
if not np.isnan(colCM): ## if no pixels < cut we get nan
frame[rowOffset : rowOffset + nRowsPerBank, c] -= colCM.astype('int')
##except Exception:
if False:
print("colCM problem")
print(frame[rowOffset : rowOffset + nRowsPerBank], c)
rowOffset += nRowsPerBank
return frame



f = sys.argv[1]
label = f.split('/')[-1]
label = label.split('.')[0]
rawData = np.load(f)
data = np.zeros(rawData.shape)

try:
signalPixel = eval(sys.argv[2])
darkPixel = eval(sys.argv[3])
except:
print("defaulting to standard pixels")
signalPixel = (66, 66)
darkPixel = (6, 6)

nSkipForChargeInjectionOffset = 200
nInjections = 1024
gainCut = 1<<15
gainBitsMask = gainCut -1

dataHighSignalPixel = data[signalPixel[0],signalPixel[1],:]<gainCut
dataHighDarkPixel = data[darkPixel[0],darkPixel[1],:]<gainCut
x = np.arange(nSkipForChargeInjectionOffset, nInjections)

rawData &= gainBitsMask

pedestal = rawData[:,:,nSkipForChargeInjectionOffset]
for i in range(rawData.shape[2]):
data[:,:, i] = rawData[:,:, i] - pedestal
print(data[:,:, 666].mean())

data = data[:,:,nSkipForChargeInjectionOffset:]
dataHighSignalPixel = dataHighSignalPixel[nSkipForChargeInjectionOffset:]
dataHighDarkPixel = dataHighDarkPixel[nSkipForChargeInjectionOffset:]

doCM = [True,False][1]

plt.scatter(x[dataHighSignalPixel], data[signalPixel[0],signalPixel[1],:][dataHighSignalPixel],color='slateblue')
plt.scatter(x[~ dataHighSignalPixel], data[signalPixel[0],signalPixel[1],:][~ dataHighSignalPixel], color='darkblue')

## real photons are quantized, allowing cut to make sense even for signal pixels
if doCM:
label += " column common mode correction"
for i in range(data.shape[2]):
data[:,:,i] = colCommonModeCorrection(data[:,:,i], 32000)
else:
label += " no common mode correction"

plt.scatter(x[dataHighDarkPixel], data[darkPixel[0],darkPixel[1],:][dataHighDarkPixel], color='orange')
plt.scatter(x[~ dataHighDarkPixel], data[darkPixel[0],darkPixel[1],:][~ dataHighDarkPixel], color='goldenrod')
plt.title("Alex data, %s" %(label))
plt.xlabel("injection")
title = "test pixels %d,%d, %d,%d in file %s" %(signalPixel[0], signalPixel[1], darkPixel[0], darkPixel[1], label)
plt.savefig(title.replace(' ', '_'))
plt.clf()


##plt.hist(data.flatten().clip(0,40000), 100)
plt.hist(data[data<gainCut].flatten(), 100)
plt.hist((data[data>=gainCut].flatten()), 100, alpha=0.5)
plt.title("Alex data, %s" %(label))
plt.xlabel("ADU")
title = "all pixels in file %s" %(label)
##plt.savefig(title.replace(' ', '_'))
24 changes: 24 additions & 0 deletions standalone_scripts/makePietroPixels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import numpy as np
roi = np.zeros([4, 168, 192])
roi[0, 109:157, 0:48] = 1
np.save("../data/epixUHR_asic0_sensor_fullRoi.npy", roi)
roi = np.zeros([4, 168, 192])
roi[3, 112:160, 10:58] = 1
np.save("../data/epixUHR_asic3_sensor_fullRoi.npy", roi)
roi = np.zeros([4, 168, 192])
for r in range(109, 157):
for c in range(48):
if r%12 == 11 and c%6 == 0:
roi[0, r, c] = 1
np.save("../data/epixUHR_asic0_sensor_pietroPixelRoi.npy", roi)
for r in range(111, 160):
for c in range(10, 58):
if r%12 == 11 and c%6 == 0:
roi[3, r, c] = 1
np.save("../data/epixUHR_asic3_sensor_pietroPixelRoi.npy", roi)
roi = np.zeros([4, 168, 192])
roi[3, 58:107, 70:119] = 1
np.save("../data/epixUHR_asic3_offSensor_fullRoi.npy", roi)
roi = np.zeros([4, 168, 192])
roi[0, 11:59, 60:109] = 1
np.save("../data/epixUHR_asic0_offSensor_fullRoi.npy", roi)
5 changes: 4 additions & 1 deletion suite_scripts/LinearityPlotsParallelSlice.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ def analyze_h5_slice(self, dataFile, label):
print("using flux label:", lpp.fluxLabel)
lpp.fitInfo = None
lpp.analyze_h5(lpp.file, lpp.label + "_raw")
lpp.analyze_h5_slice(lpp.file, lpp.label + "_raw")
## modify for speed...
slow = True
if slow:
lpp.analyze_h5_slice(lpp.file, lpp.label + "_raw")
print("done with standalone analysis of %s, exiting" % (lpp.file))
logger.info("done with standalone analysis of %s, exiting" % (lpp.file))
sys.exit(0)
Expand Down

0 comments on commit 376d27a

Please sign in to comment.