Save-Path-File-Changes #1
@ -792,7 +792,7 @@ def b_field_rotation(instr1:pyvisa.resources.Resource, instr2:pyvisa.resources.R
|
|||||||
endangle = endangle % 360 # ensures that the angles are within [0,360)
|
endangle = endangle % 360 # ensures that the angles are within [0,360)
|
||||||
|
|
||||||
idnstr1 = query_no_echo(instr1, '*IDN?')
|
idnstr1 = query_no_echo(instr1, '*IDN?')
|
||||||
idnstr2 = query_no_echo(instr1, '*IDN?')
|
idnstr2 = query_no_echo(instr2, '*IDN?')
|
||||||
|
|
||||||
intensity_data = [] # To store data from each scan
|
intensity_data = [] # To store data from each scan
|
||||||
cwd = os.getcwd() # save original directory
|
cwd = os.getcwd() # save original directory
|
||||||
@ -855,15 +855,26 @@ def b_field_rotation(instr1:pyvisa.resources.Resource, instr2:pyvisa.resources.R
|
|||||||
# value = 0 # Simulate receiving a float from the device INSERT QUERY NO ECHO HERE TO ASK FOR DEVICE IMAG
|
# value = 0 # Simulate receiving a float from the device INSERT QUERY NO ECHO HERE TO ASK FOR DEVICE IMAG
|
||||||
if '2301034' in device_id:
|
if '2301034' in device_id:
|
||||||
value = sep_num_from_units(query_no_echo(instr1, 'IMAG?'))[0]*0.1 # convert kG to T
|
value = sep_num_from_units(query_no_echo(instr1, 'IMAG?'))[0]*0.1 # convert kG to T
|
||||||
|
if value <= target_value[device_id]:
|
||||||
|
write_no_echo(instr1, f"CHAN 2;ULIM {target_value[device_id]*10};SWEEP UP")
|
||||||
|
else:
|
||||||
|
write_no_echo(instr1, "CHAN 2;LLIM {target_value[device_id]*10};SWEEP DOWN")
|
||||||
|
|
||||||
elif '2101014' in device_id:
|
elif '2101014' in device_id:
|
||||||
value = sep_num_from_units(query_no_echo(instr2, 'IMAG?'))[0]*0.1 # convert kG to T
|
value = sep_num_from_units(query_no_echo(instr2, 'IMAG?'))[0]*0.1 # convert kG to T
|
||||||
|
if value <= target_value[device_id]:
|
||||||
|
write_no_echo(instr2, f"ULIM {target_value[device_id]*10};SWEEP UP")
|
||||||
|
else:
|
||||||
|
write_no_echo(instr2, "LLIM {target_value[device_id]*10};SWEEP DOWN")
|
||||||
|
else:
|
||||||
|
continue # Skip if device ID is not recognized
|
||||||
print(f"Device {device_id} reports value: {value} T")
|
print(f"Device {device_id} reports value: {value} T")
|
||||||
|
|
||||||
with lock:
|
with lock:
|
||||||
shared_values[device_id] = value
|
shared_values[device_id] = value
|
||||||
# Check if both devices have met their targets
|
# Check if both devices have met their targets
|
||||||
if all(shared_values.get(device) is not None and abs(shared_values[device] - target_value[device]) <= 0.0001
|
if all(shared_values.get(device) is not None and abs(value - target_value[device]) <= 0.0001
|
||||||
for device in shared_values):
|
for device,value in shared_values.items()):
|
||||||
print(f"Both devices reached their target values: {shared_values}")
|
print(f"Both devices reached their target values: {shared_values}")
|
||||||
all_targets_met_event.set() # Signal that both targets are met
|
all_targets_met_event.set() # Signal that both targets are met
|
||||||
|
|
||||||
@ -891,6 +902,10 @@ def b_field_rotation(instr1:pyvisa.resources.Resource, instr2:pyvisa.resources.R
|
|||||||
# Wait until both devices meet their target values
|
# Wait until both devices meet their target values
|
||||||
all_targets_met_event.wait()
|
all_targets_met_event.wait()
|
||||||
print(f"Both target values for iteration {iteration+1} met. Performing action...")
|
print(f"Both target values for iteration {iteration+1} met. Performing action...")
|
||||||
|
# Clean up threads
|
||||||
|
for thread in threads:
|
||||||
|
thread.join()
|
||||||
|
print(f"Threads for iteration {iteration+1} closed.\n")
|
||||||
|
|
||||||
# Perform some action after both targets are met
|
# Perform some action after both targets are met
|
||||||
# we acquire with the LF
|
# we acquire with the LF
|
||||||
@ -913,12 +928,6 @@ def b_field_rotation(instr1:pyvisa.resources.Resource, instr2:pyvisa.resources.R
|
|||||||
#append the intensity data as it is (so after every #of_wl_points, the spectrum of the next point begins)
|
#append the intensity data as it is (so after every #of_wl_points, the spectrum of the next point begins)
|
||||||
intensity_data.append(loaded_files.data[0][0][0])
|
intensity_data.append(loaded_files.data[0][0][0])
|
||||||
|
|
||||||
# Clean up threads
|
|
||||||
for thread in threads:
|
|
||||||
thread.join()
|
|
||||||
|
|
||||||
print(f"Threads for iteration {iteration+1} closed.\n")
|
|
||||||
|
|
||||||
#prints total time the mapping lasted
|
#prints total time the mapping lasted
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
elapsed_time = (end_time - start_time) / 60
|
elapsed_time = (end_time - start_time) / 60
|
||||||
|
8
Test.py
8
Test.py
@ -138,5 +138,13 @@ if __name__=="__main__":
|
|||||||
|
|
||||||
# print(generate_coord_list_fixed_angle(10, 5, 1, reverse=False))
|
# print(generate_coord_list_fixed_angle(10, 5, 1, reverse=False))
|
||||||
|
|
||||||
|
testdict = [{'2301034': bval[0], '2101014': bval[1]} for bval in coordinates]
|
||||||
|
print(f"{testdict=}")
|
||||||
|
|
||||||
|
for i, target in enumerate(testdict):
|
||||||
|
print(i, target.keys())
|
||||||
|
# for key in target.keys():
|
||||||
|
# print(type(key))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user