def test_methods(): ds = TimeResSpec(wl, t, data) bds = ds.bin_freqs(300) assert (len(bds.wavelengths) == 300) nds = ds.cut_freqs([(400, 600)]) assert (np.all(nds.wavelengths > 600)) nds = ds.cut_times([(-100, 1)]) assert (np.all(nds.t > .99)) nds = ds.bin_times(5) assert (nds.t.size == np.ceil(ds.t.size / 5)) ds.mask_freqs([(400, 600)]) assert (np.all(ds.data.mask[:, ds.wl_idx(550)]))
def test_methods(): ds = TimeResSpec(wl, t, data) bds = ds.bin_freqs(300) assert(len(bds.wavelengths) == 300) nds = ds.cut_freqs([(400, 600)]) assert(np.all(nds.wavelengths > 600)) nds = ds.cut_times([(-100, 1)]) assert(np.all(nds.t > .99)) nds = ds.bin_times(5) assert(nds.t.size == np.ceil(ds.t.size/5)) ds.mask_freqs([(400, 600)]) assert(np.all(ds.data.mask[:, ds.wl_idx(550)]))
def test_methods(): ds = TimeResSpec(wl, t, data) bds = ds.bin_freqs(300) ds2 = TimeResSpec(1e7 / wl, t, data, freq_unit='cm', disp_freq_unit='cm') bds2 = ds2.bin_freqs(50) assert (np.all(np.isfinite(bds2.data))) assert (len(bds.wavelengths) == 300) nds = ds.cut_freq(400, 600) assert (np.all(nds.wavelengths > 600)) nds = ds.cut_time(-100, 1) assert (np.all(nds.t > .99)) nds = ds.bin_times(5) assert (nds.t.size == np.ceil(ds.t.size / 5)) ds.mask_freqs([(400, 600)]) assert (np.all(ds.data.mask[:, ds.wl_idx(550)])) ds2 = ds.scale_and_shift(2, t_shift=1, wl_shift=10) assert_almost_equal(2 * ds.data, ds2.data) assert_almost_equal(ds.t + 1, ds2.t) assert_almost_equal(ds.wavelengths + 10, ds2.wavelengths) assert_almost_equal(1e7 / ds2.wavelengths, ds2.wavenumbers)