def __init__(self): """Set the expected options.""" from dials.util.options import OptionParser import libtbx.load_env # Create the option parser usage = ("usage: %s [options] /path/to/refined/json/file" % libtbx.env.dispatcher_name) self.parser = OptionParser( usage=usage, sort_options=True, phil=phil_scope, read_experiments=True, read_reflections=True, epilog=help_message, )
def run(args=None): usage = "dials.find_spots_server [options]" # Python 3.8 on macOS... needs fork if sys.hexversion >= 0x3080000 and sys.platform == "darwin": multiprocessing.set_start_method("fork") from dials.util.options import OptionParser parser = OptionParser(usage=usage, phil=phil_scope, epilog=help_message) params, options = parser.parse_args(args, show_diff_phil=True) if params.nproc is libtbx.Auto: from libtbx.introspection import number_of_processors params.nproc = number_of_processors(return_value_if_unknown=-1) main(params.nproc, params.port)
def KB_test_param(): """Generate a params phil scope.""" phil_scope = phil.parse( """ include scope dials.algorithms.scaling.scaling_options.phil_scope include scope dials.algorithms.scaling.scaling_refiner.scaling_refinery_phil_str """, process_includes=True, ) optionparser = OptionParser(phil=phil_scope, check_format=False) parameters, _ = optionparser.parse_args( args=[], quick_parse=True, show_diff_phil=False ) parameters.__inject__("model", "KB") return parameters
def __init__(self): ''' Set the expected options. ''' from dials.util.options import OptionParser import libtbx.load_env # Create the option parser usage = "usage: %s experiment1.json experiment2.json reflections1.pickle reflections2.pickle" % libtbx.env.dispatcher_name self.parser = OptionParser( usage=usage, sort_options=True, phil=phil_scope, read_experiments=True, read_datablocks=True, read_reflections=True, check_format=False, epilog=help_message)
def __init__(self): """ Initialise the script. """ from dials.util.options import OptionParser from libtbx.phil import parse import libtbx.load_env # Create the phil parameters phil_scope = parse(""" interfaces=False .type = bool .help = "Only show information about the interfaces" """) # Create the option parser usage = "usage: %s [options] /path/to/image/files" % libtbx.env.dispatcher_name self.parser = OptionParser(usage=usage, phil=phil_scope)
def generated_param(): """Generate a param phil scope.""" phil_scope = phil.parse( """ include scope dials.algorithms.scaling.scaling_options.phil_scope """, process_includes=True, ) optionparser = OptionParser(phil=phil_scope, check_format=False) parameters, _ = optionparser.parse_args( args=[], quick_parse=True, show_diff_phil=False ) parameters.__inject__("model", "KB") parameters.scaling_options.free_set_percentage = 50.0 parameters.reflection_selection.method = "use_all" return parameters
def run(args): from dials.util.options import OptionParser import libtbx.load_env import json usage = "%s [options] DSC03206.jpg" % ( libtbx.env.dispatcher_name) parser = OptionParser( usage=usage, phil=phil_scope) params, options, args = parser.parse_args(show_diff_phil=True, return_unhandled=True) correlation(args[0], args[1])
def __init__(self, phil=working_phil): """Initialise the script.""" # The script usage usage = ( "usage: dials.find_spots [options] [param.phil] " "{models.expt | image1.file [image2.file ...]}" ) # Initialise the base class self.parser = OptionParser( usage=usage, phil=phil, epilog=help_message, read_experiments_from_images=True, read_experiments=True, )
def __init__(self): """Initialise the script.""" from dials.util.options import OptionParser usage = ("usage: dials.slice_sequence [options] [param.phil] " "models.expt observations.refl") # Create the parser self.parser = OptionParser( usage=usage, phil=phil_scope, read_reflections=True, read_experiments=True, check_format=False, epilog=help_message, )
def __init__(self): '''Initialise the script.''' from dials.util.options import OptionParser import libtbx.load_env # The script usage usage = "usage: %s [options] [param.phil] " \ "experiments1.json experiments2.json reflections1.pickle " \ "reflections2.pickle..." \ % libtbx.env.dispatcher_name # Create the parser self.parser = OptionParser(usage=usage, phil=phil_scope, read_datablocks=True, epilog=help_message)
def __init__(self): """Initialise the script.""" from libtbx.phil import parse from dials.util.options import OptionParser # Create the phil parameters phil_scope = parse(""" interfaces=False .type = bool .help = "Only show information about the interfaces" """) # Create the option parser usage = "dev.dials.show_extensions [options] /path/to/image/files" self.parser = OptionParser(usage=usage, phil=phil_scope)
def generated_param(): """Generate a param phil scope.""" phil_scope = phil.parse( """ include scope dials.algorithms.scaling.scaling_options.phil_scope include scope dials.algorithms.scaling.model.model.model_phil_scope include scope dials.algorithms.scaling.scaling_refiner.scaling_refinery_phil_scope """, process_includes=True, ) optionparser = OptionParser(phil=phil_scope, check_format=False) parameters, _ = optionparser.parse_args(args=[], quick_parse=True, show_diff_phil=False) parameters.model = "KB" return parameters
def __init__(self): '''Initialise the script.''' from dials.util.options import OptionParser import libtbx.load_env self.reference_detector = None # The script usage usage = "usage: %s [options] [param.phil] datablock.json" % libtbx.env.dispatcher_name # Create the parser self.parser = OptionParser(usage=usage, phil=phil_scope, epilog=help_message, read_datablocks=True, read_datablocks_from_images=True)
def __init__(self): '''Initialise the script.''' from dials.util.options import OptionParser import libtbx.load_env # The script usage usage = "usage: %s [options] [param.phil] "\ "datablock.json" \ % libtbx.env.dispatcher_name # Initialise the base class self.parser = OptionParser(usage=usage, phil=phil_scope, epilog=help_message, read_datablocks=True, read_reflections=True)
def generated_param(): """Generate the default scaling parameters object.""" phil_scope = phil.parse( """ include scope dials.algorithms.scaling.scaling_options.phil_scope include scope dials.algorithms.scaling.model.model.model_phil_scope """, process_includes=True, ) optionparser = OptionParser(phil=phil_scope, check_format=False) parameters, _ = optionparser.parse_args(args=[], quick_parse=True, show_diff_phil=False) parameters.array.modulation_correction = True return parameters
def __init__(self): '''Initialise the script.''' from dials.util.options import OptionParser from libtbx.phil import parse import libtbx.load_env # The script usage usage = "usage: %s [options] " \ % libtbx.env.dispatcher_name # Create the parser self.parser = OptionParser(usage=usage, phil=phil_scope, epilog=help_message, check_format=True, read_experiments=True)
def parse_input(self): '''Parse input at rank 0 and broadcast the input parameters and options to all ranks''' if self.mpi_helper.rank == 0: from xfel.merging.application.phil.phil import phil_scope help_message = '''Merge xfel data.''' # The script usage import libtbx.load_env self.usage = "usage: %s [options] [param.phil] " % libtbx.env.dispatcher_name self.parser = None '''Initialize the script.''' from dials.util.options import OptionParser # Create the parser self.parser = OptionParser(usage=self.usage, phil=phil_scope, epilog=help_message) # Parse the command line. quick_parse is required for MPI compatibility params, options = self.parser.parse_args(show_diff_phil=True, quick_parse=True) # Log the modified phil parameters diff_phil_str = self.parser.diff_phil.as_str() if diff_phil_str is not "": self.mpi_logger.main_log( "The following parameters have been modified:\n%s" % diff_phil_str) # prepare for transmitting input parameters to all ranks transmitted = dict(params=params, options=options) else: transmitted = None # broadcast parameters and options to all ranks self.mpi_logger.log("Broadcasting input parameters...") self.mpi_logger.log_step_time("BROADCAST_INPUT_PARAMS") transmitted = self.mpi_helper.comm.bcast(transmitted, root=0) self.params = transmitted['params'] self.options = transmitted['options'] self.mpi_logger.set_log_file_paths(self.params) self.mpi_logger.log("Received input parameters and options") self.mpi_logger.log_step_time("BROADCAST_INPUT_PARAMS", True)
def run(args=None, phil=working_phil): usage = "dials.index [options] models.expt strong.refl" parser = OptionParser( usage=usage, phil=phil, read_reflections=True, read_experiments=True, check_format=False, epilog=help_message, ) params, options = parser.parse_args(args=args, show_diff_phil=False) # 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) reflections, experiments = reflections_and_experiments_from_files( params.input.reflections, params.input.experiments ) if len(experiments) == 0: parser.print_help() return try: indexed_experiments, indexed_reflections = index( experiments, reflections, params ) except (DialsIndexError, ValueError) as e: sys.exit(str(e)) # Save experiments logger.info("Saving refined experiments to %s", params.output.experiments) assert indexed_experiments.is_consistent() indexed_experiments.as_file(params.output.experiments) # Save reflections logger.info("Saving refined reflections to %s", params.output.reflections) indexed_reflections.as_msgpack_file(filename=params.output.reflections)
def run(args): from dials.util.options import OptionParser import libtbx.load_env import json usage = "%s [options] DSC03206.jpg" % (libtbx.env.dispatcher_name) parser = OptionParser(usage=usage, phil=phil_scope) params, options, args = parser.parse_args(show_diff_phil=True, return_unhandled=True) max_image_r = None max_image_g = None max_image_b = None from astrotbx.input_output.loader import load_image from astrotbx.input_output.saver import save_image for image in args: r, g, b = load_image(image) if max_image_r is None: max_image_r = r else: max_image_r.as_1d().copy_selected((r > max_image_r).iselection(), r.as_1d()) if max_image_g is None: max_image_g = g else: max_image_g.as_1d().copy_selected((g > max_image_g).iselection(), g.as_1d()) if max_image_b is None: max_image_b = b else: max_image_b.as_1d().copy_selected((b > max_image_b).iselection(), b.as_1d()) # output the image max_image_r *= params.scale max_image_g *= params.scale max_image_b *= params.scale save_image(params.output, max_image_r, max_image_g, max_image_b)
def run(args): from dials.util.options import OptionParser import libtbx.load_env usage = "%s [options] *ARW" % ( libtbx.env.dispatcher_name) parser = OptionParser( usage=usage, phil=phil_scope) params, options, args = parser.parse_args(show_diff_phil=True, return_unhandled=True) from astrotbx.input_output.loader import load_image_gs, load_raw_image_gs from astrotbx.algorithms.star_find import hot from dials.array_family import flex raws = ['arw'] total = None n = 0 for arg in args: n += 1 exten = arg.split('.')[-1].lower() if exten in raws: image = load_raw_image_gs(arg, params.raw) else: image = load_image_gs(arg) signal = hot(image, params).as_1d() if total is None: total = signal.as_int() else: total += signal.as_int() h_total = flex.histogram(total.as_double(), data_min=-0.5, data_max=n + 0.5, n_slots=n + 1) for c, v in zip(h_total.slot_centers(), h_total.slots()): print(c, v) total.reshape(flex.grid(*image.focus())) if params.output: import cPickle as pickle with open(params.output, 'w') as fout: pickle.dump(total, fout, protocol=pickle.HIGHEST_PROTOCOL)
def __init__(self): """ Initialise the script. """ from dials.util.options import OptionParser from libtbx.phil import parse import libtbx.load_env # Create the phil parameters phil_scope = parse(""" input { method = *experiment reflections .type = choice .help = "The input method" xds_file = None .type = str .help = "Explicitly specify the file to use" } output { filename = None .type = str .help = "The output file" xds_experiments = None .type = str .help = "Output filename of data block with xds" } remove_invalid = False .type = bool .help = "Remove non-index reflections (if miller indices are present)" add_standard_columns = False .type = bool .help = "Add empty standard columns to the reflections. Note columns" "for centroid variances are set to contain 1s, not 0s" read_varying_crystal = False .type = bool .help = "Attempt to create a scan-varying crystal model from" "INTEGRATE.LP, if present" """) # The option parser usage = ("usage: %s [options] (SPOT.XDS|INTEGRATE.HKL)" % libtbx.env.dispatcher_name) self.parser = OptionParser(usage=usage, phil=phil_scope)
def physical_param(): """Generate the scaling phil param scope.""" phil_scope = phil.parse( """ include scope dials.algorithms.scaling.model.model.model_phil_scope include scope dials.algorithms.scaling.scaling_options.phil_scope """, process_includes=True, ) optionparser = OptionParser(phil=phil_scope, check_format=False) parameters, _ = optionparser.parse_args(args=[], quick_parse=True, show_diff_phil=False) parameters.model = "physical" parameters.physical.absorption_correction = False return parameters
def __init__(self): '''Initialise the script.''' from dials.util.options import OptionParser import libtbx.load_env # The script usage usage = "usage: %s [options] [param.phil] " \ "experiments.json reflections.pickle" \ % libtbx.env.dispatcher_name # Create the parser self.parser = OptionParser(usage=usage, phil=working_phil, read_reflections=True, read_experiments=True, check_format=False, epilog=help_message)
def __init__(self): '''Initialise the script.''' from dials.util.options import OptionParser import libtbx.load_env # The script usage usage = "usage: %s map_file=output.ccp4 [max_resolution=6] [grid_size=192] "\ "[reverse_phi=False] [param.phil] "\ "{datablock.json | image1.file [image2.file ...]}" \ % libtbx.env.dispatcher_name # Initialise the base class self.parser = OptionParser(usage=usage, phil=phil_scope, epilog=help_message, read_datablocks=True, read_datablocks_from_images=True)
def __init__(self): from dials.util.options import OptionParser from libtbx.phil import parse usage = "usage: %prog [options] [param.phil] " \ "sweep.json crystal.json intensities.mtz" phil_scope = parse(''' output = simulated.pickle .type = str .help = "The filename for the simulated reflections" ''') # Create the parser self.parser = OptionParser( usage=usage, phil=self.phil_scope())
def generated_param(absorption_term=False): """Generate a param phil scope.""" phil_scope = phil.parse( """ include scope dials.algorithms.scaling.scaling_options.phil_scope include scope dials.algorithms.scaling.scaling_refiner.scaling_refinery_phil_scope """, process_includes=True, ) optionparser = OptionParser(phil=phil_scope, check_format=False) parameters, _ = optionparser.parse_args(args=[], quick_parse=True, show_diff_phil=False) parameters.parameterisation.absorption_term = absorption_term parameters.parameterisation.n_resolution_bins = 1 # to stop example dataset # being overparameterised for array model refinement. return parameters
def __init__(self): '''Initialise the script.''' from dials.util.options import OptionParser import libtbx.load_env # The script usage usage = "usage: %s [options] [param.phil] filenames" % libtbx.env.dispatcher_name self.tag = None self.reference_detector = None # Create the parser self.parser = OptionParser( usage=usage, phil=phil_scope, epilog=help_message )
def __init__(self, comm): """MPI-aware constructor.""" self.comm = comm self.rank = comm.Get_rank() # each process in MPI has a unique id, 0-indexed self.size = comm.Get_size() # size: number of processes running in this job # The script usage usage = ( "usage: %s [options] [param.phil] mp.blob=<filepattern>" % libtbx.env.dispatcher_name ) self.tag = None self.reference_detector = None # Create the parser self.parser = OptionParser(usage=usage, phil=phil_scope, epilog=help_message)
def __init__(self): """Initialise the script.""" from dials.util.options import OptionParser # The script usage usage = ("usage: %s [options] experiment.expt observations.refl" % libtbx.env.dispatcher_name) # Create the parser self.parser = OptionParser( usage=usage, phil=phil_scope, epilog=help_message, read_experiments=True, read_reflections=True, )
def __init__(self): """Initialise the script.""" # The script usage usage = ( "usage: dials.two_theta_refine [options] [param.phil] " "models.expt observations.refl" ) # Create the parser self.parser = OptionParser( usage=usage, phil=working_phil, read_reflections=True, read_experiments=True, check_format=False, epilog=help_message, )