示例#1
0
def test_write_with_missing_info():
    data = DataParser(scan_angle=np.arange(3), epoch=np.arange(1991, 1994),
                      residuals=np.arange(2, 5),
                      inverse_covariance_matrix=None,
                      along_scan_errs=None)
    with tempfile.TemporaryDirectory() as tmp_dir:
        data.write(os.path.join(tmp_dir, 'out.csv'))
        t = Table.read(os.path.join(tmp_dir, 'out.csv'))
        assert np.allclose(t['residuals'], data.residuals)
        assert np.allclose(t['julian_day_epoch'], data.julian_day_epoch())
        assert np.allclose(t['scan_angle'], data.scan_angle)
        assert len(t.colnames) == 5
示例#2
0
def test_write():
    data = DataParser(scan_angle=np.arange(3), epoch=np.arange(1991, 1994),
                      residuals=np.arange(2, 5),
                      inverse_covariance_matrix=np.array([[1, 2], [3, 4]]) * np.ones((3, 2, 2)),
                      along_scan_errs=np.arange(3, 6))
    with tempfile.TemporaryDirectory() as tmp_dir:
        data.write(os.path.join(tmp_dir, 'out.csv'))
        t = Table.read(os.path.join(tmp_dir, 'out.csv'))
        assert np.allclose(t['residuals'], data.residuals)
        assert np.allclose(t['julian_day_epoch'], data.julian_day_epoch())
        assert np.allclose(t['scan_angle'], data.scan_angle)
        assert np.allclose(t['along_scan_errs'], data.along_scan_errs)
        icovs = [np.array(literal_eval(icov)) for icov in t['icov']]
        assert np.allclose(icovs, data.inverse_covariance_matrix)
        assert len(t.colnames) == 5