Skip to content

Commit

Permalink
Update create_calib_file.py to work with latest slow control version
Browse files Browse the repository at this point in the history
  • Loading branch information
lscharenberg authored May 12, 2023
1 parent d7a1e94 commit efe8e5c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions calib/create_calib_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import argparse
import os
import re
text_description = "JSON calibration file manipulator. The tool create_calib_file.py creates a calibration file for a whole system of multiple hybrids. The user has to specify the JSON mapping file that describes the system (mapping between hybrid, FEC and VMM), the name for the new combined system calibration file, the directory with the calibration files of the individual hybrids, and the choice of calibrations (ADC, time, time walk)."
parser = argparse.ArgumentParser(description=text_description,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
Expand Down Expand Up @@ -53,8 +54,9 @@
d.update(y)
if is_adc:
for filename in os.listdir(directory):
search_name = "vmm_adc_calibration_" + d["hybridID"]
if filename.startswith(search_name) and filename.endswith(".json"):
search_name = "vmm_calibration_ADC"
if bool(re.search(search_name + "_FEC._" + d["hybridID"], filename)) == True and filename.endswith(".json"):
print(filename)
with open(filename, "r") as file:
the_calib = json.load(file)
for c in the_calib["vmm_calibration"]:
Expand All @@ -63,8 +65,9 @@
d["adc_offsets"] = c["adc_offsets"]
if is_time:
for filename in os.listdir(directory):
search_name = "vmm_time_calibration_" + d["hybridID"]
if filename.startswith(search_name) and filename.endswith(".json"):
search_name = "vmm_calibration_time"
if bool(re.search(search_name + "_FEC._" + d["hybridID"], filename)) == True and filename.endswith(".json"):
print(filename)
with open(filename, "r") as file:
the_calib = json.load(file)
for c in the_calib["vmm_calibration"]:
Expand All @@ -73,8 +76,9 @@
d["time_offsets"] = c["time_offsets"]
if is_timewalk:
for filename in os.listdir(directory):
search_name = "vmm_timewalk_calibration_" + d["hybridID"]
if filename.startswith(search_name) and filename.endswith(".json"):
search_name = "vmm_calibration_timewalk"
if bool(re.search(search_name + "_FEC._" + d["hybridID"], filename)) == True and filename.endswith(".json"):
print(filename)
with open(filename, "r") as file:
the_calib = json.load(file)
for c in the_calib["vmm_calibration"]:
Expand Down

0 comments on commit efe8e5c

Please sign in to comment.