Skip to content

Commit

Permalink
Merge pull request #20 from GeoscienceAustralia/NPI-3290-clearer-erro…
Browse files Browse the repository at this point in the history
…r-on-empty-sinex-header

NPI-3290 Clearer error on empty Sinex header
  • Loading branch information
ronaldmaj authored May 16, 2024
2 parents 02861d7 + 2a8802d commit c5e5179
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gnssanalysis/gn_io/sinex.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def _get_snx_header(path_or_bytes):
header_begin = snx_bytes.find(b"%=SNX")
header_end = snx_bytes.find(b"\n", header_begin)
snx_hline = snx_bytes[header_begin:header_end].decode()
if len(snx_hline) == 0: # Raise an inteligible error if the Sinex header is effectively empty.
# Is the source bytes, or a path / str path? If not bytes, we can output it.
if isinstance(path_or_bytes, bytes):
raise ValueError(f"Sinex header is empty for UNKNOWN file (passed in as bytes object not path)")
else:
raise ValueError(f"Sinex header is empty for file: '{str(path_or_bytes)}'")
dates = _gn_datetime.yydoysec2datetime([snx_hline[15:27], snx_hline[32:44], snx_hline[45:57]]).tolist()
return {
"version": float(snx_hline[6:10]),
Expand Down

0 comments on commit c5e5179

Please sign in to comment.