Пример #1
0
def test_compare():
    test_files = _get_test_files("v2_0", "valid")
    oem1 = OrbitEphemerisMessage.open(test_files[0])
    oem2 = OrbitEphemerisMessage.open(test_files[1])
    assert oem1 == oem1
    assert oem2 == oem2
    assert oem1 != oem2
Пример #2
0
def test_ephemeris_accuracy(coarse_file, fine_file):
    fine_sample = SAMPLE_DIR / "real" / fine_file
    coarse_sample = SAMPLE_DIR / "real" / coarse_file
    fine_oem = OrbitEphemerisMessage.open(fine_sample)
    coarse_oem = OrbitEphemerisMessage.open(coarse_sample)

    for state in fine_oem.states:
        predict = coarse_oem(state.epoch)
        np.testing.assert_almost_equal(predict.position, state.position, 6)
        np.testing.assert_almost_equal(predict.velocity, state.velocity, 6)
        if state.has_accel:
            np.testing.assert_almost_equal(predict.acceleration,
                                           state.acceleration, 6)
Пример #3
0
def test_ephemeris_self_compare():
    test_file_path = SAMPLE_DIR / "real" / "GEO_20s.oem"
    oem = OrbitEphemerisMessage.open(test_file_path)
    compare = oem - oem
    assert not compare.is_empty
    for state_compare in compare.steps(600):
        assert state_compare.range == 0 and state_compare.range_rate == 0
Пример #4
0
def test_segment_self_compare():
    test_file_path = SAMPLE_DIR / "real" / "GEO_20s.oem"
    segment = OrbitEphemerisMessage.open(test_file_path).segments[0]
    compare = segment - segment
    assert not compare.is_empty
    for state_compare in compare.steps(600):
        assert state_compare.range == 0 and state_compare.range_rate == 0
Пример #5
0
def test_segment_compare_mismatch():
    test_file_path = SAMPLE_DIR / "real" / "GEO_20s.oem"
    segment1 = OrbitEphemerisMessage.open(test_file_path).segments[0]
    segment2 = segment1.copy()
    _ = segment1 - segment2
    segment2.metadata["CENTER_NAME"] = "MARS"
    with pytest.raises(ValueError):
        _ = segment1 - segment2
Пример #6
0
def test_ephemeris_resample(input_file):
    sample_file = SAMPLE_DIR / "real" / input_file
    step_size = 600
    oem = OrbitEphemerisMessage.open(sample_file)
    new_oem = oem.resample(step_size)

    for idx in range(1, len(new_oem.states)):
        assert np.isclose(
            (new_oem.states[idx].epoch - new_oem.states[idx - 1].epoch).sec,
            step_size)
Пример #7
0
def test_ephemeris_stepping(input_file):
    sample_file = SAMPLE_DIR / "real" / input_file
    oem = OrbitEphemerisMessage.open(sample_file)

    for state in oem.steps(601):
        assert state.epoch in oem

    for segment in oem:
        for state in segment.steps(601):
            assert state.epoch in oem
Пример #8
0
def test_valid_samples(file_path):
    oem = OrbitEphemerisMessage.open(file_path)

    for segment in oem:
        if not segment.has_accel:
            for state in segment.states:
                assert state.acceleration is None
        for covariance in segment.covariances:
            assert covariance.matrix.shape == (6, 6)

        assert segment.useable_start_time in segment
        assert segment.useable_stop_time in segment
        assert len(oem.states) > 0
        assert len(oem.covariances) >= 0

    with tempfile.TemporaryDirectory() as tmp_dir:
        written_oem_path = Path(tmp_dir) / "written.oem"
        fmt = "xml" if is_kvn(file_path) else "kvn"
        OrbitEphemerisMessage.convert(file_path, written_oem_path, fmt)
        written_oem = OrbitEphemerisMessage.open(written_oem_path)
        assert written_oem == oem
Пример #9
0
def test_convert(file_path):
    with tempfile.TemporaryDirectory() as tmp_dir:
        converted_xml_path = Path(tmp_dir) / "written.oem"
        OrbitEphemerisMessage.convert(file_path, converted_xml_path, "kvn")
        converted_xml = OrbitEphemerisMessage.open(converted_xml_path)

        converted_kvn_path = Path(tmp_dir) / "written.oem"
        OrbitEphemerisMessage.convert(converted_xml_path, converted_kvn_path,
                                      "xml")
        converted_kvn = OrbitEphemerisMessage.open(converted_kvn_path)

        assert converted_xml == converted_kvn
Пример #10
0
def test_copy(file_path):
    oem1 = OrbitEphemerisMessage.open(file_path)
    oem2 = oem1.copy()
    assert oem1 is not oem2 and oem1 == oem2
Пример #11
0
def test_invalid_samples(file_path):
    with pytest.raises(Exception):
        OrbitEphemerisMessage.open(file_path)