Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPI-3429 - Fix mergesp3 utility #37

Merged
merged 7 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions gnssanalysis/gn_io/sp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,16 @@ def sp3merge(
:return pd.DataFrame: The merged sp3 DataFrame.
"""
sp3_dfs = [read_sp3(sp3_file, nodata_to_nan=nodata_to_nan) for sp3_file in sp3paths]
# Create a new attrs dictionary to be used for the output DataFrame
merged_attrs = merge_attrs(sp3_dfs)
ronaldmaj marked this conversation as resolved.
Show resolved Hide resolved
# If attrs of two DataFrames are different, pd.concat will fail - set them to empty dict instead
for df in sp3_dfs:
df.attrs = {}
merged_sp3 = _pd.concat(sp3_dfs)
merged_sp3.attrs["HEADER"] = merge_attrs(sp3_dfs)

merged_sp3.attrs["HEADER"] = merged_attrs
if clkpaths is not None:
clk_dfs = [_gn_io.clk.read_clk(clk_file) for clk_file in clkpaths]
merged_sp3.EST.CLK = _pd.concat(clk_dfs).EST.AS * 1000000

return merged_sp3


Expand Down
20 changes: 18 additions & 2 deletions gnssanalysis/gn_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def snxmap(sinexpaths, outdir):
@_click.option(
"-o",
"--output",
type=_click.Path(exists=True),
type=_click.Path(),
help="output path",
default=_os.curdir + "/merge.sp3",
)
Expand All @@ -326,6 +326,8 @@ def sp3merge(sp3paths, clkpaths, output, nodata_to_nan):
from .gn_io import sp3

_logging.info(msg=output)
if clkpaths == ():
clkpaths = None # clkpaths = None is a conditional used in sp3.sp3merge
merged_df = sp3.sp3merge(sp3paths=sp3paths, clkpaths=clkpaths, nodata_to_nan=nodata_to_nan)
sp3.write_sp3(sp3_df=merged_df, path=output)

Expand Down Expand Up @@ -556,11 +558,25 @@ def trace2mongo(trace_paths, db_name):
default=None,
show_default=True,
)
def orbq(input, output_path, format, csv_separation, json_format, nodata_to_nan, hlm_mode, satellite, constellation, header, index, reject_re):
def orbq(
input,
output_path,
format,
csv_separation,
json_format,
nodata_to_nan,
hlm_mode,
satellite,
constellation,
header,
index,
reject_re,
):
"""
A simple utility to assess pairs of sp3 files
"""
from gnssanalysis import gn_io, gn_aux, gn_diffaux

_logging.basicConfig(level="INFO") # seems that logging can only be configured before the first logging call
logger = _logging.getLogger()
# if verbose:
Expand Down
Loading