Exemplo n.º 1
0
def test_check_and_fix(tc):

    n_det = tc.det_param.num_free()
    n_beam = tc.s0_param.num_free()
    n_xlo = tc.xlo_param.num_free()
    n_xluc = tc.xluc_param.num_free()

    # Similar to test_check_and_fail, setting 137 reflections as the minimum
    # should leave all parameters free
    options = ar_phil_scope.extract()
    options.min_nref_per_parameter = 137
    ar = AutoReduce(
        options,
        [tc.det_param],
        [tc.s0_param],
        [tc.xlo_param],
        [tc.xluc_param],
        gon_params=[],
        reflection_manager=tc.refman,
    )
    ar.check_and_fix()

    assert ar.det_params[0].num_free() == n_det == 6
    assert ar.beam_params[0].num_free() == n_beam == 3
    assert ar.xl_ori_params[0].num_free() == n_xlo == 3
    assert ar.xl_uc_params[0].num_free() == n_xluc == 6

    # Setting 138 reflections as the minimum should fix all the detector
    # parameters and remove that parameterisation. The crystal unit cell also
    # has 6 parameters, but each parameter is considered separately, so the
    # critical minimum number of reflections is 138*1 not 138*6 in that case
    options = ar_phil_scope.extract()
    options.min_nref_per_parameter = 138
    ar = AutoReduce(
        options,
        [tc.det_param],
        [tc.s0_param],
        [tc.xlo_param],
        [tc.xluc_param],
        gon_params=[],
        reflection_manager=tc.refman,
    )
    ar.check_and_fix()

    assert not ar.det_params
    assert ar.xl_uc_params[0].num_free() == n_xluc
    assert ar.beam_params[0].num_free() == n_beam
    assert ar.xl_ori_params[0].num_free() == n_xlo
Exemplo n.º 2
0
def test_check_and_fix(tc):

    n_det = tc.det_param.num_free()
    n_beam = tc.s0_param.num_free()
    n_xlo = tc.xlo_param.num_free()
    n_xluc = tc.xluc_param.num_free()

    # Similar to test_check_and_fail, setting 792 reflections as the minimum
    # should leave all parameters free
    options = ar_phil_scope.extract()
    options.min_nref_per_parameter = 792
    ar = AutoReduce(options,
                    pred_param=tc.pred_param,
                    reflection_manager=tc.refman)
    ar.check_and_fix()

    det_params = tc.pred_param.get_detector_parameterisations()
    beam_params = tc.pred_param.get_beam_parameterisations()
    xl_ori_params = tc.pred_param.get_crystal_orientation_parameterisations()
    xl_uc_params = tc.pred_param.get_crystal_unit_cell_parameterisations()
    assert det_params[0].num_free() == n_det == 6
    assert beam_params[0].num_free() == n_beam == 3
    assert xl_ori_params[0].num_free() == n_xlo == 3
    assert xl_uc_params[0].num_free() == n_xluc == 6

    # Setting 793 reflections as the minimum should fix crystal unit cell
    # parameters g_param_0, g_param_3 and g_param_4
    options = ar_phil_scope.extract()
    options.min_nref_per_parameter = 793
    ar = AutoReduce(options,
                    pred_param=tc.pred_param,
                    reflection_manager=tc.refman)
    ar.check_and_fix()

    det_params = tc.pred_param.get_detector_parameterisations()
    beam_params = tc.pred_param.get_beam_parameterisations()
    xl_ori_params = tc.pred_param.get_crystal_orientation_parameterisations()
    xl_uc_params = tc.pred_param.get_crystal_unit_cell_parameterisations()
    assert det_params[0].num_free() == n_det
    assert xl_uc_params[0].num_free() == 3
    assert xl_uc_params[0].get_param_names() == [
        "g_param_1", "g_param_2", "g_param_5"
    ]
    assert beam_params[0].num_free() == n_beam
    assert xl_ori_params[0].num_free() == n_xlo