def test_auto_scaling_model(): params = generated_param() exp = generated_exp(scan=False) rt = generated_refl() params.__inject__("model", "auto") new_exp = create_auto_scaling_model(params, exp, [rt]) assert new_exp[0].scaling_model.id_ == "KB" params = generated_param(absorption_term=True) exp = generated_exp(image_range=[1, 5]) # 5 degree wedge params.__inject__("model", "auto") new_exp = create_auto_scaling_model(params, exp, [rt]) assert new_exp[0].scaling_model.id_ == "physical" assert len(new_exp[0].scaling_model.components["scale"].parameters) == 5 assert len(new_exp[0].scaling_model.components["decay"].parameters) == 3 assert "absorption" not in new_exp[0].scaling_model.components params = generated_param(absorption_term=True) exp = generated_exp(image_range=[1, 20]) # 20 degree wedge params.__inject__("model", "auto") new_exp = create_auto_scaling_model(params, exp, [rt]) assert new_exp[0].scaling_model.id_ == "physical" assert len(new_exp[0].scaling_model.components["scale"].parameters) == 7 assert len(new_exp[0].scaling_model.components["decay"].parameters) == 6 assert "absorption" not in new_exp[0].scaling_model.components params = generated_param(absorption_term=True) exp = generated_exp(image_range=[1, 75]) # 20 degree wedge params.__inject__("model", "auto") new_exp = create_auto_scaling_model(params, exp, [rt]) assert new_exp[0].scaling_model.id_ == "physical" assert len(new_exp[0].scaling_model.components["scale"].parameters) == 12 assert len(new_exp[0].scaling_model.components["decay"].parameters) == 10 assert "absorption" in new_exp[0].scaling_model.components # Now test overwrite_existing_models option params.overwrite_existing_models = True params.model = "KB" newer_exp = create_scaling_model(params, new_exp, [rt]) assert isinstance(newer_exp[0].scaling_model, KBScalingModel)
def _create_model_and_scaler(self): """Create the scaling models and scaler.""" if self.params.model in (None, libtbx.Auto): self.experiments = create_auto_scaling_model( self.params, self.experiments, self.reflections ) else: self.experiments = create_scaling_model( self.params, self.experiments, self.reflections ) logger.info("\nScaling models have been initialised for all experiments.") logger.info("%s%s%s", "\n", "=" * 80, "\n") self.experiments = set_image_ranges_in_scaling_models(self.experiments) self.scaler = create_scaler(self.params, self.experiments, self.reflections)