Formalize hardware configuration
The hardware configuration is currently a dict without a formal structure (the documentation only shows two examples). That makes it hard to write good methods to modify or generate this configuration. For example, we wrote the following method to update the line gain settings:
def update_line_gain(hardware_mapping, gain_dictionary):
for key in hardware_mapping:
if key=='backend':
continue
for key2 in hardware_mapping[key]:
if key2=='ref' or key2=='instrument_type':
continue
print(f'checking {key} {key2}')
for key3 in hardware_mapping[key][key2]:
if key3=='line_gain_db':
continue
port = hardware_mapping[key][key2][key3]['port']
if port in gain_dictionary:
hardware_mapping[key][key2]['line_gain_db']=gain_dictionary[port]
gain_dictionary_db = {'P1': -3., 'P2': -1.1, 'RP':-2.3}
update_line_gain(SPIN_HARDWARE_MAPPING_CFG, gain_dictionary_db)
The method is error prone and could be improved if either the hardware configuration is a class or dataclass with structure, or tooling is provided to generate the hardware mapping.