seafloor-geodesy / gnatss

Community Seafloor Global Navigation Satellite Systems - Acoustic (GNSS-A) Transponder Surveying Software
https://gnatss.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
10 stars 14 forks source link

Bug: perform_solve() fails with error code "matrix must not have NaNs or infs" #308

Open johnbdesanto opened 1 week ago

johnbdesanto commented 1 week ago

I got this error code after a failed run. Many records in the gps_solutions.csv file have null values for the covariance matrix, but the same error code is triggered even when I manually add these epochs to the deletions file. Needs more investigation.

Traceback (most recent call last):

  File "/home/jdesanto/miniconda3/envs/gipsyx/bin/gnatss", line 8, in <module>
    sys.exit(app())

  File "/home/jdesanto/miniconda3/envs/gipsyx/lib/python3.10/site-packages/gnatss/cli.py", line 100, in run
    run_gnatss(

  File "/home/jdesanto/miniconda3/envs/gipsyx/lib/python3.10/site-packages/gnatss/main.py", line 110, in run_gnatss
    data_dict = run_solver(config, data_dict, return_raw=return_raw)

  File "/home/jdesanto/miniconda3/envs/gipsyx/lib/python3.10/site-packages/gnatss/solver/run.py", line 33, in run_solver
    process_data, is_converged = prepare_and_solve(all_observations, config, twtt_model=twtt_model)

  File "/home/jdesanto/miniconda3/envs/gipsyx/lib/python3.10/site-packages/gnatss/solver/utilities.py", line 414, in prepare_and_solve
    all_results = perform_solve(

  File "/home/jdesanto/miniconda3/envs/gipsyx/lib/python3.10/site-packages/numba/np/linalg.py", line 827, in _check_finite_matrix
    raise np.linalg.LinAlgError(

numpy.linalg.LinAlgError: Array must not contain infs or NaNs.
johnbdesanto commented 1 week ago

After troubleshooting the data set, it looks like the above error resulted from missing antenna positions during one of the days I was processing. The GNSS positioning failed, so there were no positions to interpolate during the posfilter step. This didn't break the posfilter, but must have led to poor data being written to the gps_solutions.csv file since the solver failed.

The bug fix would probably be to make sure there is positioning data within some amount of time from each epoch during the Kalman filter, and to skip the epoch if there is no positioning data.