예제 #1
0
def test_SingleScalerFactory(generated_param, refl_to_filter, mock_scaling_component):
    """Test the single scaler factory."""
    test_refl, exp = test_refl_and_exp(mock_scaling_component)
    # Test that all required attributes get added with standard params.
    assert all(
        (i not in test_refl) for i in ["inverse_scale_factor", "intensity", "variance"]
    )
    # Test default, (no split into free set)
    ss = SingleScalerFactory.create(generated_param, exp, test_refl)
    assert isinstance(ss, SingleScaler)
    assert all(
        i in ss.reflection_table
        for i in ["inverse_scale_factor", "intensity", "variance"]
    )

    # Test reflection filtering
    rt, reasons = SingleScalerFactory.filter_bad_reflections(refl_to_filter)
    assert list(rt.get_flags(rt.flags.excluded_for_scaling)) == [
        False,
        True,
        True,
        False,
        False,
        False,
    ]
예제 #2
0
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
예제 #3
0
def test_selection_of_profile_or_summation_intensities(generated_param,
                                                       prf_sum_refl_to_filter,
                                                       mock_scaling_component):
    _, exp = test_refl_and_exp(mock_scaling_component)
    # Test that all required attributes get added with standard params.
    assert all((i not in prf_sum_refl_to_filter)
               for i in ["inverse_scale_factor", "intensity", "variance"])
    # Test default, (no split into free set)
    ss = SingleScalerFactory.create(generated_param, exp,
                                    prf_sum_refl_to_filter)
    assert isinstance(ss, SingleScaler)
    rt = ss.reflection_table
    assert all(i in rt
               for i in ["inverse_scale_factor", "intensity", "variance"])
    assert list(rt.get_flags(rt.flags.excluded_for_scaling)) == [
        False,
        True,
        False,
        False,
        False,
    ]
    # test correct initial intensities have been chosen - should be prf then sum
    assert list(rt["intensity"]) == [11.0, 2.0, 3.0, 14.0, 15.0]