def test_find_min_max_I_simple_1D_case(self): """ test _find_min_max_I for a 1D case, it finds the minimum and maximum value to plot for a given McStasData set """ dummy_data = get_dummy_McStasData_1d() found_min, found_max = _find_min_max_I(dummy_data) # np.arange(20) + 5: min = 5, max = 5+19 = 24 self.assertEqual(found_min, 5) self.assertEqual(found_max, 19 + 5)
def test_find_min_max_I_cut_min_1D_case(self): """ test _find_min_max_I for a 1D case, it finds the minimum and maximum value to plot for a given McStasData set. Here cut_min is used to limit the minimum plotted. """ dummy_data = get_dummy_McStasData_1d() dummy_data.set_plot_options(cut_min=0.2) found_min, found_max = _find_min_max_I(dummy_data) # np.arange(20) + 5: min = 5, max = 5+19 = 24 self.assertEqual(found_min, 5 + (24 - 5) * 0.2) self.assertEqual(found_max, 19 + 5)
def test_find_min_max_I_log_orders_of_mag_2D_case(self): """ test _find_min_max_I for a 1D case, it finds the minimum and maximum value to plot for a given McStasData set. Here orders_of_mag is used to limit the minimum plotted while log mode is enabled. """ dummy_data = get_dummy_McStasData_2d() dummy_data.Intensity[2, 2] = 10**6 dummy_data.set_plot_options(log=True, orders_of_mag=3) found_min, found_max = _find_min_max_I(dummy_data) self.assertAlmostEqual(found_min, 10**3) self.assertAlmostEqual(found_max, 10**6)
def test_find_min_max_I_log_cut_max_2D_case(self): """ test _find_min_max_I for a 1D case, it finds the minimum and maximum value to plot for a given McStasData set. Here cut_max is used to limit the maximum plotted while log mode is enabled. """ dummy_data = get_dummy_McStasData_2d() dummy_data.set_plot_options(cut_max=0.8, log=True) found_min, found_max = _find_min_max_I(dummy_data) # np.arange(20) + 5: min = 5, max = 5+19 = 24 self.assertAlmostEqual(found_min, 5) self.assertAlmostEqual(found_max, (19 + 5) * 0.8)
def test_find_min_max_I_fail_case(self): """ test _find_min_max_I for a 1D case, it finds the minimum and maximum value to plot for a given McStasData set. Here orders_of_mag is used to limit the minimum plotted while log mode is enabled. A bin in the data contains zero intensity, which should be ignored. """ dummy_data = get_dummy_McStasData_2d() dummy_data.Intensity = np.zeros((5, 5)) dummy_data.set_plot_options(log=True, orders_of_mag=3) found_min, found_max = _find_min_max_I(dummy_data) self.assertEqual(found_min, 0) self.assertEqual(found_max, 0)
def test_find_min_max_I_log_with_zero_2D_case(self): """ test _find_min_max_I for a 1D case, it finds the minimum and maximum value to plot for a given McStasData set. Here a bin contains zero intensity and log mode is enabled, since log(0) is not allowed, this data point should be ignored. """ dummy_data = get_dummy_McStasData_2d() dummy_data.Intensity[2, 2] = 0 dummy_data.set_plot_options(log=True) found_min, found_max = _find_min_max_I(dummy_data) # np.arange(20) + 5: min = 5, max = 5+19 = 24 self.assertAlmostEqual(found_min, 5) self.assertAlmostEqual(found_max, 19 + 5)
def test_find_min_max_I_log_orders_of_mag_1D_with_zero_case(self): """ test _find_min_max_I for a 1D case, it finds the minimum and maximum value to plot for a given McStasData set. Here orders_of_mag is used to limit the minimum plotted while log mode is enabled. A bin in the data contains zero intensity, which should be ignored. """ dummy_data = get_dummy_McStasData_1d() dummy_data.Intensity[5] = 10**6 dummy_data.Intensity[6] = 0 dummy_data.set_plot_options(log=True, orders_of_mag=3) found_min, found_max = _find_min_max_I(dummy_data) self.assertAlmostEqual(found_min, 10**3) self.assertAlmostEqual(found_max, 10**6)