diff --git a/notebooks/DSSC/Characterize_DSSC_Darks_NBC.ipynb b/notebooks/DSSC/Characterize_DSSC_Darks_NBC.ipynb index e7fb07b7434bae7dae6680aff38250382768d8ab..b4e01c190dd99c40c08943d02181e7e5c47d36d6 100644 --- a/notebooks/DSSC/Characterize_DSSC_Darks_NBC.ipynb +++ b/notebooks/DSSC/Characterize_DSSC_Darks_NBC.ipynb @@ -210,18 +210,7 @@ " import h5py\n", " import numpy as np\n", " from cal_tools.enums import BadPixels\n", - " \n", - " def get_num_cells(fname, h5path):\n", - " with h5py.File(fname, \"r\") as f:\n", - "\n", - " cells = f[f\"{h5path}/cellId\"][()]\n", - " if cells == []:\n", - " return\n", - " maxcell = np.max(cells)\n", - " options = [100, 200, 400, 500, 600, 700, 800, 900]\n", - " dists = np.array([(o-maxcell) for o in options])\n", - " dists[dists<0] = 10000 # assure to always go higher\n", - " return options[np.argmin(dists)]\n", + " from cal_tools.dssclib import get_num_cells\n", " \n", " filename, channel = inp\n", " \n", @@ -491,11 +480,15 @@ " acquisition_rate=opfreq, \n", " target_gain=targetgain,\n", " encoded_gain=encodedgain)\n", - " \n", + " for parm in condition.parameters:\n", + " if parm.name == \"Memory cells\":\n", + " parm.lower_deviation = max_cells\n", + " parm.upper_deviation = 0\n", + "\n", " if db_output:\n", " md = send_to_db(db_module, karabo_id, dconst, condition, file_loc, report,\n", " cal_db_interface, creation_time=creation_time, timeout=cal_db_timeout)\n", - " \n", + "\n", " if local_output and dont_use_pulseIds: # Don't save constant localy two times.\n", " md = save_const_to_h5(db_module, karabo_id, dconst, condition,\n", " dconst.data, file_loc, report,\n", diff --git a/notebooks/DSSC/DSSC_Correct_and_Verify.ipynb b/notebooks/DSSC/DSSC_Correct_and_Verify.ipynb index 55978ac1ec6dcbd6dadf38671db8e338904ed0e6..88277c1449194bf6fdfd58d24d43e604879f92ea 100644 --- a/notebooks/DSSC/DSSC_Correct_and_Verify.ipynb +++ b/notebooks/DSSC/DSSC_Correct_and_Verify.ipynb @@ -238,7 +238,11 @@ "\n", " import h5py\n", " import numpy as np\n", - " from cal_tools.dssclib import get_dssc_ctrl_data, get_pulseid_checksum\n", + " from cal_tools.dssclib import (\n", + " get_dssc_ctrl_data,\n", + " get_num_cells,\n", + " get_pulseid_checksum,\n", + " )\n", " from cal_tools.enums import BadPixels\n", " from cal_tools.tools import get_constant_from_db_and_time\n", " from iCalibrationDB import (\n", @@ -267,15 +271,6 @@ " pulse_edges = None\n", " err = None\n", " offset_not_found = False\n", - " def get_num_cells(fname, h5path):\n", - " with h5py.File(fname, \"r\") as f:\n", - "\n", - " cells = f[f\"{h5path}/cellId\"][()]\n", - " maxcell = np.max(cells)\n", - " options = [100, 200, 400, 500, 600, 700, 800]\n", - " dists = np.array([(o-maxcell) for o in options])\n", - " dists[dists<0] = 10000 # assure to always go higher\n", - " return options[np.argmin(dists)]\n", " \n", " if mem_cells == 0:\n", " mem_cells = get_num_cells(filename, h5path)\n", diff --git a/src/cal_tools/dssclib.py b/src/cal_tools/dssclib.py index 59ca874d2c896224418347577f2a991789fb00b4..a17ec3648524c7449e3e20cae44c4348965bbcc8 100644 --- a/src/cal_tools/dssclib.py +++ b/src/cal_tools/dssclib.py @@ -9,6 +9,16 @@ import h5py import numpy as np +def get_num_cells(fname, h5path): + + with h5py.File(fname, "r") as f: + cells = f[f"{h5path}/cellId"][()] + if cells == []: + return + maxcell = np.max(cells) + return maxcell+1 + + def get_pulseid_checksum(fname, h5path, h5path_idx): """generates hash value from pulse pattern (veto defined).""" with h5py.File(fname, "r") as infile: diff --git a/tests/test_reference_runs/callab_tests.py b/tests/test_reference_runs/callab_tests.py index 0e04d7e80fa0ab3e6d065f20004d3b615950df76..3923bf478593afcc7592cb43a75a4952b96c0a38 100644 --- a/tests/test_reference_runs/callab_tests.py +++ b/tests/test_reference_runs/callab_tests.py @@ -584,11 +584,7 @@ automated_test_config = { "run": "9028", # Original run: "1723", "karabo-id": "SCS_DET_DSSC1M-1", "slow-data-path": "SCS_CDIDET_DSSC/FPGA/PPT_Q", - "slow-data-aggregators": - - 1 - - 2 - - 3 - - 4 + "slow-data-aggregators": [1, 2, 3, 4] }, "reference-folder": "{}/{}/{}", }, @@ -602,6 +598,7 @@ automated_test_config = { "run": "9028", # Original run: "1723", "karabo-id": "SCS_DET_DSSC1M-1", "slow-data-path": "SCS_CDIDET_DSSC/FPGA/PPT_Q", + "slow-data-aggregators": [1, 2, 3, 4] }, "reference-folder": "{}/{}/{}", },