diff --git a/RSP/parse_rinex.py b/RSP/parse_rinex.py index 053da2f..ccad100 100644 --- a/RSP/parse_rinex.py +++ b/RSP/parse_rinex.py @@ -173,6 +173,7 @@ def _next_line(rinex_file: TextIOWrapper) -> list: def _extract_data(rinex_file: TextIOWrapper) -> dict: ext_data = {} + nr_sat = 0 while True: try: str_data = [] @@ -180,16 +181,19 @@ def _extract_data(rinex_file: TextIOWrapper) -> dict: for _ in range(8): str_data.append(_next_line(rinex_file)) - ex_data_l1 = _read_PRN_EPOCH_SV_CLK(str_data[0]) - ext_data[str(ex_data_l1['PRN'])] = ex_data_l1 - ext_data[str(ex_data_l1['PRN'])].update(_read_BROADCAST_ORBIT_1(str_data[1])) - ext_data[str(ex_data_l1['PRN'])].update(_read_BROADCAST_ORBIT_2(str_data[2])) - ext_data[str(ex_data_l1['PRN'])].update(_read_BROADCAST_ORBIT_3(str_data[3])) - ext_data[str(ex_data_l1['PRN'])].update(_read_BROADCAST_ORBIT_4(str_data[4])) - ext_data[str(ex_data_l1['PRN'])].update(_read_BROADCAST_ORBIT_5(str_data[5])) - ext_data[str(ex_data_l1['PRN'])].update(_read_BROADCAST_ORBIT_6(str_data[6])) - ext_data[str(ex_data_l1['PRN'])].update(_read_BROADCAST_ORBIT_7(str_data[7])) + + ex_data_l1 = _read_PRN_EPOCH_SV_CLK(str_data[0]) + key = f"{nr_sat}_{str(ex_data_l1['PRN'])}" + nr_sat += 1 + ext_data[key] = ex_data_l1 + ext_data[key].update(_read_BROADCAST_ORBIT_1(str_data[1])) + ext_data[key].update(_read_BROADCAST_ORBIT_2(str_data[2])) + ext_data[key].update(_read_BROADCAST_ORBIT_3(str_data[3])) + ext_data[key].update(_read_BROADCAST_ORBIT_4(str_data[4])) + ext_data[key].update(_read_BROADCAST_ORBIT_5(str_data[5])) + ext_data[key].update(_read_BROADCAST_ORBIT_6(str_data[6])) + ext_data[key].update(_read_BROADCAST_ORBIT_7(str_data[7])) except EndOfFile: print("End of file") diff --git a/RSP/satpos.py b/RSP/satpos.py index 9c45f8c..3dfc673 100644 --- a/RSP/satpos.py +++ b/RSP/satpos.py @@ -56,10 +56,10 @@ def calculate_satpos(sat_rinex: dict) -> tuple: def calculate_positions(sat_data: dict) -> dict: sat_pos = {} - for _, sat_rinex in sat_data.items(): + for key, sat_rinex in sat_data.items(): xk, yk, zk = calculate_satpos(sat_rinex) - sat_pos[str(sat_rinex['PRN'])] = { + sat_pos[key] = { 'x': xk, 'y': yk, 'z': zk diff --git a/example.py b/example.py index 66c2513..cedba93 100644 --- a/example.py +++ b/example.py @@ -1,7 +1,7 @@ from RSP.parse_rinex import read_rinex -from RSP.satpos import calculate_positions +from RSP.satpos import calculate_satpos, calculate_positions -sat_data = read_rinex('./test/940779338I_1.17N') +sat_data = read_rinex('./test/gmez0380.21n') sat_pos = calculate_positions(sat_data) -print(sat_pos) \ No newline at end of file +print(sat_pos)