예제 #1
0
def measureIF(cellnum, N, filebase, volt=10.):
    """
    Measure the influence function of piezo cell cellnum.
    Measure using 100 averages per measurement, and do this N times.
    Save the results in a 3D fits file of shape (N,128,128).
    These results may then be postprocessed into an influence function
    fits file.
    Resulting fits files will be saved as:
    filebase+'_%03i.fits'
    """
    num = 100
    sy = np.zeros((N, 128, 128))
    sx = np.zeros((N, 128, 128))
    p = np.zeros((N, 128, 128))
    for i in range(N):
        #Ensure all cells are grounded
        ax.ground()

        #Take WFS reference measurement
        ref_file = 'C:\\Users\\rallured\\Documents\\HFDFC3_Measurements\\Ref_CellNum' + str(
            cellnum) + '_Meas' + str(i) + '.has'
        wfs.takeWavefront(
            num, filename=ref_file
        )  #filename='Ref_CellNum_' + str(cellnum) + '_Meas' + str(i) + '.has')

        #Set cell voltage
        ax.setVoltChan(cellnum, volt)
        print volt

        print '\nTaking a nap.........\n'
        time.sleep(10)
        #Take actuated WFS measurement
        act_file = 'C:\\Users\\rallured\\Documents\\HFDFC3_Measurements\\Act_CellNum' + str(
            cellnum) + '_Meas' + str(i) + '.has'
        wfs.takeWavefront(
            num, filename=act_file
        )  #filename='Act_CellNum_' + str(cellnum) + '_Meas' + str(i) + '.has')
        #time.sleep(1)

        #Ensure all cells are grounded
        ax.ground()

        #Process influence function measurement
        sy[i] = wfs.processHAS(act_file, ref=ref_file, type='Y')
        sx[i] = wfs.processHAS(act_file, ref=ref_file, type='X')
        p[i] = wfs.processHAS(act_file, ref=ref_file, type='P')

    #Write fits file
    pyfits.writeto('%s_SY_%03i.fits' % (filebase, cellnum), sy, clobber=True)
    pyfits.writeto('%s_SX_%03i.fits' % (filebase, cellnum), sx, clobber=True)
    pyfits.writeto('%s_P_%03i.fits' % (filebase, cellnum), p, clobber=True)

    return sy, sx, p
예제 #2
0
def measureIF_WFS(cellnum, N=1, filebase='', volt=0, ftype=None):
    """
    Measure the influence function using the WFS of piezo cell cellnum.
    Measure using 100 averages per measurement, and do this N times.
    Save the results in a 3D fits file of shape (N,128,128).
    These results may then be postprocessed into an influence function
    fits or h5 file.

    """
    num = 100
    sy = np.zeros((N, 128, 128))
    sx = np.zeros((N, 128, 128))
    p = np.zeros((N, 128, 128))

    for i in range(N):
        #Ensure all cells are grounded
        ax.ground()

        #Take WFS reference measurement
        ref_file = os.path.join(fdir, 'Ref_CellNum' + str(cellnum) + '_Meas' + str(i) + '.has')
        wfs.takeWavefront(num, filename=ref_file)

        #Set cell voltage
        ax.setVoltChan(cellnum, volt)
        print(volt)

        print('\nTaking a nap.........\n')
        time.sleep(10)
        #Take actuated WFS measurement
        act_file = os.path.join(fdir, 'Act_CellNum' + str(cellnum) + '_Meas' + str(i) + '.has')
        wfs.takeWavefront(num, filename=act_file)#filename='Act_CellNum_' + str(cellnum) + '_Meas' + str(i) + '.has')
        #time.sleep(1)

        #Ensure all cells are grounded
        ax.ground()

        #Process influence function measurement
        sy[i] = wfs.processHAS(act_file, ref=ref_file, ptype='Y')
        sx[i] = wfs.processHAS(act_file, ref=ref_file, ptype='X')
        p[i] = wfs.processHAS(act_file, ref=ref_file, ptype='P')

    # Save compiled array to defined filetype
    save_dataset_wfs(sx, sy, p, cellnum, filebase=filebase, ftype=ftype)
예제 #3
0
def measChangeFromVolts(opt_volts, n, filebase=''):
    # First grounding everything on HFDFC3.
    ax.ground()

    # Now taking the grounded reference measurement.
    ref_file = 'C:\\Users\\rallured\\Documents\\HFDFC3_IterativeCorrection\\RefMeas' + str(
        n) + '.has'
    wfs.takeWavefront(100, filename=ref_file)

    #Set optimal cell voltages
    ax.setVoltArr(opt_volts)

    # Waiting to let the cells reach equilibrium -- probably not needed.
    print '\nWaiting for Cells To Stabilize....\n'
    time.sleep(2)

    actual_volts = ax.readVoltArr()

    time.sleep(2)

    # Now taking the activated measurement.
    act_file = 'C:\\Users\\rallured\\Documents\\HFDFC3_IterativeCorrection\\OptVolt_Meas' + str(
        n) + '.has'
    wfs.takeWavefront(100, filename=act_file)

    # And returning to the grounded state for safety.
    ax.ground()

    # Computing the relative change from the activated state to the ground state.
    rel_change = wfs.processHAS(act_file, ref=ref_file, type='P')

    # And saving the measurement at the specified file path location.
    figure_filepath = filebase + '_MeasChange_Iter' + str(n) + '.fits'
    hdu = pyfits.PrimaryHDU(rel_change)
    hdu.writeto(figure_filepath, clobber=True)

    np.savetxt(filebase + '_MeasVoltApplied_Iter' + str(n) + '.txt',
               actual_volts)

    # Returning the file path location for easy reading with the metrology suite.
    return figure_filepath
예제 #4
0
def measureIF_4D(cellnum, N=1, filebase='', volt=0, ftype='h5'):
    """
    Measure the influence function using the WFS of piezo cell cellnum.
    Measure using 100 averages per measurement, and do this N times.
    Save the results in a h5 file of shape (N,128,128).
    These results may then be postprocessed into an influence function
    fits or h5 file.

    """
    num = 32  # num frames avg

    for i in range(N):
        #Ensure all cells are grounded
        ax.ground()

        #Take WFS reference measurement
        ref_file = os.path.join(fdir, 'Ref_CellNum' + str(cellnum) + '_Meas' + str(i) + '.h5')
        intcom.takeWavefront(num, filename=ref_file)

        #Set cell voltage
        ax.setVoltChan(cellnum, volt)
        print(volt)

        print('\nTaking a nap.........\n')
        time.sleep(2)
        #Take actuated WFS measurement
        act_file = os.path.join(fdir, 'Act_CellNum' + str(cellnum) + '_Meas' + str(i) + '.h5')
        intcom.takeWavefront(num, filename=act_file)#filename='Act_CellNum_' + str(cellnum) + '_Meas' + str(i) + '.has')
        time.sleep(1)
        #Ensure all cells are grounded
        ax.ground()
        refdata, _, _ = load_h5(ref_file)
        actdata, _, _ = load_h5(act_file)

        # Save to a composite h5 file of the reference subtracted data
        save_dataset_4d(actdata-refdata, cellnum=cellnum, filebase=filebase, ftype=ftype)