Skip to content

Commit

Permalink
NPI-3421 fix format handling of STD nodata values (formatter was not …
Browse files Browse the repository at this point in the history
…getting invoked because the specified column names to use it for, were missing the underscore).
  • Loading branch information
treefern committed Jul 26, 2024
1 parent b29c7b4 commit c6687e8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions gnssanalysis/gn_io/sp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def sp3_clock_nodata_to_nan(
sp3_df: _pd.DataFrame
) -> None:
"""
Converts the SP3 Clock column's nodata values (999999 or 999999.999999 - the fractional component optional) to NaNs.
Converts the SP3 Clock column's nodata values (999999 or 999999.999999 - fractional component optional) to NaNs.
See https://files.igs.org/pub/data/format/sp3_docu.txt
:param _pd.DataFrame sp3_df: SP3 data frame to filter nodata values for
:return None
"""
nan_mask = sp3_df[("EST", "CLK")] >= SP3_CLOCK_NODATA_NUMERIC
sp3_df.loc[nan_mask, ("EST", "CLK")] = _np.NAN
sp3_df.loc[nan_mask, ("EST", "CLK")] = _np.nan


def mapparm(old, new):
Expand Down Expand Up @@ -395,6 +395,8 @@ def clk_formatter(x):
# NOTE: the following formatters are fine, as the nodata value is actually a *numeric value*,
# so DataFrame.to_string() will invoke them for those values.

# TODO A future improvement would be to use NaN rather than specific integer values, as this is an internal
# only representation.
def pos_std_formatter(x):
# We use -100 as our integer NaN/"missing" marker
if x <= SP3_POS_STD_NODATA:
Expand All @@ -413,10 +415,10 @@ def clk_std_formatter(x):
"Y": pos_formatter,
"Z": pos_formatter,
"CLK": clk_formatter, # Can't handle CLK nodata (Inf or NaN). Handled prior to invoking DataFrame.to_string()
"STDX": pos_std_formatter, # Nodata is represented as an integer, so can be handled here.
"STDY": pos_std_formatter,
"STDZ": pos_std_formatter,
"STDCLK": clk_std_formatter, # ditto above
"STD_X": pos_std_formatter, # Nodata is represented as an integer, so can be handled here.
"STD_Y": pos_std_formatter,
"STD_Z": pos_std_formatter,
"STD_CLK": clk_std_formatter, # ditto above
}
for epoch, epoch_vals in out_df.reset_index("PRN").groupby(axis=0, level="J2000"):
# Format and write out the epoch in the SP3 format
Expand Down

0 comments on commit c6687e8

Please sign in to comment.