Exemple #1
0
###########################################
# Script to read in pickled wave
# file for basic checks. Inherits
# strongly from AcquireTek/calc_utils.py
#
# Author: Ed Leming
# Date:   08/04/2015
############################################
import time
import sys
import calc_utils as calc

if __name__ == "__main__":

    ## File path
    fileName = sys.argv[1]

    ## Read data
    fileRead = time.time()
    x, y = calc.readPickleChannel(fileName, 1)
    print "Reading %d pulses from file took %1.2f s" % (len(
        y[:, 0]), (time.time() - fileRead))
    calc.printParams(x, y, "pmt pulses")
    print "Reading + calcs on %d pulses from file took %1.2f s" % (len(
        y[:, 0]), (time.time() - fileRead))

    ### PLOT ###
    calc.plot_eg_pulses(x, y, 10, show=True)
def sweep(dir_out,box,channel,width,delay,scope,min_volt=None):
    """Perform a measurement using a default number of
    pulses, with user defined width, channel and rate settings.
    """
    print '____________________________'
    print width

    #fixed options
    height = 16383    
    fibre_delay = 0
    trigger_delay = 0
    pulse_number = 100
    #first select the correct channel and provide settings
    logical_channel = (box-1)*8 + channel
    
    sc.select_channel(logical_channel)
    sc.set_pulse_width(width)
    sc.set_pulse_height(16383)
    sc.set_pulse_number(pulse_number)
    sc.set_pulse_delay(delay)
    sc.set_fibre_delay(fibre_delay)
    sc.set_trigger_delay(trigger_delay)
    
    # first, run a single acquisition with a forced trigger, effectively to clear the waveform
    scope._connection.send("trigger:state ready")
    time.sleep(0.1)
    scope._connection.send("trigger force")
    time.sleep(0.1)

    # Get pin read
    time.sleep(0.1)
    sc.fire_sequence() # previously fire_sequence!
    #wait for the sequence to end
    tsleep = pulse_number * (delay*1e-3 + 210e-6)
    time.sleep(tsleep) #add the offset in
    pin = None
   # while not comms_flags.valid_pin(pin,channel):
    while pin==None:
        pin,rms, _ = sc.tmp_read_rms()
    print "PIN (sweep):",pin[logical_channel], rms[logical_channel]
    sc.stop()

    # File system stuff
    check_dir("%s/raw_data/" % (dir_out))
    directory = check_dir("%s/raw_data/Channel_%02d/" % (dir_out,logical_channel))
    fname = "%sWidth%05d" % (directory,width)
    
    # Check scope
    ck = find_and_set_scope_y_scale(1,height,width,delay,scope,scaleGuess=min_volt)

    if ck == True:
        print "Saving raw files to: %s..." % fname
        sc.fire_continuous()
        time.sleep(0.2)
        save_ck = save_scopeTraces(fname, scope, 1, 100)
        sc.stop()
        if save_ck == True:
            # Calc and return params
            x,y = calc.readPickleChannel(fname, 1)
            results = calc.dictionary_of_params(x,y)
            results["pin"] = pin[logical_channel]
            results["pin error"] = rms[logical_channel]
            calc.printParamsDict(results, width)
            calc.plot_eg_pulses(x,y,10, fname='%s/LastMeasuredPulses.png' % dir_out.split("/")[0])
            #os.system("open %s/LastMeasuredPulses.png" % dir_out.split("/")[0])
        elif save_ck == False:
            results = return_zero_result()
            results['pin'] = pin[logical_channel]
    else: 
        results = return_zero_result()
        results['pin'] = pin[logical_channel]
        results["pin error"] = rms[logical_channel]
    sc.stop()
    return results
###########################################
# Script to read in pickled wave 
# file for basic checks. Inherits
# strongly from AcquireTek/calc_utils.py
# 
# Author: Ed Leming 
# Date:   08/04/2015
############################################
import time
import sys
import calc_utils as calc

if __name__ == "__main__":

    ## File path
    fileName = sys.argv[1]
    
    ## Read data
    fileRead = time.time()
    x,y = calc.readPickleChannel(fileName, 1)
    print "Reading %d pulses from file took %1.2f s" % ( len(y[:,0]), (time.time()-fileRead) )
    calc.printParams(x,y,"pmt pulses")
    print "Reading + calcs on %d pulses from file took %1.2f s" % ( len(y[:,0]), (time.time()-fileRead) )

    ### PLOT ###
    calc.plot_eg_pulses(x,y,10,show=True)
Exemple #4
0
def sweep(dir_out, box, channel, width, delay, scope, min_volt=None):
    """Perform a measurement using a default number of
    pulses, with user defined width, channel and rate settings.
    """
    print '____________________________'
    print width

    #fixed options
    height = 16383
    fibre_delay = 0
    trigger_delay = 0
    pulse_number = 100
    #first select the correct channel and provide settings
    logical_channel = (box - 1) * 8 + channel

    sc.select_channel(logical_channel)
    sc.set_pulse_width(width)
    sc.set_pulse_height(16383)
    sc.set_pulse_number(pulse_number)
    sc.set_pulse_delay(delay)
    sc.set_fibre_delay(fibre_delay)
    sc.set_trigger_delay(trigger_delay)

    # first, run a single acquisition with a forced trigger, effectively to clear the waveform
    scope._connection.send("trigger:state ready")
    time.sleep(0.1)
    scope._connection.send("trigger force")
    time.sleep(0.1)

    # Get pin read
    time.sleep(0.1)
    sc.fire_sequence()  # previously fire_sequence!
    #wait for the sequence to end
    tsleep = pulse_number * (delay * 1e-3 + 210e-6)
    time.sleep(tsleep)  #add the offset in
    pin = None
    # while not comms_flags.valid_pin(pin,channel):
    while pin == None:
        pin, rms, _ = sc.tmp_read_rms()
    print "PIN (sweep):", pin[logical_channel], rms[logical_channel]
    sc.stop()

    # File system stuff
    check_dir("%s/raw_data/" % (dir_out))
    directory = check_dir("%s/raw_data/Channel_%02d/" %
                          (dir_out, logical_channel))
    fname = "%sWidth%05d" % (directory, width)

    # Check scope
    ck = find_and_set_scope_y_scale(1,
                                    height,
                                    width,
                                    delay,
                                    scope,
                                    scaleGuess=min_volt)

    if ck == True:
        print "Saving raw files to: %s..." % fname
        sc.fire_continuous()
        time.sleep(0.2)
        save_ck = save_scopeTraces(fname, scope, 1, 100)
        sc.stop()
        if save_ck == True:
            # Calc and return params
            x, y = calc.readPickleChannel(fname, 1)
            results = calc.dictionary_of_params(x, y)
            results["pin"] = pin[logical_channel]
            results["pin error"] = rms[logical_channel]
            calc.printParamsDict(results, width)
            calc.plot_eg_pulses(x,
                                y,
                                10,
                                fname='%s/LastMeasuredPulses.png' %
                                dir_out.split("/")[0])
            #os.system("open %s/LastMeasuredPulses.png" % dir_out.split("/")[0])
        elif save_ck == False:
            results = return_zero_result()
            results['pin'] = pin[logical_channel]
    else:
        results = return_zero_result()
        results['pin'] = pin[logical_channel]
        results["pin error"] = rms[logical_channel]
    sc.stop()
    return results