Skip to content

Commit bc5bd05

Browse files
authored
Merge pull request #83 from GeoscienceAustralia/NPI-3973-debug-sinex-stypes
NPI-3973 Better errors and exceptions for Sinex reading
2 parents 4eb7a63 + f678609 commit bc5bd05

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

gnssanalysis/gn_frame.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_frame_of_day(
3535
):
3636
"""Main function to propagate frame into datetime of interest"""
3737

38-
if isinstance(date_or_j2000, (int, _np.int64)):
38+
if isinstance(date_or_j2000, (int, _np.int64)): # TODO check: np.int64 is meant to be a class not a type
3939
date_J2000 = date_or_j2000
4040
else:
4141
date_J2000 = _gn_datetime.datetime2j2000(_np.datetime64(date_or_j2000))
@@ -53,6 +53,8 @@ def get_frame_of_day(
5353
output = itrf_path_or_df
5454
elif isinstance(itrf_path_or_df, str):
5555
output = _gn_io.sinex._get_snx_vector_gzchunks(filename=itrf_path_or_df, block_name="SOLUTION/ESTIMATE")
56+
if output is None:
57+
raise Exception(f"Output from _get_snx_vector_gzchunks() was None! Filepath: {itrf_path_or_df}")
5658
else:
5759
raise ValueError(f"itrf_path_or_df must be a pandas DataFrame or str, got: {type(itrf_path_or_df)}")
5860

gnssanalysis/gn_io/sinex.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def _get_valid_stypes(stypes: Union[list[str], set[str]]) -> _List[str]:
327327
"""Returns only stypes in allowed list
328328
Fastest if stypes size is small"""
329329
allowed_stypes = ["EST", "APR", "NEQ"]
330-
stypes = set(stypes) if not isinstance(stypes, set) else stypes
330+
stypes = set(stypes) if not isinstance(stypes, set) else stypes # Convert to set if not one.
331331
ok_stypes = sorted(stypes.intersection(allowed_stypes), key=allowed_stypes.index) # need EST to always be first
332332
if len(ok_stypes) != len(stypes):
333333
not_ok_stypes = stypes.difference(allowed_stypes)
@@ -544,12 +544,17 @@ def _get_snx_vector(
544544
if isinstance(path_or_bytes, str):
545545
path = path_or_bytes
546546
snx_bytes = _gn_io.common.path2bytes(path)
547-
# TODO Removed this very broken code path, not sure what happened
548-
# elif isinstance(path_or_bytes, list):
549-
# path, stypes, format, verbose = path_or_bytes
550-
# snx_bytes = _gn_io.common.path2bytes(path)
551-
else:
547+
# Very weird code path, should be removed if possible
548+
elif isinstance(path_or_bytes, list):
549+
_logging.error(
550+
f"path_or_bytes was a list! Using legacy code path. Please update this! Input values: {path_or_bytes}"
551+
)
552+
path, stypes, format, verbose = path_or_bytes
553+
snx_bytes = _gn_io.common.path2bytes(path)
554+
elif isinstance(path_or_bytes, bytes):
552555
snx_bytes = path_or_bytes
556+
else:
557+
raise ValueError(f"Unexpected type for path_or_bytes: {type(path_or_bytes)}. Value: {path_or_bytes}")
553558

554559
if snx_header == {}:
555560
snx_header = _get_snx_header(
@@ -560,7 +565,9 @@ def _get_snx_vector(
560565
"Indices are likely inconsistent between ESTIMATE and APRIORI in the EMR AC files hence files might be parsed incorrectly"
561566
)
562567

568+
_logging.info(f"Passing stypes through SType validator: {stypes}. Input path if available: {path}")
563569
stypes = _get_valid_stypes(stypes) # EST is always first as APR may have skips
570+
_logging.info(f"STypes after validator: {stypes}. Input path if available: {path}")
564571

565572
extracted = _snx_extract(snx_bytes=snx_bytes, stypes=stypes, obj_type="VECTOR", verbose=verbose)
566573
if extracted is None:

0 commit comments

Comments
 (0)