Skip to content

FieldError for "r" column in MPC ephemeris #451

Description

@phtnnz

High-level problem description
FieldError raised for querying MPC ephemeris for a particular object and time (epoch)

What did you do?

    loc = EarthLocation(lat=-23.23639*u.deg, lon=16.36167*u.deg , height=1825*u.m) # M49, Hakos, Namibia
    obj = "2026 JH2"

    ## Working example
    epochs = {"start":  Time('2026-05-20 00:00:00.000'),
              "step":   30 * u.min,
              "stop":   Time('2026-05-20 06:00:00.000')
             }
    eph = Ephem.from_mpc(obj, location=loc, epochs=epochs)
    ic(eph)

    ## This epochs setting raises a FieldError exception
    epochs = {"start":  Time('2026-05-19 00:00:00.000'),
              "step":   30 * u.min,
              "stop":   Time('2026-05-19 06:00:00.000')
             }
    eph = Ephem.from_mpc(obj, location=loc, epochs=epochs)
    ic(eph)

What did you expect?
Both code snippets should output the ephemeris for the requested epochs range.

What did really happen?
The second epochs setting raises a FieldError as follows

WARNING: column r has a unit but is kept as a Column as an attempt to convert it to Quantity failed with:
TypeError('The value must be a valid Python or Numpy numeric type.') [astropy.table.table]
Traceback (most recent call last):
  File "D:\Users\mj\src\python\astropy-workbench\test-ephem-error.py", line 61, in <module>
    main()
  File "D:\Users\mj\src\python\astropy-workbench\test-ephem-error.py", line 55, in main
    eph = Ephem.from_mpc(obj, location=loc, epochs=epochs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\mj\src\python\astropy-workbench\venv\Lib\site-packages\sbpy\utils\decorators.py", line 78, in wrapper
    return wrapped_function(*func_args, **func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\mj\src\python\astropy-workbench\venv\Lib\site-packages\sbpy\bib\core.py", line 183, in wrapper
    result = f(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^
  File "D:\Users\mj\src\python\astropy-workbench\venv\Lib\site-packages\sbpy\data\ephem\core.py", line 534, in from_mpc
    return cls.from_table(all_eph)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\mj\src\python\astropy-workbench\venv\Lib\site-packages\sbpy\data\core.py", line 514, in from_table
    tab.table = QTable(table, meta={**table.meta, **meta}, **kwargs)
    ^^^^^^^^^
  File "D:\Users\mj\src\python\astropy-workbench\venv\Lib\site-packages\sbpy\data\core.py", line 743, in table
    self.verify_fields()
  File "D:\Users\mj\src\python\astropy-workbench\venv\Lib\site-packages\sbpy\data\core.py", line 922, in verify_fields
    raise FieldError(
sbpy.data.core.FieldError: Field r is not an instance of <class 'astropy.units.quantity.Quantity'>

Querying the MPC ephemeris service on the web shows an valid "r" column for both dates.

Provide information on your environment:
Windows 11, Python 3.12
sbpy version: 0.6.0
astropy version: 7.2.0
numpy version: 2.3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    potential bugautomated label to indicate issue reports

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions