def test_wavelength_theta_inversion(): logger.debug('test_wavelength_theta_inversion') wavelength = ccm.theta_to_wavelength(SAMPLE_THETA, ccm.default_dspacing) theta = ccm.wavelength_to_theta(wavelength, ccm.default_dspacing) logger.debug('%s, %s', wavelength, theta) assert np.isclose(theta, SAMPLE_THETA) theta = ccm.wavelength_to_theta(SAMPLE_WAVELENGTH, ccm.default_dspacing) wavelength = ccm.theta_to_wavelength(theta, ccm.default_dspacing) logger.debug('%s, %s', wavelength, theta) assert np.isclose(wavelength, SAMPLE_WAVELENGTH)
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)
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)