def test_GIVEN_interp_with_2D_points_based_on_setpoint_of_beamline_parameter_WHEN_request_a_point_THEN_correction_returned_for_that_point_with_interpolation_if_needed(self, value, theta, expected_correction): grid_data_provider = GridDataFileReader("Test") grid_data_provider.variables = ["driver", "Theta"] grid_data_provider.points = np.array([[1.0, 1.0], [2.0, 1.0], [3.0, 1.0], [1.0, 6.0], [2.0, 6.0], [3.0, 6.0]]) grid_data_provider.corrections = np.array([1.234, 4.0, 6.0, 2.234, 5.0, 7.0]) grid_data_provider.read = lambda: None comp = Component("param_comp", setup=PositionAndAngle(0, 0, 90)) beamline_parameter = AxisParameter("theta", comp, ChangeAxis.POSITION) beamline_parameter.sp = theta interp = InterpolateGridDataCorrectionFromProvider(grid_data_provider, beamline_parameter) result = interp.correction(value) assert_that(result, is_(close_to(expected_correction, FLOAT_TOLERANCE)))
def test_GIVEN_user_function_engineering_correction_which_adds_setpoint_and_beamline_param_WHEN_set_value_on_axis_THEN_value_is_twice_value_plus_beamline_parameter_value(self): def _test_correction(setpoint, beamline_parameter): return setpoint + beamline_parameter parameter_value = 2 comp = Component("param_comp", setup=PositionAndAngle(0, 0, 90)) beamline_parameter = AxisParameter("param", comp, ChangeAxis.POSITION) beamline_parameter.sp = parameter_value value = 1 expected_correction = value * 2 + parameter_value engineering_correction = UserFunctionCorrection(_test_correction, beamline_parameter) result = engineering_correction.to_axis(value) assert_that(result, is_(close_to(expected_correction, FLOAT_TOLERANCE)))