def scale_single_dataset(reflection_table, experiment, params=None, model="physical"): """Determine scale factors for a single dataset. Requires a reflection table and an ExperimentList with a single experiment. A custom params option can be specified, if not the default scaling params option will be used, with default configuration options. The model can be individually specified. Returns the reflection table, with added columns 'inverse_scale_factor' and 'inverse_scale_factor_variance'.""" if not params: phil_scope = phil.parse( """ include scope dials.algorithms.scaling.model.model.model_phil_scope 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) params, _ = optionparser.parse_args(args=[], quick_parse=True) params.model = model from dials.algorithms.scaling.scaler_factory import SingleScalerFactory experiments = create_scaling_model(params, experiment, [reflection_table]) scaler = SingleScalerFactory.create(params, experiments[0], reflection_table) from dials.algorithms.scaling.algorithm import scaling_algorithm scaler = scaling_algorithm(scaler) return scaler.reflection_table
def run_scaling_cycle(self): """Do a round of scaling for scaling and filtering.""" # Turn off the full matrix round, all else is the same. initial_full_matrix = self.params.scaling_options.full_matrix self.scaler.params.scaling_options.full_matrix = False self.scaler = scaling_algorithm(self.scaler) self.scaler.params.scaling_options.full_matrix = initial_full_matrix self.remove_unwanted_datasets() self.scaled_miller_array = scaled_data_as_miller_array( self.reflections, self.experiments, anomalous_flag=False) try: self.calculate_merging_stats() except DialsMergingStatisticsError as e: logger.info(e) logger.info("Performed cycle of scaling.")
def scale(self): """The main scaling algorithm.""" if self.scaler.id_ == "target": ### FIXME add in quick prescaling round if large scale difference? self.scaler.perform_scaling() if (self.params.scaling_options.only_target or self.params.scaling_options.target_model or self.params.scaling_options.target_mtz): self.scaler = targeted_scaling_algorithm(self.scaler) return # Now pass to a multiscaler ready for next round of scaling. self.scaler.expand_scales_to_all_reflections() self.scaler = MultiScalerFactory.create_from_targetscaler( self.scaler) # From here onwards, scaler should only be a SingleScaler # or MultiScaler (not TargetScaler). self.scaler = scaling_algorithm(self.scaler)