Пример #1
0
def load_full_map(location ='SACLA'):
    if location == 'i24':
    	chip_name, visit, sub_dir, n_exposures, chip_type, map_type = startup.scrape_parameter_file(location)
    else:
	chip_name, sub_dir, n_exposures, chip_type, map_type = startup.scrape_parameter_file(location)
    #fullmap_path = '/dls_sw/i24/scripts/fastchips/fullmaps/'
    fullmap_path = '/localhome/local/Documents/sacla/parameter_files/'
    fullmap_fid = fullmap_path + str(caget(pv.me14e_gp5)) + '.spec'
    print 'opening', fullmap_fid
    mapping.plot_file(fullmap_fid, chip_type)
    print '\n\n', 10*'PNG '
    mapping.convert_chip_to_hex(full_map_fid, chip_type)
    os.system("cp %s %s" % (fullmap_fid[:-4]+'full', fullmap_path+'currentchip.full'))
    print 10*'Done ', '\n'
def start_sacla():
    print 'Starting SACLA'
    name = inspect.stack()[0][3]
    lg.info('%s Starting SACLA' % name)
    start_time = time.ctime()
    chip_name, sub_dir, n_exposures, chip_type, map_type = scrape_parameter_file(
        location='SACLA')
    #### Hack for sacla3 to bismuth chip type for oxford inner
    if str(chip_type) == '3':
        lg.debug('%s\t:Hack for SACLA3 bismuth for oxford inner' % name)
        chip_type = '1'
    if map_type == '0':
        chip_format = get_format(chip_type)[:4]
        total_numb_imgs = np.prod(chip_format)
        if str(chip_type) == '6':
            xs = int(caget(pv.me14e_gp6))
            ys = int(caget(pv.me14e_gp7))
            print xs, ys, type(xs), type(ys)
            total_numb_imgs = xs * ys
        caput(pv.me14e_gp10, total_numb_imgs)
        caput(pv.me14e_pmac_str, 'P2402=0')
        print 'Total number of images', total_numb_imgs

    elif map_type == '1' or map_type == '3':
        chip_format = get_format(chip_type)[2:4]
        block_count = 0
        f = open(
            '/localhome/local/Documents/sacla/parameter_files/currentchip.map',
            'r')
        for line in f.readlines():
            entry = line.split()
            if entry[2] == '1':
                block_count += 1
        f.close()
        print 'block_count', block_count
        lg.info('%s\t:block_count=%s' % (name, block_count))
        print chip_format
        lg.info('%s\t:chip_format=%s' % (name, chip_format))
        ####################
        n_exposures = caget(pv.me14e_gp3)
        print n_exposures
        lg.info('%s\t:n_exposures=%s' % (name, n_exposures))
        ####################
        total_numb_imgs = np.prod(chip_format) * block_count  # * n_exposures
        caput(pv.me14e_gp10, total_numb_imgs)
        caput(pv.me14e_pmac_str, 'P2402=0')
        print 'Total number of images', total_numb_imgs

    elif map_type == '2':
        lg.warning('%s Not Set Up For Full Mapping' % name)
        print 'FIX ME, Im not set up for full mapping '
    else:
        lg.warning('%s Unknown Map Type, map_type = %s' % (name, map_type))
        print 'Unknown map type'
    ###make sure flipper is out
    moveto('flipperout')
    sleep(1)
    moveto('lightout')
    sleep(3)
    return start_time
def start_i24():
    print 'Starting i24'
    start_time = time.ctime()
    run_num = caget(pv.pilat_filenumber)
    print 80 * '-', run_num
    chip_name, visit, sub_dir, n_exposures, chip_type, map_type, exptime, \
                                        dcdetdist = scrape_parameter_file(location='i24')
    sup.beamline('collect')
    print 'hello', dcdetdist, type(dcdetdist)
    sup.beamline('quickshot', [dcdetdist])

    if map_type == '0':
        chip_format = get_format(chip_type)[:4]
        total_numb_imgs = np.prod(chip_format)

    elif map_type == '1':
        chip_format = get_format(chip_type)[2:4]
        block_count = 0
        f = open('/dls_sw/i24/scripts/fastchips/litemaps/currentchip.map', 'r')
        for line in f.readlines():
            entry = line.split()
            if entry[2] == '1':
                block_count += 1
        f.close()
        print 'block_count', block_count
        print chip_format
        ####################
        n_exposures = caget(pv.me14e_gp3)
        print n_exposures
        ####################
        #total_numb_imgs = np.prod(chip_format) * block_count
        total_numb_imgs = np.prod(chip_format) * block_count * n_exposures
        print 'Total number of images', total_numb_imgs

    elif map_type == '2':
        print 'FIX ME, Im not set up for full mapping '

    else:
        print 'Unknown map type'

    print 'total_numb_imgs', total_numb_imgs, '\n\n\n'
    filepath = visit + sub_dir
    filename = chip_name
    #print 'AAAAAAAAAAAAAAAAAAAAA', filepath, filename
    sup.pilatus('fastchip', [filepath, filename, total_numb_imgs, exptime])
    #sup.pilatus('fastchip-hatrx', [filepath, filename, total_numb_imgs, exptime])
    sup.zebra1('fastchip')

    print 'Acquire Region'
    caput(pv.pilat_acquire, '1')  # Arm pilatus
    caput(pv.zebra1_pc_arm_out, '1')  # Arm zebra
    caput(pv.zebra1_soft_in_b1, '1')  # Open fast shutter (zebra gate)
    caput(pv.pilat_filename, filename)
    time.sleep(1.5)
    return start_time
def start_sacla():
    print 'Starting SACLA'
    start_time = time.ctime()
    chip_name, sub_dir, n_exposures, chip_type, map_type = scrape_parameter_file(
        location='SACLA')
    #### Hack for sacla3 to bismuth chip type for oxford inner
    if str(chip_type) == '3':
        chip_type = '1'
    if map_type == '0':
        chip_format = get_format(chip_type)[:4]
        total_numb_imgs = np.prod(chip_format)

    elif map_type == '1':
        chip_format = get_format(chip_type)[2:4]
        block_count = 0
        f = open(
            '/localhome/local/Documents/sacla/parameter_files/currentchip.map',
            'r')
        for line in f.readlines():
            entry = line.split()
            if entry[2] == '1':
                block_count += 1
        f.close()
        print 'block_count', block_count
        print chip_format
        ####################
        n_exposures = caget(pv.me14e_gp3)
        print n_exposures
        ####################
        #total_numb_imgs = np.prod(chip_format) * block_count * n_exposures
        #print 'Total number of images', total_numb_imgs

    elif map_type == '2':
        print 'FIX ME, Im not set up for full mapping '

    else:
        print 'Unknown map type'

    return start_time
Пример #5
0
def main(location='i24'):
    print 'Location is', location, 'Starting'
    # ABORT BUTTON
    name = inspect.stack()[0][3]
    lg.info('%s' % name)
    lg.info('%s Location is %s \n Starting' % (name, location))
    caput(pv.me14e_gp9, 0)

    if location == 'i24':
        chip_name, visit, sub_dir, n_exposures, chip_type, map_type, exptime, \
                                        dcdetdist = scrape_parameter_file(location='i24')
        print 'exptime', exptime
        print 'visit', visit
        print 'dcdetdist', dcdetdist
        print 'n_exposures', n_exposures
        lg.info('%s exptime = %s' % (name, exptime))
        lg.info('%s visit = %s' % (name, visit))
        lg.info('%s dcdetdist = %s' % (name, dcdetdist))
    else:
        chip_name, sub_dir, n_exposures, chip_type, map_type = scrape_parameter_file(
            location='SACLA')

    print '\n\nChip name is', chip_name
    print 'sub_dir', sub_dir
    print 'n_exposures', n_exposures
    print 'chip_type', chip_type
    print 'map type', map_type
    print 'Getting Prog Dictionary'
    lg.info('%s Chip name is %s' % (name, chip_name))
    lg.info('%s sub_dir = %s' % (name, sub_dir))
    lg.info('%s n_exposures = %s' % (name, n_exposures))
    lg.info('%s chip_type = %s' % (name, chip_type))
    lg.info('%s map_type = %s' % (name, map_type))
    lg.info('%s Getting Program Dictionary' % (name))
    #### Hack for sacla3 to bismuth chip type for oxford inner
    if str(chip_type) == '3':
        lg.debug('%s\tMain:Hack for SACLA3 Bismuth to Oxford Inner' % name)
        chip_type = '1'
    if location == 'i24':
        chip_prog_dict = get_chip_prog_values(chip_type,
                                              location,
                                              exptime=exptime,
                                              n_exposures=n_exposures)
    else:
        chip_prog_dict = get_chip_prog_values(chip_type,
                                              location,
                                              n_exposures=n_exposures)
    print 'Loading Motion Program Data'
    lg.info('%s Loading Motion Program Data' % (name))
    load_motion_program_data(chip_prog_dict, map_type)

    if location == 'i24':
        start_time = start_i24()
    elif location == 'SACLA':
        start_time = start_sacla()
    else:
        lg.warning(
            '%s This does nothing location not i24 or SACLA \n location = %s' %
            (name, location))
        lg.debug('%s Put something here... start_time = start_sacla()' %
                 (name))
        print 'Something here... start_time = start_sacla()'
    #caput('ME14E-DI-CAM-01:CAM:Acquire', 'Done')
    #caput('ME14E-DI-CAM-03:CAM:Acquire', 'Done')

    print 'Moving to Start'
    lg.info('%s Moving to start' % (name))
    caput(pv.me14e_pmac_str, '!x0y0z0')
    sleep(3.5)

    prog_num = get_prog_num(chip_type, map_type)
    lg.info('%s prog_num = %s' % (name, prog_num))
    lg.info('%s Resting' % (name))
    print 'Resting1'

    ##########################################
    #  ADDED DUE TO FAST SHUTTER STUCK OPEN  #
    ##########################################
    caput('BL24I-PS-SHTR-01:CON', 'Reset')
    print 'Reset sleep for 1sec'
    sleep(1.0)
    caput('BL24I-PS-SHTR-01:CON', 'Open')
    print ' Open sleep for 4sec'
    sleep(4.0)

    print 'pmacing'
    lg.info('%s pmacing' % (name))
    lg.info('%s pmac str = &2b%sr' % (name, prog_num))
    caput(pv.me14e_pmac_str, '&2b%sr' % prog_num)
    print 'Resting2'
    lg.info('%s Resting' % (name))
    sleep(1.0)

    print 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    print '11111111111111111111111111111111'
    print caget(pv.me14e_scanstatus)
    lg.info('%s Data Collection running' % (name))
    while True:
        # me14e_gp9 is the ABORT button
        if caget(pv.me14e_gp9) == 0:
            i = 0
            text_list = ['|', '/', '-', '\\']
            while True:
                line_of_text = '\r\t\t\t Waiting   ' + 30 * ('%s' %
                                                             text_list[i % 4])
                flush_print(line_of_text)
                sleep(0.5)
                i += 1
                if caget(pv.me14e_gp9) != 0:
                    lg.warning('%s Data Collection Aborted' % (name))
                    print 50 * 'ABORTED '
                    caput(pv.me14e_pmac_str, 'A')
                    sleep(1.0)
                    caput(pv.me14e_pmac_str, 'P2401=0')
                    break
                elif caget(pv.me14e_scanstatus) == 0:
                    print caget(pv.me14e_scanstatus)
                    lg.warning('%s Data Collection Finished' % (name))
                    print '\n', 20 * 'DONE '
                    break
        #if caget(pv.pilat_acquire) == 'Done':
                #    print '\n', 20*'DONE '
                #    break
        else:
            lg.info('%s Data Collection ended due to GP 9 not equalling 0' %
                    (name))
            break
        break
    print 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    caput('BL24I-PS-SHTR-01:CON', 'Close')
    print 'Closing shutter'

    if location == 'i24':
        end_time = finish_i24()
    if location == 'SACLA':
        end_time = finish_sacla()

    lg.info('%s Chip name = %s sub_dir = %s' % (name, chip_name, sub_dir))
    print 'Start time:', start_time
    lg.info('%s Start Time = % s' % (name, start_time))
    print 'End time:  ', end_time
    lg.info('%s End Time = %s' % (name, end_time))
Пример #6
0
def start_i24():
    print 'Starting i24'
    name = inspect.stack()[0][3]
    lg.info('%s Starting i24' % name)
    start_time = time.ctime()
    run_num = caget(pv.pilat_filenumber)
    print 80 * '-', run_num
    lg.info('%s run_num = %s' % (name, run_num))
    chip_name, visit, sub_dir, n_exposures, chip_type, map_type, exptime, \
                                        dcdetdist = scrape_parameter_file(location='i24')
    sup.beamline('collect')
    print 'hello', dcdetdist, type(dcdetdist)
    #lg.info('%s dcdetdist, %s, of type %s = %s'%(name,dcdetdist, type(dcdetdist)))
    lg.info('%s Launching quickshot' % (name))
    sup.beamline('quickshot', [dcdetdist])

    if map_type == '0':
        chip_format = get_format(chip_type)[:4]
        if chip_type == '6':
            # Chip Type 6 is Custom
            print 'Calculating total number of images'
            total_numb_imgs = int(caget(pv.me14e_gp6) * caget(pv.me14e_gp7))
            lg.info('%s !!!!!! Calculating total number of images %s' %
                    (name, total_numb_imgs))
            print total_numb_imgs
        else:
            total_numb_imgs = np.prod(chip_format)

    elif map_type == '1':
        chip_format = get_format(chip_type)[2:4]
        block_count = 0
        f = open('/dls_sw/i24/scripts/fastchips/litemaps/currentchip.map', 'r')
        for line in f.readlines():
            entry = line.split()
            if entry[2] == '1':
                block_count += 1
        f.close()
        print 'block_count', block_count
        print chip_format
        lg.info('%s\t:block_count=%s' % (name, block_count))
        lg.info('%s\t:chip_format=%s' % (name, chip_format))
        ####################
        n_exposures = caget(pv.me14e_gp3)
        print n_exposures
        lg.info('%s\t:n_exposures=%s' % (name, n_exposures))
        ####################
        #total_numb_imgs = np.prod(chip_format) * block_count
        total_numb_imgs = np.prod(chip_format) * block_count * n_exposures
        print 'Total number of images', total_numb_imgs
        lg.info('%s\t:Total number of images = %s' % (name, total_numb_imgs))

    elif map_type == '2':
        lg.warning('%s\t:Not Set Up For FUll Mapping=%s' % (name))
        print 'FIX ME, Im not set up for full mapping '

    else:
        lg.warning('%s Unknown Map Type, map_type = %s' % (name, map_type))
        print 'Unknown map type'

    print 'total_numb_imgs', total_numb_imgs, '\n\n\n'
    lg.info('%s\t:----->Total number of images = %s' % (name, total_numb_imgs))
    filepath = visit + sub_dir
    filename = chip_name
    #print 'AAAAAAAAAAAAAAAAAAAAA', filepath, filename
    sup.pilatus('fastchip', [filepath, filename, total_numb_imgs, exptime])
    #sup.pilatus('fastchip-hatrx', [filepath, filename, total_numb_imgs, exptime])
    sup.zebra1('fastchip')

    print 'Acquire Region'
    lg.info('%s\t:Acquire Region' % (name))
    caput(pv.pilat_acquire, '1')  # Arm pilatus
    caput(pv.zebra1_pc_arm_out, '1')  # Arm zebra
    caput(pv.zebra1_soft_in_b1, '1')  # Open fast shutter (zebra gate)
    caput(pv.pilat_filename, filename)
    time.sleep(1.5)
    return start_time
def main(location='i24'):
    print 'Location is', location, 'Starting'
    # ABORT BUTTON
    caput(pv.me14e_gp9, 0)

    if location == 'i24':
        chip_name, visit, sub_dir, n_exposures, chip_type, map_type, exptime, \
                                        dcdetdist = scrape_parameter_file(location='i24')
        print 'exptime', exptime
        print 'visit', visit
        print 'dcdetdist', dcdetdist
    else:
        chip_name, sub_dir, n_exposures, chip_type, map_type = scrape_parameter_file(
            location='SACLA')

    print '\n\nChip name is', chip_name
    print 'sub_dir', sub_dir
    print 'n_exposures', n_exposures
    print 'chip_type', chip_type
    print 'map type', map_type
    print 'Getting Prog Dictionary'
    #### Hack for sacla3 to bismuth chip type for oxford inner
    lg.info('CHIP_COLLECT\tMain:Hack for SACLA3')
    if str(chip_type) == '3':
        chip_type = '1'
    if location == 'i24':
        chip_prog_dict = get_chip_prog_values(chip_type,
                                              location,
                                              exptime=exptime,
                                              n_exposures=n_exposures)
    else:
        chip_prog_dict = get_chip_prog_values(chip_type,
                                              location,
                                              n_exposures=n_exposures)
    print 'Loading Motion Program Data'
    load_motion_program_data(chip_prog_dict, map_type)

    if location == 'i24':
        start_time = start_i24()
    elif location == 'SACLA':
        start_time = start_sacla()
    else:
        print 'Something here... start_time = start_sacla()'
        #caput('ME14E-DI-CAM-01:CAM:Acquire', 'Done')
        #caput('ME14E-DI-CAM-03:CAM:Acquire', 'Done')

    print 'Moving to Start'
    caput(pv.me14e_pmac_str, '!x0y0z0')
    sleep(3.5)

    prog_num = get_prog_num(chip_type, map_type)
    print 'Resting'
    sleep(1.0)
    print 'pmacing'
    caput(pv.me14e_pmac_str, '&2b%sr' % prog_num)
    print 'Resting'
    sleep(1.0)

    while True:
        # me14e_gp9 is the ABORT button
        if caget(pv.me14e_gp9) == 0:
            i = 0
            text_list = ['|', '/', '-', '\\']
            while True:
                line_of_text = '\r\t\t\t Waiting   ' + 30 * ('%s' %
                                                             text_list[i % 4])
                flush_print(line_of_text)
                sleep(0.5)
                i += 1
                if caget(pv.me14e_gp9) != 0:
                    print 50 * 'ABORTED '
                    caput(pv.me14e_pmac_str, 'A')
                    sleep(1.0)
                    caput(pv.me14e_pmac_str, 'P2401=0')
                    break
                if caget(pv.me14e_scanstatus) == 0:
                    print '\n', 20 * 'DONE '
                    break
        #if caget(pv.pilat_acquire) == 'Done':
                #    print '\n', 20*'DONE '
                #    break
        else:
            break
        break

    if location == 'i24':
        end_time = finish_i24()
    if location == 'SACLA':
        end_time = finish_sacla()

    print 'Start time:', start_time
    print 'End time:  ', end_time
Пример #8
0
        caput(pv.me14e_pmac_str, s)
        sleep(0.02)
    sleep(0.2)
    print 'done'
	lg.info('%s done'%name)

def start_i24():
    print 'Starting i24'
	name = inspect.stack()[0][3]
	lg.info('%s Starting i24'%name)
    start_time = time.ctime()
    run_num = caget(pv.pilat_filenumber)
    print 80*'-', run_num
	lg.info('%s run_num = %s'%(name,run_num))
    chip_name, visit, sub_dir, n_exposures, chip_type, map_type, exptime, \
                                        dcdetdist = scrape_parameter_file(location='i24')
    sup.beamline('collect')
    print 'hello', dcdetdist, type(dcdetdist)
	lg.info('%s dcdetdist, %s, of type %s = %s'%(name,dcdetdist, type(dcdetdist)))
	lg.info('%s Launching quickshot'%(name))
    sup.beamline('quickshot', [dcdetdist])

    if map_type == '0':
        chip_format = get_format(chip_type)[:4]
        total_numb_imgs = np.prod(chip_format)

    elif map_type == '1':
        chip_format = get_format(chip_type)[2:4]
        block_count = 0
        f = open('/dls_sw/i24/scripts/fastchips/litemaps/currentchip.map', 'r')
        for line in f.readlines():