-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from slaclab/beamtime_nov_8th_merge_dev
Merge beamtime november 8 2024 branch into development
- Loading branch information
Showing
12 changed files
with
150 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(' ', '_')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters