def export(self): """ Export the files """ from dials.util import best experiment = self.experiments[0] reflections = self.reflections[0] partiality = reflections["partiality"] sel = partiality >= self.params.min_partiality logger.info( "Selecting %s/%s reflections with partiality >= %s", sel.count(True), sel.size(), self.params.min_partiality, ) if sel.count(True) == 0: raise Sorry( "No reflections remaining after filtering for minimum partiality (min_partiality=%f)" % (self.params.min_partiality) ) reflections = reflections.select(sel) imageset = experiment.imageset prefix = self.params.output.prefix best.write_background_file( "%s.dat" % prefix, imageset, n_bins=self.params.n_bins ) best.write_integrated_hkl(prefix, reflections) best.write_par_file("%s.par" % prefix, experiment)
def find_hdf5_lib(template=None): global __hdf5_lib from xia2.Applications.xia2setup import is_hdf5_name if template and not is_hdf5_name(template): return "" if __hdf5_lib: return __hdf5_lib from xia2.Handlers.Phil import PhilIndex from dials.util import Sorry plugin_name = PhilIndex.get_python_object().xds.hdf5_plugin if os.path.isabs(plugin_name): if not os.path.exists(plugin_name): raise Sorry("Cannot find plugin %s" % plugin_name) __hdf5_lib = "LIB=%s\n" % plugin_name return __hdf5_lib for d in os.environ["PATH"].split(os.pathsep): if os.path.exists(os.path.join(d, plugin_name)): __hdf5_lib = "LIB=%s\n" % os.path.join(d, plugin_name) return __hdf5_lib return ""
def run(args): from dials.util import Sorry usage = "dials.augment_spots [options] [models.expt] strong.refl" parser = OptionParser( usage=usage, phil=phil_scope, read_reflections=True, read_experiments=True, check_format=False, epilog=help_message, ) params, options = parser.parse_args(show_diff_phil=True) reflections, experiments = reflections_and_experiments_from_files( params.input.reflections, params.input.experiments) if len(reflections) != 1: parser.print_help() return if len(experiments) > 1: raise Sorry("0, 1 experiments required") stronger = augment_reflections(reflections[0], params, experiments=experiments) stronger.as_file(params.output.reflections)
def run(args): usage = "dials.estimate_gain [options] models.expt" parser = OptionParser( usage=usage, phil=phil_scope, read_experiments=True, check_format=True, read_experiments_from_images=True, epilog=help_message, ) params, options = parser.parse_args(show_diff_phil=False) # Log the diff phil diff_phil = parser.diff_phil.as_str() if diff_phil != "": print("The following parameters have been modified:\n") print(diff_phil) experiments = flatten_experiments(params.input.experiments) if len(experiments) == 0: parser.print_help() return elif len(experiments) > 1: raise Sorry("Only one experiment can be processed at a time") else: imagesets = experiments.imagesets() assert len(imagesets) == 1 imageset = imagesets[0] estimate_gain(imageset, params.kernel_size, params.output.gain_map, params.max_images)
def error_python_traceback(records): traceback_mode = False error_message_mode = False buf = [] tracebacks = [] error_messages = [] for line in records: if "Traceback (most recent call last)" in line: traceback_mode = True # continue if traceback_mode and not ( line.startswith(tuple(string.whitespace)) or line.startswith("Traceback") ): traceback_mode = False error_message_mode = True tracebacks.append("".join(buf)) buf = [] if error_message_mode and len(line) < 5: error_message_mode = False error_messages.append("".join(buf)) buf = [] if traceback_mode or error_message_mode: if len(line) > 400: line = line[:400] + "...\n" buf.append(line) if error_messages: from dials.util import Sorry raise Sorry(error_messages[0])
def assert_single_sequence(self, experiments, params): """ Print an error message if more than 1 sequence """ sequences = [ e.imageset for e in experiments if isinstance(e.imageset, ImageSequence) ] if len(sequences) > 1: # Print some info about multiple sequences self.diagnose_multiple_sequences(sequences, params) # Raise exception raise Sorry( """ More than 1 sequence was found. Two things may be happening here: 1. There really is more than 1 sequence. If you expected this to be the case, set the parameter allow_multiple_sequences=True. If you don't expect this, then check the input to dials.import. 2. There may be something wrong with your image headers (for example, the rotation ranges of each image may not match up). You should investigate what went wrong, but you can force dials.import to treat your images as a single sequence by using the template=image_####.cbf parameter (see help). """ )
def try_read_reflections(self, args, verbose): """Try to import reflections. :param args: The input arguments :param verbose: Print verbose output :returns: Unhandled arguments """ unhandled = [] for argument in args: try: if not os.path.exists(argument): raise Sorry("File %s does not exist" % argument) self.reflections.append( FilenameDataWrapper( filename=argument, data=flex.reflection_table.from_file(argument), )) except pickle_errors: self._handle_converter_error( argument, pickle.UnpicklingError( "Appears to be an invalid pickle file"), type="Reflections", validation=True, ) unhandled.append(argument) except Exception as e: self._handle_converter_error(argument, e, type="Reflections") unhandled.append(argument) return unhandled
def load_image(self, file_name_or_data): """The load_image() function displays the image from @p file_name_or_data. The chooser is updated appropriately. """ key = self.get_key(file_name_or_data) if type(file_name_or_data) is dict: self._img = rstbx.viewer.image(file_name_or_data) else: try: self._img = rstbx.viewer.image(key) except IOError: raise Sorry(( "The file '%s' could not be recognized as a supported " + "image format; please make sure it is actually a detector image." ) % key) # Update the selection in the chooser. i = self.add_file_name_or_data(file_name_or_data) self.image_chooser.SetSelection(i) self.viewer.set_image(self._img) if self.settings_frame is not None: self.settings_frame.set_image(self._img) self.SetTitle(to_unicode(key)) self.update_statusbar() self.Layout()
def __init__( self, experiments, reflections, dendrogram=False, threshold=1000, n_max=None ): try: from xfel.clustering.cluster import Cluster from xfel.clustering.cluster_groups import unit_cell_info except ImportError: raise Sorry("clustering is not configured") import matplotlib.pyplot as plt ucs = Cluster.from_expts( refl_table=reflections, expts_list=experiments, n_images=n_max ) self.clusters, _ = ucs.ab_cluster( threshold=threshold, log=True, # log scale ax=plt.gca() if dendrogram else None, write_file_lists=False, schnell=False, doplot=dendrogram, ) print(unit_cell_info(self.clusters)) self.clustered_frames = { int(c.cname.split("_")[1]): c.members for c in self.clusters } if dendrogram: plt.tight_layout() plt.show()
def run(args=None): usage = "dials.generate_distortion_maps [options] image_*.cbf" parser = OptionParser( usage=usage, phil=scope, read_experiments=True, read_experiments_from_images=True, check_format=False, epilog=help_message, ) params, options = parser.parse_args(args) # Configure the logging log.config(verbosity=options.verbose, logfile=params.output.log) logger.info(dials_version()) # Log the diff phil diff_phil = parser.diff_phil.as_str() if diff_phil != "": logger.info("The following parameters have been modified:\n") logger.info(diff_phil) experiments = flatten_experiments(params.input.experiments) if len(experiments) == 0: parser.print_help() exit() assert len(experiments) == 1 imagesets = experiments.imagesets() assert len(imagesets) == 1 imageset = imagesets[0] if params.mode == "translate": op = params.translate logger.info(f"Generating translation map with dx={op.dx}, dy={op.dy}") dx, dy = make_dx_dy_translate(imageset, op.dx, op.dy) elif params.mode == "ellipse": op = params.ellipse logger.info("Generating elliptical map with phi={}, l1={}, " "l2={}, centre_xy={},{}".format(op.phi, op.l1, op.l2, *op.centre_xy)) dx, dy = make_dx_dy_ellipse(imageset, op.phi, op.l1, op.l2, op.centre_xy) else: raise Sorry("Unrecognised mode") logger.info(f"Saving X distortion map to {params.output.x_map}") with open(params.output.x_map, "wb") as f: pickle.dump(dx, f, pickle.HIGHEST_PROTOCOL) logger.info(f"Saving Y distortion map to {params.output.y_map}") with open(params.output.y_map, "wb") as f: pickle.dump(dy, f, pickle.HIGHEST_PROTOCOL)
def blank_counts_analysis(reflections, scan, phi_step, fractional_loss): if not len(reflections): raise Sorry("Input contains no reflections") xyz_px = reflections["xyzobs.px.value"] x_px, y_px, z_px = xyz_px.parts() phi = scan.get_angle_from_array_index(z_px) osc = scan.get_oscillation()[1] n_images_per_step = iceil(phi_step / osc) phi_step = n_images_per_step * osc array_range = scan.get_array_range() phi_min = scan.get_angle_from_array_index(array_range[0]) phi_max = scan.get_angle_from_array_index(array_range[1]) assert phi_min <= flex.min(phi) assert phi_max >= flex.max(phi) n_steps = int(round((phi_max - phi_min) / phi_step)) hist = flex.histogram( z_px, data_min=array_range[0], data_max=array_range[1], n_slots=n_steps ) logger.debug("Histogram:") logger.debug(hist.as_str()) counts = hist.slots() fractional_counts = counts.as_double() / flex.max(counts) potential_blank_sel = fractional_counts <= fractional_loss xmin, xmax = zip( *[ (slot_info.low_cutoff, slot_info.high_cutoff) for slot_info in hist.slot_infos() ] ) d = { "data": [ { "x": list(hist.slot_centers()), "y": list(hist.slots()), "xlow": xmin, "xhigh": xmax, "blank": list(potential_blank_sel), "type": "bar", "name": "blank_counts_analysis", } ], "layout": { "xaxis": {"title": "z observed (images)"}, "yaxis": {"title": "Number of reflections"}, "bargap": 0, }, } blank_regions = blank_regions_from_sel(d["data"][0]) d["blank_regions"] = blank_regions return d
def miller_array_from_mtz(unmerged_mtz): from iotbx import reflection_file_reader hkl_in = reflection_file_reader.any_reflection_file( scaled_unmerged) miller_arrays = hkl_in.as_miller_arrays(merge_equivalents=False) i_obs = None batches = None all_i_obs = [] for array in miller_arrays: labels = array.info().label_string() if array.is_xray_intensity_array(): all_i_obs.append(array) if labels == "BATCH": assert batches is None batches = array if i_obs is None: if len(all_i_obs) == 0: raise Sorry("No intensities found in %s." % file_name) elif len(all_i_obs) > 1: if params.labels is not None: from iotbx.reflection_file_utils import label_table lab_tab = label_table(all_i_obs) i_obs = lab_tab.select_array( label=params.labels[0], command_line_switch="labels") if i_obs is None: raise Sorry( "Multiple intensity arrays - please specify one:\n%s" % "\n".join([ " labels=%s" % a.info().label_string() for a in all_i_obs ])) else: i_obs = all_i_obs[0] if hkl_in.file_type() == "ccp4_mtz": # need original miller indices otherwise we don't get correct anomalous # merging statistics mtz_object = hkl_in.file_content() if "M_ISYM" in mtz_object.column_labels(): indices = mtz_object.extract_original_index_miller_indices( ) i_obs = i_obs.customized_copy(indices=indices, info=i_obs.info()) return i_obs, batches
def run(): """Run the command line filtering script.""" flags = list(flex.reflection_table.flags.names.items()) flags.sort(key=itemgetter(0)) phil_scope = parse(phil_str, process_includes=True) # The script usage usage = "usage: dials.filter_reflections [options] experiment.expt" # Create the parser parser = OptionParser( usage=usage, phil=phil_scope, epilog=help_message, read_reflections=True, read_experiments=True, check_format=False, ) params, options = parser.parse_args(show_diff_phil=True) reflections = flatten_reflections(params.input.reflections) experiments = flatten_experiments(params.input.experiments) log.config(verbosity=options.verbose) if not reflections: parser.print_help() raise Sorry("No valid reflection file given") if len(reflections) != 1: parser.print_help() raise Sorry("Exactly 1 reflection file must be specified") reflections = reflections[0] # Check if any filter has been set using diff_phil filter_def = [ o for o in parser.diff_phil.objects if o.name not in ["input", "output"] ] if not filter_def: print("No filter specified. Performing analysis instead.") run_analysis(flags, reflections) else: run_filtering(params, experiments, reflections)
def __init__(self): """Check script input and return two experiments if all is okay""" import libtbx.load_env from dials.util.options import OptionParser # The script usage usage = ("usage: {0} [options] [param.phil] experiments1.expt " "experiments2.expt").format(libtbx.env.dispatcher_name) parser = OptionParser( usage=usage, phil=phil_scope, read_experiments=True, check_format=False, epilog=help_message, ) params, options = parser.parse_args(show_diff_phil=True) if len(params.input.experiments) != 2: raise Sorry("Please provide two experiment lists as input") warnmsg = ("WARNING: The {0} experiment list contains more than one " "detector. Only the first will be considered.") detector1 = params.input.experiments[0].data.detectors() if len(detector1) > 1: print(warnmsg.format("first")) detector1 = detector1[0] experiment1 = params.input.experiments[0].data[0] detector2 = params.input.experiments[1].data.detectors() if len(detector2) > 1: print(warnmsg.format("second")) detector2 = detector2[0] experiment2 = params.input.experiments[1].data[0] if len(detector1) != len(detector2): raise Sorry( "The detectors do not contain the same number of panels") self.experiment1 = experiment1 self.experiment2 = experiment2 self.params = params return
def GetImageset(self): if self._imagesets: i = self.stack_ctrl.GetSelections() frames = None if self.frame_ctrl is not None: frames = self.frame_ctrl.GetPhilValue() return self._imagesets[i], frames else: raise Sorry("No imageset selected!")
def export(self): from dials.util.export_xds_ascii import export_xds_ascii if not "profile" in params.intensity and not "sum" in params.intensity: raise Sorry( """Only intensity options containing sum or profile are compatible with export to xds_ascii format.""") if not any([ i in self.reflections for i in ["intensity.sum.value", "intensity.prf.value"] ]): raise Sorry( """Unable to find 'intensity.sum.value' or 'intensity.prf.value' columns in reflection table.""") try: export_xds_ascii(self.reflections, self.experiments, self.params) except ValueError as e: raise Sorry(e)
def extract_rotation_axes(self, experiments): axes = [] for iexp, exp in enumerate(experiments): try: axes.append(matrix.col(exp.goniometer.get_rotation_axis())) except AttributeError: raise Sorry( "Experiment with id {0} has no goniometer".format(iexp)) return axes
def __call__(self): """ Import the experiments """ # Get the experiments experiments = flatten_experiments(self.params.input.experiments) # Check we have some filenames if len(experiments) == 0: # FIXME Should probably make this smarter since it requires editing here # and in dials.import phil scope try: format_kwargs = { "dynamic_shadowing": self.params.format.dynamic_shadowing, "multi_panel": self.params.format.multi_panel, } except Exception: format_kwargs = None # Check if a template has been set and print help if not, otherwise try to # import the images based on the template input if len(self.params.input.template) > 0: importer = ExperimentListTemplateImporter( self.params.input.template, format_kwargs=format_kwargs) experiments = importer.experiments if len(experiments) == 0: raise Sorry("No experiments found matching template %s" % self.params.input.experiments) elif len(self.params.input.directory) > 0: experiments = ExperimentListFactory.from_filenames( self.params.input.directory, format_kwargs=format_kwargs) if len(experiments) == 0: raise Sorry("No experiments found in directories %s" % self.params.input.directory) else: raise Sorry("No experimetns found") # Get a list of all imagesets imageset_list = experiments.imagesets() # Return the experiments return imageset_list
def run_scaling(params, experiments, reflections): """Run scaling algorithms; stats only, cross validation or standard.""" if params.output.delete_integration_shoeboxes: for r in reflections: del r["shoebox"] if params.cross_validation.cross_validation_mode: from dials.algorithms.scaling.cross_validation.cross_validate import ( cross_validate, ) from dials.algorithms.scaling.cross_validation.crossvalidator import ( DialsScaleCrossValidator, ) cross_validator = DialsScaleCrossValidator(experiments, reflections) try: cross_validate(params, cross_validator) except ValueError as e: raise Sorry(e) logger.info( "Cross validation analysis does not produce scaling output files, rather\n" "it gives insight into the dataset. Choose an appropriate parameterisation\n" "and rerun scaling without cross_validation_mode.\n") else: script = Script(params, experiments, reflections) # Register the observers at the highest level if params.output.html: register_default_scaling_observers(script) else: register_merging_stats_observers(script) if params.filtering.method: if script.scaler.id_ != "multi": raise Sorry(""" Scaling and filtering can only be performed in multi-dataset scaling mode (not single dataset or scaling against a reference)""") register_scale_and_filter_observers(script) script.run_scale_and_filter() with open(params.filtering.output.scale_and_filter_results, "w") as f: json.dump(script.filtering_results.to_dict(), f, indent=2) else: script.run() script.export()
def __init__(self, params, experiments, reflections): """ Initialise the exporter :param params: The phil parameters :param experiments: The experiment list :param reflections: The reflection tables """ # Check the input if not experiments: raise Sorry("BEST exporter requires an experiment list") if not reflections: raise Sorry("BEST exporter require a reflection table") # Save the stuff self.params = params self.experiments = experiments self.reflections = reflections
def run(args: List[str] = None, phil: phil.scope = phil_scope) -> None: """Run the scaling from the command-line.""" usage = """Usage: dials.scale integrated.refl integrated.expt [integrated.refl(2) integrated.expt(2) ....] [options]""" parser = OptionParser( usage=usage, read_experiments=True, read_reflections=True, phil=phil, check_format=False, epilog=__doc__, ) params, options = parser.parse_args(args=args, show_diff_phil=False) if not params.input.experiments or not params.input.reflections: parser.print_help() sys.exit() reflections, experiments = reflections_and_experiments_from_files( params.input.reflections, params.input.experiments ) log.config(verbosity=options.verbose, logfile=params.output.log) logger.info(dials_version()) diff_phil = parser.diff_phil.as_str() if diff_phil: logger.info("The following parameters have been modified:\n%s", diff_phil) try: scaled_experiments, joint_table = run_scaling(params, experiments, reflections) except ValueError as e: raise Sorry(e) else: # Note, cross validation mode does not produce scaled datafiles if scaled_experiments and joint_table: logger.info( "Saving the scaled experiments to %s", params.output.experiments ) scaled_experiments.as_file(params.output.experiments) logger.info( "Saving the scaled reflections to %s", params.output.reflections ) joint_table.as_file(params.output.reflections) if params.output.unmerged_mtz: _export_unmerged_mtz(params, scaled_experiments, joint_table) if params.output.merged_mtz: _export_merged_mtz(params, scaled_experiments, joint_table) logger.info( "See dials.github.io/dials_scale_user_guide.html for more info on scaling options" )
def __init__(self, params, experiments, reflections): """ Initialise the exporter :param params: The phil parameters :param experiments: The experiment list :param reflections: The reflection tables """ # Check the input if not experiments: raise Sorry("XDS_ASCII exporter requires an experiment list") if len(reflections) != 1: raise Sorry("XDS_ASCII exporter requires 1 reflection table") # Save the input self.params = params self.experiments = experiments self.reflections = reflections[0]
def convert_to_grid_scan(self, imageset_list, params): """ Convert the imagesets to grid scans """ if params.input.grid_size is None: raise Sorry("The input.grid_size parameter is required") result = [] for imageset in imageset_list: result.append( ImageGrid.from_imageset(imageset.as_imageset(), params.input.grid_size) ) return result
def export(self): """ Export the files """ from dials.util.export_mmcif import MMCIFOutputFile outfile = MMCIFOutputFile(self.params) try: outfile.write(self.experiments, self.reflections) except ValueError as e: raise Sorry(e)
def run_dps(args): imageset, spots_mm, max_cell, params = args detector = imageset.get_detector() beam = imageset.get_beam() goniometer = imageset.get_goniometer() # max_cell: max possible cell in Angstroms; set to None, determine from data # recommended_grid_sampling_rad: grid sampling in radians; guess for now DPS = DPS_primitive_lattice( max_cell=max_cell, recommended_grid_sampling_rad=None, horizon_phil=params ) DPS.S0_vector = matrix.col(beam.get_s0()) DPS.inv_wave = 1.0 / beam.get_wavelength() if goniometer is None: DPS.axis = matrix.col((1, 0, 0)) else: DPS.axis = matrix.col(goniometer.get_rotation_axis()) DPS.set_detector(detector) # transform input into what Nick needs # i.e., construct a flex.vec3 double consisting of mm spots, phi in degrees data = flex.vec3_double() for spot in spots_mm: data.append( ( spot["xyzobs.mm.value"][0], spot["xyzobs.mm.value"][1], spot["xyzobs.mm.value"][2] * 180.0 / math.pi, ) ) logger.info("Running DPS using %i reflections" % len(data)) DPS.index( raw_spot_input=data, panel_addresses=flex.int([s["panel"] for s in spots_mm]) ) solutions = DPS.getSolutions() logger.info( "Found %i solution%s with max unit cell %.2f Angstroms." % (len(solutions), plural_s(len(solutions))[1], DPS.amax) ) if len(solutions) < 3: raise Sorry( "Not enough solutions: found %i, need at least 3" % (len(solutions)) ) return dict(solutions=flex.vec3_double([s.dvec for s in solutions]), amax=DPS.amax)
def run(args=None): """Run assign experiment identifiers from the command line.""" usage = ( """Usage: dials.assign_experiment_identifiers observations.refl models.expt""" ) parser = ArgumentParser( usage=usage, read_experiments=True, read_reflections=True, phil=phil_scope, check_format=False, epilog=help_message, ) params, _ = parser.parse_args(args=args, show_diff_phil=False) if not params.input.experiments or not params.input.reflections: parser.print_help() sys.exit() reflections, experiments = reflections_and_experiments_from_files( params.input.reflections, params.input.experiments) reflections = parse_multiple_datasets(reflections) if len(experiments) != len(reflections): raise Sorry( "Mismatched number of experiments and reflection tables found: %s & %s." % (len(experiments), len(reflections))) try: experiments, reflections = assign_unique_identifiers( experiments, reflections, params.identifiers) except ValueError as e: raise Sorry(e) print(f"assigned identifiers: {list(experiments.identifiers())}") experiments.as_file(params.output.experiments) joint_table = flex.reflection_table() for reflection_table in reflections: joint_table.extend(reflection_table) joint_table.as_file(params.output.reflections)
def process_imageset(self, imageset): rec_range = 1 / self.max_resolution if len(imageset.get_detector()) != 1: raise Sorry("This program does not support multi-panel detectors.") panel = imageset.get_detector()[0] beam = imageset.get_beam() s0 = beam.get_s0() pixel_size = panel.get_pixel_size() xlim, ylim = imageset.get_raw_data(0)[0].all() if pixel_size[0] != pixel_size[1]: raise Sorry("This program does not support non-square pixels.") # cache transformation xy = recviewer.get_target_pixels(panel, s0, xlim, ylim, self.max_resolution) s1 = panel.get_lab_coord(xy * pixel_size[0]) s1 = s1 / s1.norms() * (1 / beam.get_wavelength()) S = s1 - s0 for i in range(len(imageset)): axis = imageset.get_goniometer().get_rotation_axis() osc_range = imageset.get_scan(i).get_oscillation_range() print( f"Oscillation range: {osc_range[0]:.2f} - {osc_range[1]:.2f}") angle = (osc_range[0] + osc_range[1]) / 2 / 180 * math.pi if not self.reverse_phi: # the pixel is in S AFTER rotation. Thus we have to rotate BACK. angle *= -1 rotated_S = S.rotate_around_origin(axis, angle) data = imageset.get_raw_data(i)[0] if not self.ignore_mask: mask = imageset.get_mask(i)[0] data.set_selected(~mask, 0) recviewer.fill_voxels(data, self.grid, self.counts, rotated_S, xy, rec_range)
def __init__(self, cred_file, folder_id): try: from pydrive2.auth import ServiceAccountCredentials, GoogleAuth from pydrive2.drive import GoogleDrive except ImportError: raise Sorry("Pydrive2 not found. Try:\n$ conda install pydrive2 -c conda-forge") gauth = GoogleAuth() scope = ['https://www.googleapis.com/auth/drive'] gauth.credentials = ServiceAccountCredentials.from_json_keyfile_name( cred_file, scope ) self.drive = GoogleDrive(gauth) self.top_folder_id = folder_id
def miller_array_from_mtz(unmerged_mtz, anomalous=False, labels=None): mtz_object = iotbx.mtz.object(file_name=unmerged_mtz) miller_arrays = mtz_object.as_miller_arrays( merge_equivalents=False, anomalous=anomalous ) i_obs = None batches = None all_i_obs = [] for array in miller_arrays: labels = array.info().label_string() if array.is_xray_intensity_array(): all_i_obs.append(array) if labels == "BATCH": assert batches is None batches = array if i_obs is None: if len(all_i_obs) == 0: raise Sorry("No intensities found") elif len(all_i_obs) > 1: if labels is not None: lab_tab = label_table(all_i_obs) i_obs = lab_tab.select_array( label=labels[0], command_line_switch="labels" ) if i_obs is None: raise Sorry( "Multiple intensity arrays - please specify one:\n%s" % "\n".join( [" labels=%s" % a.info().label_string() for a in all_i_obs] ) ) else: i_obs = all_i_obs[0] # need original miller indices otherwise we don't get correct anomalous # merging statistics if "M_ISYM" in mtz_object.column_labels(): indices = mtz_object.extract_original_index_miller_indices() i_obs = i_obs.customized_copy(indices=indices, info=i_obs.info()) return i_obs, batches
def load_distl_output(self, file_name): distl = easy_pickle.load(file_name) self._distl = distl img_files = [] for img_id in sorted(distl.images.keys()): img = distl.images[img_id] img_files.append(img["relpath"]) if len(img_files) == 0: raise Sorry("No images in this result!") self.image_chooser.SetItems([os.path.basename(f) for f in img_files]) self.image_chooser.SetSelection(0) self.load_image(img_files[0]) self.annotate_image(img_files[0])