def take_fringe(reck_heaters, heater_index, min_voltage, max_voltage, N, int_time, metadata): global output_file output_file = ctx( 'C:/Users/Qubit/Code/lab_code/Calibration/Calibration/data/', metadata=metadata) output_file_name = output_file.filename parameter_space = np.linspace(min_voltage, max_voltage, N) # Connect to the counting gear and configure it counter = coincidence_counter(callback=handle_data) counter.set_integration_time(int_time) for index, parameter in enumerate(parameter_space): print 'Setting voltage %s' % str(parameter) reck_heaters.send_one_voltage(heater_index, parameter) current_context = reck_heaters.dict() counter.count(context=current_context) # Collect and log the last piece of data from the postprocessor counter.collect() # Close connections to hardware counter.kill() return output_file_name
def parse(datafilename, patterns): # This loads the CTX file #dir = os.path.dirname(os.path.realpath(__file__)) #datafilename = os.path.join(dir, '2014_05_13_tuesday_11h57m00s.ctx') ctxfile=ctx(datafilename) #print ctxfile # This pulls out all the stuff to do with count rates all_counts = list(ctxfile.stream('count_rates')) # This filters for the count rates we care about select_counts = lambda data: [parse_coincidence_pattern(pattern, data) for pattern in patterns] interesting_counts_table = np.array(map(select_counts, all_counts)) print interesting_counts_table # Now it's a numpy array, so we can integrate, average sum etc #print interesting_counts_table fit_data = np.sum(interesting_counts_table, axis=1) #print np.sum(interesting_counts_table, axis=1) print fit_data raw_input() return fit_data
def pm_take_fringe(reck_heaters, heater_index, min_voltage, max_voltage, N, int_time, metadata): pm=powermeter() keys = ['a','b','c','d','e','f'] #global output_file output_file = ctx('C:/Users/Qubit/Code/lab_code/Calibration/Calibration/data/', metadata=metadata) output_file_name = output_file.filename parameter_space=np.linspace(min_voltage, max_voltage, N) for index, parameter in enumerate(parameter_space): print 'Setting voltage %s' % str(parameter) reck_heaters.send_one_voltage(heater_index, parameter) time.sleep(1) total=np.zeros(6) print reck_heaters.query_v(heater_index) print pm.read() for i in range(int_time): total += np.array(pm.read()) print total counts_dict = dict(zip(keys, total.tolist())) output_file.write('count_rates', counts_dict) current_context=reck_heaters.vip_heater(heater_index) output_file.write('context', current_context) pm.kill() return output_file_name
def parse(datafilename, patterns): # This loads the CTX file #dir = os.path.dirname(os.path.realpath(__file__)) #datafilename = os.path.join(dir, '2014_05_13_tuesday_11h57m00s.ctx') ctxfile = ctx(datafilename) #print ctxfile # This pulls out all the stuff to do with count rates all_counts = list(ctxfile.stream('count_rates')) # This filters for the count rates we care about select_counts = lambda data: [ parse_coincidence_pattern(pattern, data) for pattern in patterns ] interesting_counts_table = np.array(map(select_counts, all_counts)) print interesting_counts_table # Now it's a numpy array, so we can integrate, average sum etc #print interesting_counts_table fit_data = np.sum(interesting_counts_table, axis=1) #print np.sum(interesting_counts_table, axis=1) print fit_data raw_input() return fit_data
def pm_take_fringe(reck_heaters, heater_index, min_voltage, max_voltage, N, int_time, metadata): pm = powermeter() keys = ['a', 'b', 'c', 'd', 'e', 'f'] #global output_file output_file = ctx( 'C:/Users/Qubit/Code/lab_code/Calibration/Calibration/data/', metadata=metadata) output_file_name = output_file.filename parameter_space = np.linspace(min_voltage, max_voltage, N) for index, parameter in enumerate(parameter_space): print 'Setting voltage %s' % str(parameter) reck_heaters.send_one_voltage(heater_index, parameter) time.sleep(1) total = np.zeros(6) print reck_heaters.query_v(heater_index) print pm.read() for i in range(int_time): total += np.array(pm.read()) print total counts_dict = dict(zip(keys, total.tolist())) output_file.write('count_rates', counts_dict) current_context = reck_heaters.vip_heater(heater_index) output_file.write('context', current_context) pm.kill() return output_file_name
def take_fringe(reck_heaters, heater_index, min_voltage, max_voltage, N, int_time, metadata): global output_file output_file = ctx('C:/Users/Qubit/Code/lab_code/Calibration/Calibration/data/', metadata=metadata) output_file_name = output_file.filename parameter_space=np.linspace(min_voltage, max_voltage, N) # Connect to the counting gear and configure it counter=coincidence_counter(callback=handle_data) counter.set_integration_time(int_time) for index, parameter in enumerate(parameter_space): print 'Setting voltage %s' % str(parameter) reck_heaters.send_one_voltage(heater_index, parameter) current_context=reck_heaters.dict() counter.count(context=current_context) # Collect and log the last piece of data from the postprocessor counter.collect() # Close connections to hardware counter.kill() return output_file_name
from qy.analysis.coincidence_counting import pattern_parser from matplotlib import pyplot as plt from glob import glob import os ''' An example of reading and processing data from a dip-like measurement ''' # Get a list of CTX files on the dekstop all_files=glob('C:/Users/Qubit/Desktop/data_from_example_scripts/*.ctx') filename=all_files[-1] # Load up a file for reading my_file=ctx(filename) # What do we know about it already? print my_file ############################### # Simple reading of data ############################### # Read out some countrates for data in my_file.stream('count_rates'): print 'Raw data:', data twofolds = pattern_parser.parse_coincidence_pattern('**', data) print 'Total twofolds (**):', twofolds # Read out some positions
output_file.write("context", context) # A less verbose alternative: # output_file.write('position', context[which_motor]['position']) # Write count rates to disk output_file.write("count_rates", count_rates) elif key == "dpc230_status": pass ##################################################### # START HERE ##################################################### # Get a file ready to store data metadata = {"label": "This is a test!", "mood": "hungry for knowledge"} output_file = ctx("C:/Users/Qubit/Desktop/data_from_example_scripts/", metadata=metadata) # Dip parameters parameter_space = np.linspace(0, 10, 11) which_motor = 3 # Connect to the motor controllers motor_controller = smc100(callback=None) # Connect to the counting gear and configure it counter = coincidence_counter(callback=handle_data) counter.set_integration_time(1) # Loop over a dip for position in parameter_space: print "Moving to position %.3f" % position
''' Check the state of the gui ''' for key, value in interface.collect(): if key=='gui_quit': sys.exit(0) elif key=='log_now': data_file.write('powers', total.tolist()) print 'wrote ', total # The GUI interface=gui() # The meter powermeter=powermeter() # Output file data_file=ctx('data/%s.ctx' % qy.util.timestamp()) data_file.write_metadata({'scan_label':'Looking at bright light'}) total=np.zeros(6) print data_file while True: total=np.zeros(6) for i in range(10): total += np.array(powermeter.read()) data=dict(zip('abcdefg', total)) interface.send('count_rates', data) check_gui() interface.kill()
interface.send('count_rates', count_rates) elif key == 'dpc230_status': interface.send('status', value) ##################################################### # START HERE ##################################################### # Dip parameters parameter_space = np.linspace(0, 10, 11) which_motor = 3 # Get a file ready to store data md = {'label': 'This is a test!', 'mood': 'hungry for knowledge'} output_file = ctx('C:/Users/Qubit/Desktop/data_from_example_scripts/', metadata=md) # Make the GUI interface = gui() # Connect to the motor controllers motor_controller = smc100(callback=None) # Connect to the counting gear and configure it counter = coincidence_counter(callback=handle_data) counter.set_integration_time(1) # Loop over a dip for position in parameter_space: print 'Moving to position %.3f' % position motor_controller.actuators[which_motor].move(position)