def test_dispersion_for_horizontally_aligned_trace(self, horizontal_trace): spt = SpectralTrace(horizontal_trace) disp, wave = spt.get_max_dispersion() dx = np.abs(np.diff(horizontal_trace["x"])) dw = np.abs(np.diff(horizontal_trace["wavelength"])) assert np.average(disp) == approx(np.average(dx / dw), rel=1e-5)
def test_mtc_one_pixel_apart_for_diagonal_traces(self, diagonal_trace): pixel_size = 0.015 spt = SpectralTrace(diagonal_trace) disp, wave = spt.get_max_dispersion() wave_edges = spt.get_pixel_wavelength_edges( pixel_size) # wavelength edges dist_between_mtc = np.average(disp) * np.average(np.diff(wave_edges)) assert dist_between_mtc == approx(pixel_size, rel=1e-5)
def test_monochromatic_trace_curves_are_one_pixel_apart(self, basic_trace): pixel_size = 0.015 spt = SpectralTrace(basic_trace) disp, wave = spt.get_max_dispersion() wbedges = spt.get_pixel_wavelength_edges( pixel_size) # wavelength edges dist_between_mtc = np.average(disp) * np.average(np.diff(wbedges)) assert dist_between_mtc == approx(pixel_size, rel=1e-5)
def test_dispersion_for_vertically_aligned_trace(self, basic_trace): # ..todo: accuracy of get_max_dispersion should be tested in a trace_list_utils tests file spt = SpectralTrace(basic_trace) disp, wave = spt.get_max_dispersion() # dispersion is calculated by distance [mm] / wavelength coverage [um] dy = np.diff(basic_trace["y"]) dw = np.diff(basic_trace["wavelength"]) assert np.average(disp) == approx(np.average(dy / dw), rel=1e-5) assert len(disp) == len(wave) assert all(np.diff(wave) > 0)