Beispiel #1
0
def test_gaussianrs_mask_calculator(data):
  from dials.algorithms.integration.parallel_integrator import MaskCalculatorFactory
  algorithm = MaskCalculatorFactory.create(data.experiments)
  reflections = flex.reflection_table_to_list_of_reflections(data.reflections)

  for r in reflections:
    algorithm(r, False)
Beispiel #2
0
def test_gaussianrs_detector_space_with_deconvolution_intensity_calculator2(
        data):
    from scitbx import matrix

    reflections = flex.reflection_table_to_list_of_reflections(
        data.reflections)

    R = None
    for r in reflections:
        if r.get("partiality") > 0.9 and r.get("intensity.sum.value") > 100:
            R = r
            break
    assert R is not None

    px = R.get("xyzcal.px")
    mm = R.get("xyzcal.mm")

    px1 = (px[0] - 3, px[1] - 3, px[2])
    px2 = (px[0] + 3, px[1] + 3, px[2])
    mm1 = (mm[0] - 3 * 0.172, mm[1] - 3 * 0.172, mm[2])
    mm2 = (mm[0] + 3 * 0.172, mm[1] + 3 * 0.172, mm[2])

    s11 = matrix.col(data.experiments[0].detector[0].get_pixel_lab_coord(
        px1[0:2])).normalize()
    s12 = matrix.col(data.experiments[0].detector[0].get_pixel_lab_coord(
        px2[0:2])).normalize()

    R1 = R.copy()
    R2 = R.copy()

    R1.set_vec3_double("xyzcal.px", px1)
    R1.set_vec3_double("xyzcal.mm", mm1)
    R1.set_vec3_double("s1", s11)

    R2.set_vec3_double("xyzcal.px", px2)
    R2.set_vec3_double("xyzcal.mm", mm2)
    R2.set_vec3_double("s1", s12)

    compute_intensity = IntensityCalculatorFactory.create(data,
                                                          detector_space=True,
                                                          deconvolution=False)

    compute_intensity(R, [])
    R.set_double("intensity.prf.value.old", R.get("intensity.prf.value"))
    R.set_double("intensity.prf.variance.old", R.get("intensity.prf.variance"))

    R_no_deconvolution = R.copy()
    # print "Partiality", R.get("partiality")
    # print "Partiality Old", R.get("partiality_old")
    # print "Intensity", R.get("intensity.prf.value")
    # print "Intensity Old", R.get("intensity.prf.value.old")

    from dials.algorithms.integration.parallel_integrator import MaskCalculatorFactory

    mask_calculator = MaskCalculatorFactory.create(data.experiments)

    mask_calculator(R1, True)
    mask_calculator(R2, True)

    # print R.get("shoebox").mask.as_numpy_array()[0,:,:]

    compute_intensity = IntensityCalculatorFactory.create(data,
                                                          detector_space=True,
                                                          deconvolution=True)

    compute_intensity(R, [R1, R2])
    # compute_intensity(R, [R1, R2])

    R_deconvolution = R.copy()

    partiality1 = R_no_deconvolution.get("partiality")
    partiality2 = R_deconvolution.get("partiality")
    intensity = R_deconvolution.get("intensity.prf.value")
    variance = R_deconvolution.get("intensity.prf.variance")

    assert partiality1 <= partiality2

    assert abs(intensity - 179.05997142249996) < 1e-7
    assert abs(variance - 203.56992949599677) < 1e-7