Skip to content
Snippets Groups Projects
Commit ff47109f authored by Karim Ahmed's avatar Karim Ahmed
Browse files

update test_cal_tools

parent 9b07fe24
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !774. Comments created here will be created in the context of that merge request.
...@@ -9,6 +9,7 @@ from extra_data import open_run ...@@ -9,6 +9,7 @@ from extra_data import open_run
from iCalibrationDB import Conditions, ConstantMetaData, Constants from iCalibrationDB import Conditions, ConstantMetaData, Constants
from cal_tools.agipdlib import AgipdCorrections, CellRange from cal_tools.agipdlib import AgipdCorrections, CellRange
from cal_tools.calcat_interface import CalCatError
from cal_tools.plotting import show_processed_modules from cal_tools.plotting import show_processed_modules
from cal_tools.tools import ( from cal_tools.tools import (
creation_date_file_metadata, creation_date_file_metadata,
...@@ -25,6 +26,7 @@ from cal_tools.tools import ( ...@@ -25,6 +26,7 @@ from cal_tools.tools import (
ACQ_RATE = 1.1 ACQ_RATE = 1.1
BIAS_VOLTAGE = 300 BIAS_VOLTAGE = 300
GAIN_SETTING = 0 GAIN_SETTING = 0
GAIN_MODE = 0
INTEGRATION_TIME = 12 INTEGRATION_TIME = 12
MEM_CELLS = 352 MEM_CELLS = 352
PHOTON_ENERGY = 9.2 PHOTON_ENERGY = 9.2
...@@ -405,7 +407,7 @@ def test_get_pdu_from_db(_agipd_const_cond): ...@@ -405,7 +407,7 @@ def test_get_pdu_from_db(_agipd_const_cond):
# TODO add a marker for accessing zmq end_point # TODO add a marker for accessing zmq end_point
@pytest.mark.requires_gpfs @pytest.mark.requires_gpfs
@pytest.mark.requires_caldb @pytest.mark.requires_caldb
def test_initialize_from_db(): def test_raise_initialize_from_db():
creation_time = datetime.strptime( creation_time = datetime.strptime(
"2020-01-07 13:26:48.00", "%Y-%m-%d %H:%M:%S.%f") "2020-01-07 13:26:48.00", "%Y-%m-%d %H:%M:%S.%f")
...@@ -417,44 +419,55 @@ def test_initialize_from_db(): ...@@ -417,44 +419,55 @@ def test_initialize_from_db():
modules=[0], modules=[0],
constant_shape=(3, MEM_CELLS, 512, 128)) constant_shape=(3, MEM_CELLS, 512, 128))
# CalCatError: calibration_constant_version not found !
with pytest.raises(CalCatError):
agipd_corr.initialize_from_db(
karabo_id="TEST_DET_CAL_CI-1",
karabo_da="TEST_DET_CAL_DA1",
creation_time=creation_time,
memory_cells=MEM_CELLS,
bias_voltage=BIAS_VOLTAGE,
photon_energy=PHOTON_ENERGY,
gain_setting=GAIN_SETTING,
gain_mode=GAIN_MODE,
acquisition_rate=ACQ_RATE,
integration_time=INTEGRATION_TIME,
module_idx=0,
)
# TODO add a marker for accessing zmq end_point
@pytest.mark.requires_gpfs
@pytest.mark.requires_caldb
def test_initialize_from_db():
creation_time = datetime.strptime(
"2020-01-07 13:26:48.00", "%Y-%m-%d %H:%M:%S.%f")
agipd_corr = AgipdCorrections(
max_cells=MEM_CELLS,
cell_sel=CellRange([0, 500, 1], MEM_CELLS))
agipd_corr.allocate_constants(
modules=[0],
constant_shape=(3, MEM_CELLS, 512, 128))
agipd_corr
dark_const_time_dict = agipd_corr.initialize_from_db( dark_const_time_dict = agipd_corr.initialize_from_db(
karabo_id="TEST_DET_CAL_CI-1", karabo_id=AGIPD_KARABO_ID,
karabo_da="TEST_DET_CAL_DA1", karabo_da="AGIPD00",
cal_db_interface=CAL_DB_INTERFACE,
creation_time=creation_time, creation_time=creation_time,
memory_cells=MEM_CELLS, memory_cells=MEM_CELLS,
bias_voltage=BIAS_VOLTAGE, bias_voltage=BIAS_VOLTAGE,
photon_energy=PHOTON_ENERGY, photon_energy=PHOTON_ENERGY,
gain_setting=GAIN_SETTING, gain_setting=GAIN_SETTING,
acquisition_rate=ACQ_RATE, gain_mode=GAIN_MODE,
integration_time=INTEGRATION_TIME, integration_time=INTEGRATION_TIME,
acquisition_rate=ACQ_RATE,
module_idx=0, module_idx=0,
only_dark=False,
)
assert dark_const_time_dict == {
"Offset": None,
"Noise": None,
"ThresholdsDark": None,
"BadPixelsDark": None,
}
dark_const_time_dict = agipd_corr.initialize_from_db(
karabo_id=AGIPD_KARABO_ID,
karabo_da="AGIPD00",
cal_db_interface=CAL_DB_INTERFACE,
creation_time=creation_time,
memory_cells=MEM_CELLS, bias_voltage=BIAS_VOLTAGE,
photon_energy=PHOTON_ENERGY, gain_setting=GAIN_SETTING,
integration_time=INTEGRATION_TIME,
acquisition_rate=ACQ_RATE, module_idx=0,
only_dark=False,
) )
# A retrieved constant has a value of datetime creation_time # A retrieved constant has a value of datetime creation_time
assert isinstance(dark_const_time_dict["Offset"], datetime) assert isinstance(dark_const_time_dict["Offset"], str)
assert list(dark_const_time_dict.keys()) == [ assert set(dark_const_time_dict.keys()) == {
"Offset", "Noise", "ThresholdsDark", "BadPixelsDark"] "Offset", "Noise", "ThresholdsDark", "BadPixelsDark"}
def test_module_index_to_qm(): def test_module_index_to_qm():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment