rahil-makadia / grss

Gauss-Radau Small-body Simulator. Maintainer: @rahil-makadia
https://rahil-makadia.github.io/grss/
MIT License
4 stars 0 forks source link

get_mpc_optical_obs_array crashes when querying optical observations #45

Closed Pachacoti closed 6 months ago

Pachacoti commented 6 months ago

By chance I was confronted with a new issue that get_mpc_optical_obs_array crashed when reading optical observations of 530871:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mthui/Software/anaconda3/lib/python3.9/site-packages/grss/fit/fit_optical.py", line 955, in get_mpc_optical_obs_array
    observer_program_codes) = get_optical_data(body_id, de_kernel_path, optical_obs_file,
  File "/home/mthui/Software/anaconda3/lib/python3.9/site-packages/grss/fit/fit_optical.py", line 137, in get_optical_data
    full_obs_code = get_space_based_observer_code(obs_time_mjd_tdb, first_80, last_80)
  File "/home/mthui/Software/anaconda3/lib/python3.9/site-packages/grss/fit/fit_optical.py", line 37, in get_space_based_observer_code
    if last_80[32] == '1':
IndexError: string index out of range

I suspect that this issue is caused by the following observation:

 r0871K10A85R* x2010 01 07.86121 21 48 04.53 +63 48 59.2                L~0I1lC51

which, unlike other C51 measurements, does not contain the state vector of the spacecraft.

rahil-makadia commented 6 months ago

Seems like according to the MPC's website, observations of type X/x are meant to serve as discovery records rather than be used in orbit fits:

In addition, there are 'X' and 'x' which are used only for already-filed observations. 'X' was given originally only to discovery observations that were approximate or semi-accurate and that had accurate measures corresponding to the time of discovery: this has been extended to other replaced discovery observations. Observations marked 'X'/'x' are to be suppressed in residual blocks. They are retained so that there exists an original record of a discovery. These codes MUST NOT be used on observation submissions.

This is further evidenced by the lack of a secondary record of the observation containing the WISE spacecraft state as you pointed out.

I just merged a PR into main addressing this change, so the error should be taken care of. Feel free to pull the new version and install locally or give it a few minutes to upload v3.3.0 to PyPI and install using pip.

Closing this for now, feel free to reopen if you run into any more issues fitting this orbit.