Skip to content

Commit

Permalink
Merge branch 'development' of github.com:slaclab/beamtime-calibration…
Browse files Browse the repository at this point in the history
…-suite into development
  • Loading branch information
philiph-slac committed Jun 12, 2024
2 parents feea708 + e90953e commit 3053e90
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
3 changes: 2 additions & 1 deletion calibrationSuite/basicSuiteScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def addFakePhotons(self, frames, occupancy, E, width):
def getNswitchedPixels(self, data, region=None):
return (((data>=self.g0cut)*1).sum())


"""
if __name__ == "__main__":
bSS = BasicSuiteScript()
print("have built a BasicSuiteScript")
Expand All @@ -400,3 +400,4 @@ def getNswitchedPixels(self, data, region=None):
evt = bSS.getEvt()
print(dir(evt))
logger.info(dir(evt))
"""
4 changes: 2 additions & 2 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ These tests verify that the code in _/calibrationSuite_ and _/suite\_scripts_ is
_test\_SuiteScripts.py_ runs the files in _/suite\_script_ and diffs their real output against expected output in _/tests/test\_data_

_/tests/test\_data_ stores data from this repo: <https://github.com/slaclab/beamtime-calibration-suite-test-data>
The repo is added as a [git submodule](https://www.git-scm.com/book/en/v2/Git-Tools-Submodules), and should be setup by the _setup_developers.sh_ script.
The repo is added as a [git submodule](https://gist.github.com/gitaarik/8735255), and should be setup by the _setup_developers.sh_ script.
Since the test data is large, [LFS](https://docs.github.com/en/repositories/working-with-files/managing-large-files/installing-git-large-file-storage) is used and needs to be installed. (LFS is installed already on _S3DF_)


Some more info on testing, such as adding now data to the _test\_data_ submodule or add a new test-case to_suite\_scripts_ tests, can be found [in this file.](https://github.com/slaclab/beamtime-calibration-suite/blob/development/tests/test_SuiteScripts.py)
Some more info on testing, such as adding now data to the _test\_data_ submodule or add a new test-case to_suite\_scripts_ tests, can be found [in this file.](https://github.com/slaclab/beamtime-calibration-suite/blob/development/tests/test_SuiteScripts.py)
24 changes: 14 additions & 10 deletions suite_scripts/LinearityPlotsParallelSlice.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ def analyze_h5(self, dataFile, label):
g0Fluxes = []
g1s = []
g1Fluxes = []

count = 0
for s, _ in enumerate(self.singlePixels):
count += 1
g0s.append(pixels[:, s, 1][pixels[:, s, 0] == 0])
g0Fluxes.append(fluxes[pixels[:, s, 0] == 0])
g1s.append(pixels[:, s, 1][pixels[:, s, 0] == 1])
Expand Down Expand Up @@ -203,7 +206,15 @@ def analyze_h5_slice(self, dataFile, label):

for module in [1, 2]:
for i in range(rows):
# so we can end early on testing runs:
if self.special is not None and 'testing' in self.special and i >= self.maxNevents:
break

for j in range(cols):
# so we can end early on testing runs:
if self.special is not None and 'testing' in self.special and j >= self.maxNevents:
break

iDet, jDet = self.sliceToDetector(i, j)
if False:
self.fitInfo[module, i, j, 8] = self.g0Ped[module, iDet, jDet]
Expand Down Expand Up @@ -275,10 +286,6 @@ def analyze_h5_slice(self, dataFile, label):
plt.scatter(x, y - fitFunc, zorder=3, marker=".")
plt.figure(1)

<<<<<<< HEAD
if i % 2 == 0 and i == j:
figFileName = "%s/%s_slice_m%d_r%d_c%d_r%d_c%d_%s.png" % (self.outputDir, self.className, module, i, j, self.run, self.camera, label)
=======
if i % 2 == 0 and i == j:
figFileName = "%s/%s_slice_%d_%d_r%d_c%d_%s.png" % (
self.outputDir,
Expand All @@ -303,10 +310,10 @@ def analyze_h5_slice(self, dataFile, label):
self.camera,
label,
)
>>>>>>> 7227771506c6eb7fcf01086cf40746763a0c61c1
plt.savefig(figFileName)
logger.info("Wrote file: " + figFileName)
plt.close()

if self.residuals:
plt.figure(2)
figFileName = "%s/%s_slice_m%d_r%d_c%d_r%d_c%d_residuals_%s.png" % (self.outputDir, self.className, module, i, j, self.run, self.camera, label)
Expand Down Expand Up @@ -454,21 +461,18 @@ def analyze_h5_slice(self, dataFile, label):

smd.event(
evt,
<<<<<<< HEAD
eventDict
=======
eventDict,
fluxes=flux,
rois=np.array(roiMeans),
pixels=np.array(singlePixelData),
slice=rawFrames[lpp.regionSlice],
>>>>>>> 7227771506c6eb7fcf01086cf40746763a0c61c1
)

nGoodEvents += 1
if nGoodEvents % 100 == 0:
print("n good events analyzed: %d" % (nGoodEvents))
logger.info("n good events analyzed: %d" % (nGoodEvents))
## print("switched pixels: %d" %((switchedPixels>0).sum()))
## print("switched pixels: %d" %((switchedPixels>0).sum()))

if nGoodEvents > lpp.maxNevents:
break
Expand Down
3 changes: 2 additions & 1 deletion tests/test_SuiteScripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ def test_SinglePhoton(suite_tester, command, output_dir_name):
[
"bash",
"-c",
"python LinearityPlotsParallelSlice.py -r 102 --maxNevents 250 -p /test_linearity_scan -f test_linearity_scan/LinearityPlotsParallel__c0_r102_n666.h5 --label fooBar",
# this cmd runs pretty long, so we use '--special testing' and '-maxNevents 2' to stop pixel-analysis early
"python LinearityPlotsParallelSlice.py -r 102 --special testing --maxNevents 2 -p /test_linearity_scan -f test_linearity_scan/LinearityPlotsParallel__c0_r102_n666.h5 --label fooBar",
],
"test_linearity_scan",
),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data
Submodule test_data updated 223 files

0 comments on commit 3053e90

Please sign in to comment.