def create(cls, experiments, params=None): """ Select the reference calculator """ from dials.algorithms.profile_model.gaussian_rs.algorithm import ( GaussianRSReferenceCalculatorFactory, ) # Get the parameters if params is None: from dials.command_line.integrate import phil_scope params = phil_scope.extract() # Select the factory function selection = params.profile.algorithm if selection == "gaussian_rs": # Get the parameters params = params.profile.gaussian_rs.fitting # Create the algorithm algorithm = GaussianRSReferenceCalculatorFactory.create( experiments, grid_size=params.grid_size, scan_step=params.scan_step, grid_method=params.grid_method, ) else: raise RuntimeError("Unknown profile model algorithm") # Return the algorithm return algorithm
def test_gaussianrs_reference_profile_calculator(data): from dials.algorithms.profile_model.gaussian_rs.algorithm import ( GaussianRSReferenceCalculatorFactory, ) algorithm = GaussianRSReferenceCalculatorFactory.create(data.experiments) reflections = flex.reflection_table_to_list_of_reflections( data.reflections) count = 0 for r in reflections: try: algorithm(r) except Exception: count += 1 assert len(reflections) == 15193 assert count == 0 profiles = algorithm.reference_profiles() count = 0 for i in range(len(profiles)): p = profiles[i].reference() for j in range(len(p)): d = p.data(j) p.mask(j) if len(d) != 0: count += 1 assert count == 9