def test_concat(): ds = TimeResSpec(wl, t, data) ds = ds.bin_freqs(50) n = ds.wavelengths.size // 2 ds1 = ds.cut_freq(ds.wavelengths[n], np.inf) ds2 = ds.cut_freq(-np.inf, ds.wavelengths[n]) dsc = ds1.concat_datasets(ds2) assert (np.allclose(dsc.data, ds.data)) pol_ds = PolTRSpec(ds, ds) a = PolTRSpec(ds1, ds1) b = PolTRSpec(ds2, ds2) pol_dsc = a.concat_datasets(b) for p in 'para', 'perp', 'iso': assert (np.allclose(getattr(pol_dsc, p).data, getattr(pol_ds, p).data))
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)