From 0216ec84030d77a76a939fcc2ed877190cf6e7ea Mon Sep 17 00:00:00 2001 From: nstelter-slac Date: Tue, 11 Jun 2024 18:58:29 -0700 Subject: [PATCH 1/3] BUG: fix issues from linearity-script update merge --- calibrationSuite/basicSuiteScript.py | 2 +- suite_scripts/LinearityPlotsParallelSlice.py | 24 ++++++++++++-------- tests/test_SuiteScripts.py | 3 ++- tests/test_data | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/calibrationSuite/basicSuiteScript.py b/calibrationSuite/basicSuiteScript.py index 98684ac..92ad74a 100755 --- a/calibrationSuite/basicSuiteScript.py +++ b/calibrationSuite/basicSuiteScript.py @@ -375,7 +375,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") diff --git a/suite_scripts/LinearityPlotsParallelSlice.py b/suite_scripts/LinearityPlotsParallelSlice.py index 93c9986..b7bcadd 100755 --- a/suite_scripts/LinearityPlotsParallelSlice.py +++ b/suite_scripts/LinearityPlotsParallelSlice.py @@ -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]) @@ -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] @@ -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, @@ -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) @@ -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 diff --git a/tests/test_SuiteScripts.py b/tests/test_SuiteScripts.py index 008cfbb..ab350a2 100644 --- a/tests/test_SuiteScripts.py +++ b/tests/test_SuiteScripts.py @@ -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", ), diff --git a/tests/test_data b/tests/test_data index 686eca6..a0f0d08 160000 --- a/tests/test_data +++ b/tests/test_data @@ -1 +1 @@ -Subproject commit 686eca6456055835831cdc9ff5b8724d80f0afb5 +Subproject commit a0f0d08766613ee934d137dcc934df286854df8b From 8d3f96382c28102c9398b292634a12e9f66df43c Mon Sep 17 00:00:00 2001 From: nstelter-slac Date: Tue, 11 Jun 2024 21:09:18 -0700 Subject: [PATCH 2/3] BUG: fix missing comment end-char --- calibrationSuite/basicSuiteScript.py | 1 + 1 file changed, 1 insertion(+) diff --git a/calibrationSuite/basicSuiteScript.py b/calibrationSuite/basicSuiteScript.py index 52f618f..737239f 100755 --- a/calibrationSuite/basicSuiteScript.py +++ b/calibrationSuite/basicSuiteScript.py @@ -397,3 +397,4 @@ def getNswitchedPixels(self, data, region=None): evt = bSS.getEvt() print(dir(evt)) logger.info(dir(evt)) +""" From e90953e62b5a003bda80ecc52a4962fb6f36eed0 Mon Sep 17 00:00:00 2001 From: nstelter-slac Date: Tue, 11 Jun 2024 21:35:27 -0700 Subject: [PATCH 3/3] DOC: link to simpler git-submodule info site --- docs/testing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/testing.md b/docs/testing.md index 26db1cf..a7f4f4f 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -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: -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) \ No newline at end of file +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)