Skip to content
Snippets Groups Projects
Commit 7143789a authored by Philipp Schmidt's avatar Philipp Schmidt
Browse files

(fixup) minor formatting fixes

parent f76b6497
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !995. Comments created here will be created in the context of that merge request.
...@@ -137,7 +137,7 @@ def inject_ccv(const_src, ccv_root, report_to): ...@@ -137,7 +137,7 @@ def inject_ccv(const_src, ccv_root, report_to):
unique_name = detector_type[:detector_type.index('-Type')] + ' Def' unique_name = detector_type[:detector_type.index('-Type')] + ' Def'
cond_hash = md5(pdu_name.encode()) cond_hash = md5(pdu_name.encode())
cond_hash.update(pdu_uuid.to_bytes( cond_hash.update(pdu_uuid.to_bytes(
length=8, byteorder='little', signed=False))3 length=8, byteorder='little', signed=False))
for param_dict in cond_params: for param_dict in cond_params:
cond_hash.update(str(param_dict['parameter_name']).encode()) cond_hash.update(str(param_dict['parameter_name']).encode())
...@@ -194,9 +194,12 @@ def inject_ccv(const_src, ccv_root, report_to): ...@@ -194,9 +194,12 @@ def inject_ccv(const_src, ccv_root, report_to):
copyfile(const_src, const_dest) copyfile(const_src, const_dest)
def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, const_input, begin_at): def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond,
pdu, const_input, begin_at):
"""Inject new CCV into CalCat. """Inject new CCV into CalCat.
LEGACY VERSION - DO NOT USE
(from before most details were saved in CCV file itself)
metadata_folder metadata_folder
calibration -> in file, but pass anyway as there could be multiple calibration -> in file, but pass anyway as there could be multiple
...@@ -209,13 +212,15 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, ...@@ -209,13 +212,15 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu,
metadata_folder, # Same as notebook parameter metadata_folder, # Same as notebook parameter
[run_high, run_mid, run_low], [run_high, run_mid, run_low],
'Offset', 'Offset',
current_pdu, # Element of calibration_client.from get_all_phy_det_units_from_detector current_pdu, # Element of calibration_client.from
# get_all_phy_det_units_from_detector
out_folder / 'my-constant-file.h5', out_folder / 'my-constant-file.h5',
get_dir_creation_date(in_folder, run_high) get_dir_creation_date(in_folder, run_high)
) )
Args: Args:
in_folder (str or Path): Root for input data, i.e. *not* containing r{run:04d} folder in_folder (str or Path): Root for input data, i.e. *not*
containing r{run:04d} folder
metadata_folder (str or Path): Metadata location metadata_folder (str or Path): Metadata location
runs (Iterable of str or int): Run number(s) used for characterization. runs (Iterable of str or int): Run number(s) used for characterization.
calibration (str): Calibration name, e.g. 'Offset', must exist in CalCat. calibration (str): Calibration name, e.g. 'Offset', must exist in CalCat.
...@@ -246,7 +251,8 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, ...@@ -246,7 +251,8 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu,
# Generate condition name. # Generate condition name.
unique_name = detector_type[:detector_type.index('-Type')] + ' Def' unique_name = detector_type[:detector_type.index('-Type')] + ' Def'
cond_hash = hashlib.md5(pdu_name.encode()) cond_hash = hashlib.md5(pdu_name.encode())
cond_hash.update(pdu['uuid'].to_bytes(length=8, byteorder='little', signed=False)) cond_hash.update(pdu['uuid'].to_bytes(
length=8, byteorder='little', signed=False))
for key, value in cond_dict.items(): for key, value in cond_dict.items():
cond_hash.update(str(key).encode()) cond_hash.update(str(key).encode())
...@@ -305,7 +311,8 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, ...@@ -305,7 +311,8 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu,
} }
} }
resp = CalibrationClient.inject_new_calibration_constant_version(calibration_client(), inject_h) resp = CalibrationClient.inject_new_calibration_constant_version(
calibration_client(), inject_h)
if not resp['success']: if not resp['success']:
raise RuntimeError(resp) raise RuntimeError(resp)
......
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