Exemplo n.º 1
0
def test_ccm_calc(fake_ccm):
    logger.debug('test_ccm_calc')
    calc = fake_ccm.energy

    logger.debug('physics pos is %s', calc.position)
    logger.debug('real pos is %s', calc.real_position)
    logger.debug('sample alio is %s', SAMPLE_ALIO)

    theta_func = ccm.alio_to_theta(
        SAMPLE_ALIO,
        calc.theta0_rad_val,
        calc.gr_val,
        calc.gd_val,
    )
    wavelength_func = ccm.theta_to_wavelength(theta_func, calc.dspacing_val)
    energy_func = ccm.wavelength_to_energy(wavelength_func)
    energy = calc.energy.position
    assert energy == energy_func

    calc.alio.move(0)
    calc.move(energy, wait=False)
    assert np.isclose(calc.alio.position, SAMPLE_ALIO)

    calc.alio.move(calc.alio.position)
    calc.move(energy=calc.energy.position, wait=False)
    assert np.isclose(calc.alio.position, SAMPLE_ALIO)
Exemplo n.º 2
0
def test_theta_alio_inversion():
    logger.debug('test_theta_alio_inversion')
    theta = ccm.alio_to_theta(SAMPLE_ALIO, ccm.default_theta0, ccm.default_gr,
                              ccm.default_gd)
    alio_calc = ccm.theta_to_alio(theta, ccm.default_theta0, ccm.default_gr,
                                  ccm.default_gd)
    # Unlike the other inversions, this is just an approximation
    assert np.isclose(alio_calc, SAMPLE_ALIO)
Exemplo n.º 3
0
def test_ccm_calc(fake_ccm):
    logger.debug('test_ccm_calc')
    calc = fake_ccm.calc

    logger.debug('physics pos is %s', calc.position)
    logger.debug('real pos is %s', calc.real_position)
    logger.debug('sample alio is %s', SAMPLE_ALIO)

    theta = calc.theta.position
    theta_func = ccm.alio_to_theta(SAMPLE_ALIO, calc.theta0, calc.gr, calc.gd)
    assert theta == theta_func * 180 / np.pi

    wavelength = calc.wavelength.position
    wavelength_func = ccm.theta_to_wavelength(theta * np.pi / 180,
                                              calc.dspacing)
    assert wavelength == wavelength_func

    energy = calc.energy.position
    energy_func = ccm.wavelength_to_energy(wavelength)
    assert energy == energy_func

    calc.alio.readback.sim_put(0)
    calc.alio.setpoint.sim_put(0)
    calc.move(energy, wait=False)
    assert np.isclose(calc.alio.setpoint.get(), SAMPLE_ALIO)

    calc.alio.readback.sim_put(0)
    calc.alio.setpoint.sim_put(0)
    calc.move(wavelength=wavelength, wait=False)
    assert np.isclose(calc.alio.setpoint.get(), SAMPLE_ALIO)

    calc.alio.readback.sim_put(0)
    calc.alio.setpoint.sim_put(0)
    calc.move(theta=theta, wait=False)
    assert np.isclose(calc.alio.setpoint.get(), SAMPLE_ALIO)

    calc.alio.readback.sim_put(calc.alio.setpoint.get())
    calc.move(energy=calc.energy.position,
              wavelength=calc.wavelength.position,
              theta=calc.theta.position,
              wait=False)
    assert np.isclose(calc.alio.setpoint.get(), SAMPLE_ALIO)