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
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
def gather(pmin, pmax, files): data = { } for j in range(1, 10): data[j + 1] = [] here = os.getcwd() for f in files: # hack to get the image name, so that I can then get (and test) the # phi range... directory = os.path.split(f)[0] os.chdir(directory) output = rj_run_job('labelit.stats_index', [], []) os.chdir(here) b, l, m, c, i = rj_parse_labelit_log(output) phi = rj_get_phi(i) if phi < pmin or phi > pmax: continue records = open(f, 'r').readlines() if not len(records) == 9: continue for r in records: s = r.split() n = int(s[0]) m = float(s[1]) data[n].append(m) for j in range(1, 10): positive_data = [] for d in data[j + 1]: if d > 0: positive_data.append(d) m, s = meansd(positive_data) print '%d %.3f %.3f' % (j + 1, m, s) print '%d points' % len(data[2])