From c58b4135364db4e2d2303ba040c8d4b08de4da3f Mon Sep 17 00:00:00 2001 From: Nathan <95725385+treefern@users.noreply.github.com> Date: Fri, 20 Dec 2024 06:43:02 +0000 Subject: [PATCH] NPI-3655 add unit test and minimal test data for offline sat removal, based on PR review --- tests/test_datasets/sp3_test_data.py | 31 ++++++++++++++++++++++++++++ tests/test_sp3.py | 17 +++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/tests/test_datasets/sp3_test_data.py b/tests/test_datasets/sp3_test_data.py index da47071..83f97d6 100644 --- a/tests/test_datasets/sp3_test_data.py +++ b/tests/test_datasets/sp3_test_data.py @@ -137,3 +137,34 @@ PR02 5096.267067 9515.396007 -23066.803522 -23.760149 EOF """ + +# Original filename IGS0DEMULT_20243181800_02D_05M_ORB.SP3 +# Modified using utility script, header manually updated to match. +sp3_test_data_partially_offline_sat = b"""#dP2024 11 13 18 0 0.0000000 3 ORBIT IGS20 HLM IGS +## 2340 324000.00000000 300.00000000 60627 0.7500000000000 ++ 3 G02G03G19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +++ 4 4 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +%c M cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc +%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc +%f 1.2500000 1.025000000 0.00000000000 0.000000000000000 +%f 0.0000000 0.000000000 0.00000000000 0.000000000000000 +%i 0 0 0 0 0 0 0 0 0 +%i 0 0 0 0 0 0 0 0 0 +/* +/* NOTE: This is a highly modified file for testing only. +/* It was originally derived from an IGS product, but +/* should not be taken as authoritative. +* 2024 11 13 18 0 0.00000000 +PG02 -22358.852114 -13824.987069 -4481.658280 -315.353433 8 9 10 +PG03 -12211.683721 -14412.444793 18550.880326 598.854905 9 9 9 +PG19 -16358.034086 16602.996553 12179.863169 562.338315 8 10 8 +* 2024 11 13 18 5 0.00000000 +PG02 -22143.724430 -13804.799870 -5406.496217 -315.350875 3 9 9 +PG03 -12184.752097 -15116.241903 18008.487790 598.858009 8 8 10 +PG19 0.000000 0.000000 0.000000 999999.999999 +* 2024 11 13 18 10 0.00000000 +PG02 -21896.123567 -13775.172104 -6321.083787 -315.348317 5 9 9 +PG03 -12170.453519 -15798.978021 17431.310591 598.861113 8 8 10 +PG19 0.000000 0.000000 0.000000 999999.999999 +EOF +""" diff --git a/tests/test_sp3.py b/tests/test_sp3.py index 17b8244..960279f 100644 --- a/tests/test_sp3.py +++ b/tests/test_sp3.py @@ -12,6 +12,7 @@ sp3_test_data_igs_benchmark_null_clock as input_data, # second dataset is a truncated version of file COD0OPSFIN_20242010000_01D_05M_ORB.SP3: sp3_test_data_truncated_cod_final as input_data2, + sp3_test_data_partially_offline_sat as offline_sat_test_data, ) @@ -180,6 +181,22 @@ def test_velinterpolation(self, mock_file): self.assertIsNotNone(r) self.assertIsNotNone(r2) + @patch("builtins.open", new_callable=mock_open, read_data=offline_sat_test_data) + def test_sp3_offline_sat_removal(self, mock_file): + sp3_df = sp3.read_sp3("mock_path", pOnly=False) + self.assertEqual( + sp3_df.index.get_level_values(1).unique().array, + ["G02", "G03", "G19"], + "Should be three SVs in test file before removing offline ones", + ) + + sp3_df = sp3.remove_offline_sats(sp3_df) + self.assertEqual( + sp3_df.index.get_level_values(1).unique().array, + ["G02", "G03"], + "Should be two SVs after removing offline ones", + ) + class TestMergeSP3(TestCase): def setUp(self):