コード例 #1
0
ファイル: rj_phi_spacing.py プロジェクト: xia2/trashcan
def phi_spacing(labelit_log):

    beam, lattice, metric, cell, image = rj_parse_labelit_log_file(labelit_log)
    template, directory = rj_get_template_directory(image)
    images = rj_find_matching_images(image)
    phi = rj_get_phi(image)

    if lattice == 'aP':
        raise RuntimeError, 'triclinic lattices useless'

    # then copy the dataset_preferences.py somewhere safe

    if os.path.exists('dataset_preferences.py'):
        shutil.copyfile('dataset_preferences.py',
                        'dataset_preferences.bak')

    # write out a dataset preferences file

    fout = open('dataset_preferences.py', 'w')
    fout.write('beam = (%f, %f)\n' % beam)
    fout.write('wedgelimit = 3\n')
    fout.write('beam_search_scope = 1.0\n')
    fout.close()

    # generate the list of phi values...

    phis = [float(j + 1) for j in range(5, 45)]

    image_numbers = []

    for p in phis:
        result = calculate_images(images, phi, p)
        if not result in image_numbers:
            image_numbers.append(result)

    # now run labelit with phi spacing 6-45

    metrics = []
    spacings = []

    for i_n in image_numbers:
        spacing = phi * (i_n[2] - i_n[1])
        image_names = [rj_image_name(template, directory, i) for i in i_n]
        output = rj_run_job('labelit.screen --index_only',
                            image_names, [])
        b, l, m, c, i = rj_parse_labelit_log(output)

        if l != lattice:
            raise RuntimeError, 'incorrect result with %d images' % (count + 1)

        metrics.append(m)
        spacings.append(spacing)

    if os.path.exists('dataset_preferences.bak'):
        shutil.copyfile('dataset_preferences.bak', 'dataset_preferences.py')

    return metrics, spacings
コード例 #2
0
ファイル: rj_no_images.py プロジェクト: xia2/trashcan
def no_images(labelit_log):
    # first parse this

    beam, lattice, metric, cell, image = rj_parse_labelit_log_file(labelit_log)
    template, directory = rj_get_template_directory(image)
    images = rj_find_matching_images(image)
    phi = rj_get_phi(image)

    if lattice == 'aP':
        raise RuntimeError, 'triclinic lattices useless'

    # then copy the dataset_preferences.py somewhere safe

    if os.path.exists('dataset_preferences.py'):
        shutil.copyfile('dataset_preferences.py',
                        'dataset_preferences.bak')

    # write out a dataset preferences file

    fout = open('dataset_preferences.py', 'w')
    fout.write('beam = (%f, %f)\n' % beam)
    fout.write('wedgelimit = 15\n')
    fout.write('beam_search_scope = 1.0\n')
    fout.close()

    # now run labelit with 1 - 15 images

    metrics = []
    times = []

    for count in range(15):
        result = calculate_images(images, phi, count + 1)
        image_names = [rj_image_name(template, directory, i) for i in result]

        t0 = time.time()
        output = rj_run_job('labelit.screen --index_only',
                            image_names, [])
        t1 = time.time()

        times.append((t1 - t0))
        
        b, l, m, c, i = rj_parse_labelit_log(output)

        if l != lattice:
            raise RuntimeError, 'incorrect result with %d images' % (count + 1)

        metrics.append(m)

    if os.path.exists('dataset_preferences.bak'):
        shutil.copyfile('dataset_preferences.bak', 'dataset_preferences.py')

    return metrics, times