Beispiel #1
0
 def __init__(self, parameters_dict, configdict, is_scaled=False):
     """Create the phyiscal scaling model components."""
     super(PhysicalScalingModel, self).__init__(configdict, is_scaled)
     if "scale" in configdict["corrections"]:
         scale_setup = parameters_dict["scale"]
         self._components["scale"] = SmoothScaleComponent1D(
             scale_setup["parameters"], scale_setup["parameter_esds"])
     if "decay" in configdict["corrections"]:
         decay_setup = parameters_dict["decay"]
         self._components["decay"] = SmoothBScaleComponent1D(
             decay_setup["parameters"], decay_setup["parameter_esds"])
     if "absorption" in configdict["corrections"]:
         absorption_setup = parameters_dict["absorption"]
         self._components["absorption"] = SHScaleComponent(
             absorption_setup["parameters"],
             absorption_setup["parameter_esds"])
Beispiel #2
0
def test_SmoothBScaleFactor1D():
    "test for a gaussian smoothed 1D scalefactor object"
    SF = SmoothBScaleComponent1D(flex.double(5, 0.0))
    assert SF.n_params == 5
    assert list(SF.parameters) == [0.0] * 5
    norm_rot = flex.double([0.5, 1.0, 2.5, 0.0])
    d = flex.double([1.0, 1.0, 1.0, 1.0])
    SF.data = {"x": norm_rot, "d": d}
    SF.update_reflection_data()
    assert list(SF.normalised_values[0]) == [0.5, 1.0, 2.5, 0.0]
    assert list(SF.d_values[0]) == [1.0, 1.0, 1.0, 1.0]
    SF.smoother.set_smoothing(4, 1.0)
    s, d = SF.calculate_scales_and_derivatives()
    s2 = SF.calculate_scales()
    assert list(s) == list(s2)
    assert approx_equal(list(s), [1.0, 1.0, 1.0, 1.0])
    assert approx_equal(
        d[0, 0] / d[0, 1],
        exp(-1.0) /
        exp(0.0))  # derivative ratio of two adjacent params (at +-0.5)
    sumexp = exp(-1.0 / 1.0) + exp(-0.0 / 1.0) + exp(-1.0 / 1.0)
    assert approx_equal(d[0, 1], ((exp(0.0) / sumexp) * s[1] / 2.0))
    T = d.transpose()
    assert sum(list(T[:, 0].as_dense_vector())) == 0.5  # value depends on d
    assert sum(list(T[:, 1].as_dense_vector())) == 0.5
    assert sum(list(T[:, 2].as_dense_vector())) == 0.5
    assert d[1, 1] == d[1, 2]
    assert d[1, 0] == d[1, 3]
    s, d = SF.calculate_scales_and_derivatives()

    SF._normalised_values = [flex.double([0.5])]
    SF._n_refl = [1]
    SF._d_values = [flex.double([1.0])]
    assert list(SF.normalised_values[0]) == [0.5]
    s, d = SF.calculate_scales_and_derivatives()
    s2 = SF.calculate_scales()
    assert list(s) == list(s2)