From e90513f9952d5deb9ad2802bf74679c6fbe8dafd Mon Sep 17 00:00:00 2001 From: Eugene_Du Date: Thu, 22 Aug 2024 04:30:13 +0000 Subject: [PATCH 1/4] Move in sp3/clock comparing functions --- gnssanalysis/gn_diffaux.py | 185 ++++++++++++++++++++++++++++++++++++- gnssanalysis/gn_io/sp3.py | 5 +- 2 files changed, 187 insertions(+), 3 deletions(-) diff --git a/gnssanalysis/gn_diffaux.py b/gnssanalysis/gn_diffaux.py index eebc01d..c2ff4ce 100644 --- a/gnssanalysis/gn_diffaux.py +++ b/gnssanalysis/gn_diffaux.py @@ -1,4 +1,5 @@ import logging as _logging +from pathlib import Path as _Path from typing import Union as _Union import numpy as _np @@ -526,6 +527,7 @@ def sisre( def diffsp3( sp3_a_path, sp3_b_path, tol, log_lvl, clk_a_path, clk_b_path, nodata_to_nan=True, hlm_mode=None, plot=False, write_rac_file=False ): +# Eugene: function name and description are confusing - it seems to output the SISRE instead of SP3 orbit/clock differences against the given tolerance """Compares two sp3 files and outputs a dataframe of differences above tolerance if such were found""" sp3_a, sp3_b = _gn_io.sp3.read_sp3(sp3_a_path, nodata_to_nan=nodata_to_nan), _gn_io.sp3.read_sp3(sp3_b_path, nodata_to_nan=nodata_to_nan) @@ -547,7 +549,7 @@ def diffsp3( hlm_mode=hlm_mode, plot=plot, write_rac_file=write_rac_file, - ) + ) # Eugene: sisre() returns SISRE instead of RAC differences bad_rac_vals = _diff2msg(diff_rac, tol=tol) if bad_rac_vals is not None: @@ -669,3 +671,184 @@ def rac_df_to_rms_df(rac_df): rms_df.attrs["summary"] = summary_df return rms_df + + +def sp3_diff( + base_sp3_file: _Path, + test_sp3_file: _Path, +) -> _pd.DataFrame: + """ + Compare two SP3 files to calculate orbit and clock differences. The orbit differences will be represented + in both X/Y/Z ECEF frame and R/A/C orbit frame, and the clock differences will NOT be normalised. + + :param _Path base_sp3_file: Path of the baseline SP3 file + :param _Path test_sp3_file: Path of the test SP3 file + :return _pd.DataFrame: The Pandas DataFrame containing orbit and clock differences + """ + base_sp3_df = _gn_io.sp3.read_sp3(str(base_sp3_file)) + test_sp3_df = _gn_io.sp3.read_sp3(str(test_sp3_file)) + + # Select rows with matching indices and calculate ECEF differences + common_indices = base_sp3_df.index.intersection( + test_sp3_df.index + ) # get common indices + diff_est_df = ( + test_sp3_df.loc[common_indices, "EST"] - base_sp3_df.loc[common_indices, "EST"] + ) + + # The index is in J2000 seconds but python datetimes are a little easier to read + diff_est_df.index = _pd.MultiIndex.from_tuples( + ( + (idx[0] + _gn_const.J2000_ORIGIN, idx[1]) + for idx in diff_est_df.index.values + ) + ) # Eugene: can do this and set_names once for diff_sp3_df + + # Rename the indices + diff_est_df.index = diff_est_df.index.set_names(["Epoch", "Satellite"]) + + # Extract clocks and change the units from ms to ns + diff_clk_df = diff_est_df["CLK"].to_frame(name="CLK") * 1e3 # TODO Eugene: normalise clocks and change units to s + + # Drop the clocks and then change the units from km to m + diff_xyz_df = diff_est_df.drop(columns=["CLK"]) * 1e3 + + # RAC difference + diff_rac_df = _gn_io.sp3.diff_sp3_rac( + base_sp3_df, test_sp3_df, hlm_mode=None + ) # TODO: hlm_mode + + # Change the units from km to m (read_sp3 and diff_sp3_rac will result in a dataframe in sp3 units (km)) + diff_rac_df = diff_rac_df * 1e3 + + # The index is in J2000 seconds but python datetimes are a little easier to read + diff_rac_df.index = _pd.MultiIndex.from_tuples( + ( + (idx[0] + _gn_const.J2000_ORIGIN, idx[1]) + for idx in diff_rac_df.index.values + ) + ) + + # Name the indices + diff_rac_df.index = diff_rac_df.index.set_names(["Epoch", "Satellite"]) # TODO Eugene: make this and above a function + + # Drop the not-particularly needed 'EST_RAC' multi-index level + diff_rac_df.columns = diff_rac_df.columns.droplevel(0) + + diff_sp3_df = diff_xyz_df.join(diff_rac_df) + diff_sp3_df["3D-Total"] = diff_xyz_df.pow(2).sum(axis=1, min_count=3).pow(0.5) + diff_sp3_df["Clock"] = diff_clk_df + + return diff_sp3_df + + +def sp3_stats( + diff_sp3_df: _pd.DataFrame, +) -> _pd.DataFrame: + """ + Compute statistics of SP3 differences in a Pandas DataFrame. + + :param _pd.DataFrame diff_sp3_df: The Pandas DataFrame containing SP3 differences + :return _pd.DataFrame: The Pandas DataFrame containing statistics of SP3 differences + """ + stats = diff_sp3_df.describe(percentiles=[0.25, 0.50, 0.75, 0.90, 0.95]) + stats.loc["rms"] = diff_sp3_df.pow(2).mean().pow(0.5) + + stats.index = _pd.MultiIndex.from_tuples( + (("All", idx) for idx in stats.index.values) + ) + stats.index = stats.index.set_names(["Satellite", "Stats"]) + + sat_index = diff_sp3_df.index.get_level_values("Satellite") + svs = sorted(list(sat_index.unique())) + + for sat in svs: + diff_sat = diff_sp3_df[sat_index == sat] + + stats_sat = diff_sat.describe(percentiles=[0.25, 0.50, 0.75, 0.90, 0.95]) + stats_sat.loc["rms"] = diff_sat.pow(2).mean().pow(0.5) + + stats_sat.index = _pd.MultiIndex.from_tuples( + ((sat, idx) for idx in stats_sat.index.values) + ) + stats_sat.index = stats_sat.index.set_names(["Satellite", "Stats"]) + + stats = _pd.concat([stats, stats_sat]) + + return stats + + +def clk_diff( + base_clk_file: _Path, + test_clk_file: _Path, + norm_types: list[str], +) -> _pd.DataFrame: + """ + Compare two CLK files to calculate clock differences with common mode removed (if specified) + based on the chosen normalisations. + + :param _Path base_clk_file: Path of the baseline CLK file + :param _Path test_clk_file: Path of the test CLK file + :param norm_types list[str]: Normalizations to apply. Available options include 'epoch', 'daily', 'sv', + any satellite PRN, or any combination of them, defaults to None + :return _pd.DataFrame: The Pandas DataFrame containing clock differences + """ + base_clk_df = _gn_io.clk.read_clk(base_clk_file) + test_clk_df = _gn_io.clk.read_clk(test_clk_file) + + diff_clk_df = compare_clk( + test_clk_df, base_clk_df, norm_types=norm_types + ) + diff_clk_df = diff_clk_df.stack() # compare_clk() returns unstacked dataframe + + # Change the units from s to ns (read_clk and compare_clk will result in a dataframe in clk units (s)) + diff_clk_df = diff_clk_df.to_frame(name="Clock") * 1e9 # TODO Eugene: change units to s + + # The index is in J2000 seconds but python datetimes are a little easier to read + diff_clk_df.index = _pd.MultiIndex.from_tuples( + ( + (idx[0] + _gn_const.J2000_ORIGIN, idx[1]) + for idx in diff_clk_df.index.values + ) + ) + + # Name the indices + diff_clk_df.index = diff_clk_df.index.set_names(["Epoch", "Satellite"]) + + return diff_clk_df + + +def clk_stats( + diff_clk_df: _pd.DataFrame, +) -> _pd.DataFrame: + """ + Compute statistics of CLK differences in a Pandas DataFrame. + + :param _pd.DataFrame diff_clk_df: The Pandas DataFrame containing CLK differences + :return _pd.DataFrame: The Pandas DataFrame containing statistics of CLK differences + """ + stats = diff_clk_df.describe(percentiles=[0.25, 0.50, 0.75, 0.90, 0.95]) + stats.loc["rms"] = diff_clk_df.pow(2).mean().pow(0.5) + + stats.index = _pd.MultiIndex.from_tuples( + (("All", idx) for idx in stats.index.values) + ) + stats.index = stats.index.set_names(["Satellite", "Stats"]) + + sat_index = diff_clk_df.index.get_level_values("Satellite") + svs = sorted(list(sat_index.unique())) + + for sat in svs: + diff_sat = diff_clk_df[sat_index == sat] + + stats_sat = diff_sat.describe(percentiles=[0.25, 0.50, 0.75, 0.90, 0.95]) + stats_sat.loc["rms"] = diff_sat.pow(2).mean().pow(0.5) + + stats_sat.index = _pd.MultiIndex.from_tuples( + ((sat, idx) for idx in stats_sat.index.values) + ) + stats_sat.index = stats_sat.index.set_names(["Satellite", "Stats"]) + + stats = _pd.concat([stats, stats_sat]) + + return stats diff --git a/gnssanalysis/gn_io/sp3.py b/gnssanalysis/gn_io/sp3.py index 59d3b7f..86e6d84 100644 --- a/gnssanalysis/gn_io/sp3.py +++ b/gnssanalysis/gn_io/sp3.py @@ -9,10 +9,10 @@ from scipy import interpolate as _interpolate from .. import gn_aux as _gn_aux +from .. import gn_const as _gn_const from .. import gn_datetime as _gn_datetime from .. import gn_io as _gn_io from .. import gn_transform as _gn_transform -from .. import gn_const logger = logging.getLogger(__name__) @@ -309,7 +309,7 @@ def read_sp3( first_dupe = sp3_df.index.get_level_values(0)[duplicated_indexes][0] logging.warning( f"Duplicate epoch(s) found in SP3 ({duplicated_indexes.sum()} additional entries, potentially non-unique). " - f"First duplicate (as J2000): {first_dupe} (as date): {first_dupe + gn_const.J2000_ORIGIN} " + f"First duplicate (as J2000): {first_dupe} (as date): {first_dupe + _gn_const.J2000_ORIGIN} " f"SP3 path is: '{str(sp3_path)}'. Duplicates will be removed, keeping first." ) # Now dedupe them, keeping the first of any clashes: @@ -829,6 +829,7 @@ def sp3_hlm_trans(a: _pd.DataFrame, b: _pd.DataFrame) -> tuple[_pd.DataFrame, li return b, hlm +# Eugene: move to gn_diffaux.py (and other associated functions as well)? def diff_sp3_rac( sp3_baseline: _pd.DataFrame, sp3_test: _pd.DataFrame, From de32e7630435cd5c4930c50b5c9a24a81b1372eb Mon Sep 17 00:00:00 2001 From: Eugene_Du Date: Thu, 22 Aug 2024 04:31:37 +0000 Subject: [PATCH 2/4] Quick fix rms() --- gnssanalysis/gn_aux.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gnssanalysis/gn_aux.py b/gnssanalysis/gn_aux.py index e17f2f1..6d0f9c3 100644 --- a/gnssanalysis/gn_aux.py +++ b/gnssanalysis/gn_aux.py @@ -196,10 +196,13 @@ def array_equal_unordered(a1: _np.ndarray, a2: _np.ndarray) -> bool: def rms( arr: _Union[_pd.DataFrame, _pd.Series], axis: _Union[None, int] = 0, - level: _Union[None, int] = None, + level: _Union[None, int, str] = None, ) -> _Union[_pd.Series, _pd.DataFrame]: """Trivial function to compute root mean square""" - return (arr**2).mean(axis=axis, level=level) ** 0.5 + if level is not None: + return (arr**2).groupby(axis=axis, level=level).mean() ** 0.5 + else: + return (arr**2).mean(axis=axis) ** 0.5 def get_std_bounds( From 2ee1aa9aaed1d07b114e12c6da8ca4a12c3c6d2b Mon Sep 17 00:00:00 2001 From: Eugene_Du Date: Fri, 23 Aug 2024 04:45:31 +0000 Subject: [PATCH 3/4] Update sp3/clock analysis functions and move in generate_sampling_rate() --- gnssanalysis/gn_diffaux.py | 191 +++++++++++++++--------------------- gnssanalysis/gn_download.py | 49 +++++++++ 2 files changed, 130 insertions(+), 110 deletions(-) diff --git a/gnssanalysis/gn_diffaux.py b/gnssanalysis/gn_diffaux.py index c2ff4ce..938fdb1 100644 --- a/gnssanalysis/gn_diffaux.py +++ b/gnssanalysis/gn_diffaux.py @@ -673,6 +673,25 @@ def rac_df_to_rms_df(rac_df): return rms_df +def format_index( + diff_df: _pd.DataFrame, +) -> None: + """ + Convert the epoch indices of a SP3 or CLK difference DataFrame from J2000 seconds to more readable + python datetimes and rename the indices properly. + + :param _pd.DataFrame diff_df: The Pandas DataFrame containing SP3 or CLK differences + :return None + """ + # Convert the epoch indices from J2000 seconds to python datetimes + diff_df.index = _pd.MultiIndex.from_tuples( + ((idx[0] + _gn_const.J2000_ORIGIN, idx[1]) for idx in diff_df.index.values) + ) + + # Rename the indices + diff_df.index = diff_df.index.set_names(["Epoch", "Satellite"]) + + def sp3_diff( base_sp3_file: _Path, test_sp3_file: _Path, @@ -688,94 +707,39 @@ def sp3_diff( base_sp3_df = _gn_io.sp3.read_sp3(str(base_sp3_file)) test_sp3_df = _gn_io.sp3.read_sp3(str(test_sp3_file)) - # Select rows with matching indices and calculate ECEF differences - common_indices = base_sp3_df.index.intersection( - test_sp3_df.index - ) # get common indices + # Select rows with matching indices and calculate XYZ differences (ECEF) + common_indices = base_sp3_df.index.intersection(test_sp3_df.index) diff_est_df = ( test_sp3_df.loc[common_indices, "EST"] - base_sp3_df.loc[common_indices, "EST"] ) - # The index is in J2000 seconds but python datetimes are a little easier to read - diff_est_df.index = _pd.MultiIndex.from_tuples( - ( - (idx[0] + _gn_const.J2000_ORIGIN, idx[1]) - for idx in diff_est_df.index.values - ) - ) # Eugene: can do this and set_names once for diff_sp3_df - - # Rename the indices - diff_est_df.index = diff_est_df.index.set_names(["Epoch", "Satellite"]) + # Extract clocks and change the units from ms to ns (read_sp3 will result in sp3 units (ms)) + # TODO: normalise clocks + diff_clk_df = diff_est_df["CLK"].to_frame(name="CLK") * 1e3 - # Extract clocks and change the units from ms to ns - diff_clk_df = diff_est_df["CLK"].to_frame(name="CLK") * 1e3 # TODO Eugene: normalise clocks and change units to s - - # Drop the clocks and then change the units from km to m + # Drop clocks and then change the units from km to m (read_sp3 will result in sp3 units (km)) diff_xyz_df = diff_est_df.drop(columns=["CLK"]) * 1e3 # RAC difference - diff_rac_df = _gn_io.sp3.diff_sp3_rac( - base_sp3_df, test_sp3_df, hlm_mode=None - ) # TODO: hlm_mode - - # Change the units from km to m (read_sp3 and diff_sp3_rac will result in a dataframe in sp3 units (km)) - diff_rac_df = diff_rac_df * 1e3 - - # The index is in J2000 seconds but python datetimes are a little easier to read - diff_rac_df.index = _pd.MultiIndex.from_tuples( - ( - (idx[0] + _gn_const.J2000_ORIGIN, idx[1]) - for idx in diff_rac_df.index.values - ) - ) - - # Name the indices - diff_rac_df.index = diff_rac_df.index.set_names(["Epoch", "Satellite"]) # TODO Eugene: make this and above a function + # TODO: hlm_mode + diff_rac_df = _gn_io.sp3.diff_sp3_rac(base_sp3_df, test_sp3_df, hlm_mode=None) # Drop the not-particularly needed 'EST_RAC' multi-index level diff_rac_df.columns = diff_rac_df.columns.droplevel(0) + # Change the units from km to m (diff_sp3_rac will result in sp3 units (km)) + diff_rac_df = diff_rac_df * 1e3 + diff_sp3_df = diff_xyz_df.join(diff_rac_df) diff_sp3_df["3D-Total"] = diff_xyz_df.pow(2).sum(axis=1, min_count=3).pow(0.5) diff_sp3_df["Clock"] = diff_clk_df + diff_sp3_df["|Clock|"] = diff_clk_df.abs() - return diff_sp3_df - - -def sp3_stats( - diff_sp3_df: _pd.DataFrame, -) -> _pd.DataFrame: - """ - Compute statistics of SP3 differences in a Pandas DataFrame. - - :param _pd.DataFrame diff_sp3_df: The Pandas DataFrame containing SP3 differences - :return _pd.DataFrame: The Pandas DataFrame containing statistics of SP3 differences - """ - stats = diff_sp3_df.describe(percentiles=[0.25, 0.50, 0.75, 0.90, 0.95]) - stats.loc["rms"] = diff_sp3_df.pow(2).mean().pow(0.5) - - stats.index = _pd.MultiIndex.from_tuples( - (("All", idx) for idx in stats.index.values) - ) - stats.index = stats.index.set_names(["Satellite", "Stats"]) - - sat_index = diff_sp3_df.index.get_level_values("Satellite") - svs = sorted(list(sat_index.unique())) - - for sat in svs: - diff_sat = diff_sp3_df[sat_index == sat] + # Change the epoch indices from J2000 seconds to more readable python datetimes + # and rename the indices properly + format_index(diff_sp3_df) - stats_sat = diff_sat.describe(percentiles=[0.25, 0.50, 0.75, 0.90, 0.95]) - stats_sat.loc["rms"] = diff_sat.pow(2).mean().pow(0.5) - - stats_sat.index = _pd.MultiIndex.from_tuples( - ((sat, idx) for idx in stats_sat.index.values) - ) - stats_sat.index = stats_sat.index.set_names(["Satellite", "Stats"]) - - stats = _pd.concat([stats, stats_sat]) - - return stats + return diff_sp3_df def clk_diff( @@ -796,59 +760,66 @@ def clk_diff( base_clk_df = _gn_io.clk.read_clk(base_clk_file) test_clk_df = _gn_io.clk.read_clk(test_clk_file) - diff_clk_df = compare_clk( - test_clk_df, base_clk_df, norm_types=norm_types - ) - diff_clk_df = diff_clk_df.stack() # compare_clk() returns unstacked dataframe + diff_clk_df = compare_clk(test_clk_df, base_clk_df, norm_types=norm_types) - # Change the units from s to ns (read_clk and compare_clk will result in a dataframe in clk units (s)) - diff_clk_df = diff_clk_df.to_frame(name="Clock") * 1e9 # TODO Eugene: change units to s + # Stack diff_clk_df to keep the format consistent with other dataframes (compare_clk() returns unstacked dataframe) + # and change the units from s to ns (read_clk() and compare_clk() will result in clk units (s)) + diff_clk_df = diff_clk_df.stack(dropna=False).to_frame(name="Clock") * 1e9 + diff_clk_df["|Clock|"] = diff_clk_df.abs() - # The index is in J2000 seconds but python datetimes are a little easier to read - diff_clk_df.index = _pd.MultiIndex.from_tuples( - ( - (idx[0] + _gn_const.J2000_ORIGIN, idx[1]) - for idx in diff_clk_df.index.values - ) - ) - - # Name the indices - diff_clk_df.index = diff_clk_df.index.set_names(["Epoch", "Satellite"]) + # Change the epoch indices from J2000 seconds to more readable python datetimes + # and rename the indices properly + format_index(diff_clk_df) return diff_clk_df -def clk_stats( - diff_clk_df: _pd.DataFrame, +def diff_stats( + diff_df: _pd.DataFrame, ) -> _pd.DataFrame: """ - Compute statistics of CLK differences in a Pandas DataFrame. + Compute statistics of SP3 or CLK differences in a Pandas DataFrame. - :param _pd.DataFrame diff_clk_df: The Pandas DataFrame containing CLK differences - :return _pd.DataFrame: The Pandas DataFrame containing statistics of CLK differences + :param _pd.DataFrame diff_df: The Pandas DataFrame containing SP3 or CLK differences + :return _pd.DataFrame: The Pandas DataFrame containing statistics of SP3 or CLK differences """ - stats = diff_clk_df.describe(percentiles=[0.25, 0.50, 0.75, 0.90, 0.95]) - stats.loc["rms"] = diff_clk_df.pow(2).mean().pow(0.5) - + # Statistics of all satellites + stats = diff_df.describe(percentiles=[0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95]) + stats.loc["rms"] = _gn_aux.rms(diff_df) stats.index = _pd.MultiIndex.from_tuples( (("All", idx) for idx in stats.index.values) ) - stats.index = stats.index.set_names(["Satellite", "Stats"]) - - sat_index = diff_clk_df.index.get_level_values("Satellite") - svs = sorted(list(sat_index.unique())) - - for sat in svs: - diff_sat = diff_clk_df[sat_index == sat] - stats_sat = diff_sat.describe(percentiles=[0.25, 0.50, 0.75, 0.90, 0.95]) - stats_sat.loc["rms"] = diff_sat.pow(2).mean().pow(0.5) - - stats_sat.index = _pd.MultiIndex.from_tuples( - ((sat, idx) for idx in stats_sat.index.values) - ) - stats_sat.index = stats_sat.index.set_names(["Satellite", "Stats"]) + # Statistics satellite-by-satellite + stats_sat = ( + diff_df.groupby("Satellite") + .describe(percentiles=[0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95]) + .stack(dropna=False) + ) + rms_sat = _gn_aux.rms(diff_df, level="Satellite") + rms_sat.index = _pd.MultiIndex.from_tuples( + ((sv, "rms") for sv in rms_sat.index.values) + ) - stats = _pd.concat([stats, stats_sat]) + # Merge above dataframes, rename the indices properly and re-arrange the statistics + stats = _pd.concat([stats, stats_sat, rms_sat]).sort_index() + stats.index = stats.index.set_names(["Satellite", "Stats"]) + stats = stats.reindex( + [ + "count", + "mean", + "std", + "rms", + "min", + "5%", + "10%", + "50%", + "75%", + "90%", + "95%", + "max", + ], + level="Stats", + ) return stats diff --git a/gnssanalysis/gn_download.py b/gnssanalysis/gn_download.py index 37c5acd..f79861c 100644 --- a/gnssanalysis/gn_download.py +++ b/gnssanalysis/gn_download.py @@ -259,6 +259,55 @@ def generate_nominal_span(start_epoch: _datetime.datetime, end_epoch: _datetime. return f"{span:02}{unit}" +def generate_sampling_rate(file_ext: str, analysis_center: str, solution_type: str) -> str: + """ + IGS files following the long filename convention require a content specifier + Given the file extension, generate the content specifier + """ + file_ext = file_ext.upper() + sampling_rates = { + "ERP": { + ("COD"): {"FIN": "12H", "RAP": "01D", "ERP": "01D"}, + (): "01D", + }, + "BIA": "01D", + "SP3": { + ("COD", "GFZ", "GRG", "IAC", "JAX", "MIT", "WUM"): "05M", + ("ESA"): {"FIN": "05M", "RAP": "15M", None: "15M"}, + (): "15M", + }, + "CLK": { + ("EMR", "MIT", "SHA", "USN"): "05M", + ("ESA", "GFZ", "GRG", "IGS"): {"FIN": "30S", "RAP": "05M", None: "30S"}, # DZ: IGS FIN has 30S CLK + (): "30S", + }, + "OBX": {"GRG": "05M", None: "30S"}, + "TRO": {"JPL": "30S", None: "01H"}, + "SNX": "01D", + } + if file_ext in sampling_rates: + file_rates = sampling_rates[file_ext] + if isinstance(file_rates, dict): + center_rates_found = False + for key in file_rates: + if analysis_center in key: + center_rates = file_rates.get(key, file_rates.get(())) + center_rates_found = True + break + # else: + # return file_rates.get(()) + if not center_rates_found: # DZ: bug fix + return file_rates.get(()) + if isinstance(center_rates, dict): + return center_rates.get(solution_type, center_rates.get(None)) + else: + return center_rates + else: + return file_rates + else: + return "01D" + + def generate_long_filename( analysis_center: str, # AAA content_type: str, # CNT From 9ac160fdb3f9db8f8c97a49bb92324d873c1b770 Mon Sep 17 00:00:00 2001 From: Eugene_Du Date: Fri, 30 Aug 2024 06:30:04 +0000 Subject: [PATCH 4/4] Rename functions --- gnssanalysis/gn_diffaux.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gnssanalysis/gn_diffaux.py b/gnssanalysis/gn_diffaux.py index 938fdb1..240c906 100644 --- a/gnssanalysis/gn_diffaux.py +++ b/gnssanalysis/gn_diffaux.py @@ -692,7 +692,7 @@ def format_index( diff_df.index = diff_df.index.set_names(["Epoch", "Satellite"]) -def sp3_diff( +def sp3_difference( base_sp3_file: _Path, test_sp3_file: _Path, ) -> _pd.DataFrame: @@ -742,7 +742,7 @@ def sp3_diff( return diff_sp3_df -def clk_diff( +def clk_difference( base_clk_file: _Path, test_clk_file: _Path, norm_types: list[str], @@ -774,7 +774,7 @@ def clk_diff( return diff_clk_df -def diff_stats( +def difference_statistics( diff_df: _pd.DataFrame, ) -> _pd.DataFrame: """ @@ -784,10 +784,10 @@ def diff_stats( :return _pd.DataFrame: The Pandas DataFrame containing statistics of SP3 or CLK differences """ # Statistics of all satellites - stats = diff_df.describe(percentiles=[0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95]) - stats.loc["rms"] = _gn_aux.rms(diff_df) - stats.index = _pd.MultiIndex.from_tuples( - (("All", idx) for idx in stats.index.values) + stats_df = diff_df.describe(percentiles=[0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95]) + stats_df.loc["rms"] = _gn_aux.rms(diff_df) + stats_df.index = _pd.MultiIndex.from_tuples( + (("All", idx) for idx in stats_df.index.values) ) # Statistics satellite-by-satellite @@ -802,9 +802,9 @@ def diff_stats( ) # Merge above dataframes, rename the indices properly and re-arrange the statistics - stats = _pd.concat([stats, stats_sat, rms_sat]).sort_index() - stats.index = stats.index.set_names(["Satellite", "Stats"]) - stats = stats.reindex( + stats_df = _pd.concat([stats_df, stats_sat, rms_sat]).sort_index() + stats_df.index = stats_df.index.set_names(["Satellite", "Stats"]) + stats_df = stats_df.reindex( [ "count", "mean", @@ -822,4 +822,4 @@ def diff_stats( level="Stats", ) - return stats + return stats_df