Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
# - name: Restore cached files
# uses: actions/cache/restore@v4
# with:
Expand All @@ -72,7 +72,7 @@ jobs:
# run: |
# echo "OORB_DATA=$GITHUB_WORKSPACE/oorb-data" >> "$GITHUB_ENV"
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: 3.14
- name: Install tox
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/rc_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: rc-testing

on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- name: Release candidate testing on Linux with remote data
os: ubuntu-latest
python: "3.14"
toxenv: py312-test-alldeps-predeps
toxposargs: --remote-data

- name: Release candidate testing on OSX
os: macos-latest
python: "3.12"
toxenv: py311-test-alldeps-predeps

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip tox
- name: Run tests
run: tox -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}
4 changes: 2 additions & 2 deletions docs/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,15 @@ methods.

.. _JPL Horizons: https://ssd.jpl.nasa.gov/horizons/
.. _Minor Planet Center: https://minorplanetcenter.net/
.. _IMCCE: http://vo.imcce.fr/webservices/miriade/
.. _IMCCE: http://ssp.imcce.fr/webservices/miriade/
.. _Lowell Observatory: https://asteroid.lowell.edu/gui/
.. _PyEphem: https://rhodesmill.org/pyephem
.. _REBOUND: https://github.com/hannorein/rebound
.. _OpenOrb: https://github.com/oorb/oorb
.. _SpiceyPy: https://github.com/AndrewAnnex/SpiceyPy
.. _web-API: https://minorplanetcenter.net/search_db
.. _Solar System Object Image Search function of the Canadian Astronomy Data Centre: https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/en/ssois/
.. _skybot: http://vo.imcce.fr/webservices/skybot/
.. _skybot: http://ssp.imcce.fr/webservices/skybot/
.. _small bodies data ferret: https://sbnapps.psi.edu/ferret
.. _github wiki: https://github.com/mommermi/sbpy/wiki
.. _Ginga Image Viewer: https://ejeschke.github.io/ginga/
Expand Down
2 changes: 1 addition & 1 deletion docs/sbpy/data/ephem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ IMCCE's Miriade (`~sbpy.data.Ephem.from_miriade`)
-------------------------------------------------

Finally, `~sbpy.data.Ephem.from_miriade` will retrieve ephemerides from the
`Miriade ephemeris generator <http://vo.imcce.fr/webservices/miriade/>`_ at
`Miriade ephemeris generator <https://ssp.imcce.fr/webservices/miriade/>`_ at
`Institut de Mécanique Céleste et de Calcul des Éphémérides
<https://www.imcce.fr/>`_:

Expand Down
14 changes: 7 additions & 7 deletions sbpy/data/ephem/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ def run(cls) -> None: # pragma: no cover
print(str(e), file=sys.stderr)
sys.exit(1)

print(
f"""# requested target: {cli.args.target}
print(f"""# requested target: {cli.args.target}
# returned target: {cli.eph.meta['target']}
# location: {cli.args.location}"""
)
# location: {cli.args.location}""")
cli.eph.table.pprint_all()

@staticmethod
Expand Down Expand Up @@ -344,8 +342,10 @@ def _format_eph(self, eph: Ephem) -> Ephem:
fields.insert(0, fields.pop(fields.index(k)))

eph = eph[fields]
target = eph["target"][0]
del eph.table["target"]
eph.table.meta["target"] = target

if "target" in eph:
target = eph["target"][0]
del eph.table["target"]
eph.table.meta["target"] = target

return eph
8 changes: 4 additions & 4 deletions sbpy/data/ephem/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,15 @@ def from_mpc(
@requires("astroquery")
@cite(
{
"data source": "https://vo.imcce.fr/webservices/miriade/",
"data source": "https://ssp.imcce.fr/webservices/miriade/",
"software: astroquery": "2019AJ....157...98G",
}
)
def from_miriade(
cls, targetids, objtype="asteroid", epochs=None, location="500", **kwargs
):
"""Load target ephemerides from
`IMCCE Miriade <https://vo.imcce.fr/webservices/miriade/>`_ using
`IMCCE Miriade <https://ssp.imcce.fr/webservices/miriade/>`_ using
`astroquery.imcce.MiriadeClass.get_ephemerides`

Parameters
Expand Down Expand Up @@ -591,8 +591,8 @@ def from_miriade(
-----
* For detailed explanations of the queried fields, refer to
`astroquery.imcce.MiriadeClass.get_ephemerides` and the
`Miriade documentation
<https://vo.imcce.fr/webservices/miriade/?documentation>`_.
`Miriade ephemeris documentation
<https://ssp.imcce.fr/webservices/miriade/api/ephemcc/>`_.
* By default, all properties are provided in the J2000.0 reference
system. Different settings can be chosen using
additional keyword arguments as used by
Expand Down
112 changes: 65 additions & 47 deletions sbpy/data/obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@
from ..bib import cite
from ..utils.decorators import requires

__all__ = ['Obs']
__all__ = ["Obs"]


class Obs(Ephem):
"""Class for querying, storing, and manipulating observations """
"""Class for querying, storing, and manipulating observations"""

@classmethod
@requires("astroquery")
@cite({'data source': 'https://minorplanetcenter.net/db_search',
'software: astroquery': '2019AJ....157...98G'})
@cite(
{
"data source": "https://minorplanetcenter.net/db_search",
"software: astroquery": "2019AJ....157...98G",
}
)
def from_mpc(cls, targetid, id_type=None, **kwargs):
"""Load available observations for a target from the
`Minor Planet Center <https://minorplanetcenter.net>`_ using
Expand Down Expand Up @@ -78,34 +82,41 @@ def from_mpc(cls, targetid, id_type=None, **kwargs):

if id_type is None:
id_type = Names.asteroid_or_comet(targetid)
if id_type == 'asteroid':
if id_type == "asteroid":
ident = Names.parse_asteroid(targetid)
elif id_type == 'comet':
elif id_type == "comet":
ident = Names.parse_comet(targetid)
if 'number' in ident:
id_type += ' number'
elif 'designation' in ident:
id_type += ' designation'
if "number" in ident:
id_type += " number"
elif "designation" in ident:
id_type += " designation"

try:
results = MPC.get_observations(targetid, id_type=id_type,
**kwargs)
results = MPC.get_observations(targetid, id_type=id_type, **kwargs)
except (RuntimeError, ValueError) as e:
raise QueryError(
('Error raised by '
'astroquery.mpc.MPCClass.get_observations: '
'{}').format(e))
(
"Error raised by " "astroquery.mpc.MPCClass.get_observations: " "{}"
).format(e)
)

results['epoch'] = Time(results['epoch'].to('d').value,
scale='utc', format='jd')
results["epoch"] = Time(
results["epoch"].to("d").value, scale="utc", format="jd"
)

return cls.from_table(results)

@requires("astroquery")
@cite({'software: astroquery': '2019AJ....157...98G'})
def supplement(self, service='jplhorizons', id_field='targetname',
epoch_field='epoch', location='500',
modify_fieldnames='obs', **kwargs):
@cite({"software: astroquery": "2019AJ....157...98G"})
def supplement(
self,
service="jplhorizons",
id_field="targetname",
epoch_field="epoch",
location="500",
modify_fieldnames="obs",
**kwargs,
):
"""Supplement observational data with ephemerides
queried from the selected service.

Expand All @@ -120,7 +131,7 @@ def supplement(self, service='jplhorizons', id_field='targetname',
<https://minorplanetcenter.net/iau/MPEph/MPEph.html>`_
(using `~sbpy.data.Ephem.from_mpc`), and
the `IMCCE Miriade service
<http://vo.imcce.fr/webservices/miriade/>`_
<https://ssp.imcce.fr/webservices/miriade/>`_
(using `~sbpy.data.from_miriade`). Default:
``'jplhorizons'``
id_field : str, optional
Expand Down Expand Up @@ -169,8 +180,7 @@ def supplement(self, service='jplhorizons', id_field='targetname',
try:
targetids = set(self[id_field])
except (TypeError, KeyError):
raise QueryError('cannot use field {} as id_field.'.format(
id_field))
raise QueryError("cannot use field {} as id_field.".format(id_field))

all_obs = None
all_eph = None
Expand All @@ -179,46 +189,54 @@ def supplement(self, service='jplhorizons', id_field='targetname',
if all_obs is None:
all_obs = self.table[self[id_field] == targetid]
else:
all_obs = vstack([all_obs,
self.table[self[id_field] == targetid]])
all_obs = vstack([all_obs, self.table[self[id_field] == targetid]])

if service == 'jplhorizons':
if service == "jplhorizons":
eph = Ephem.from_horizons(
targetid,
epochs=self[self[id_field] == targetid][epoch_field],
location=location,
**kwargs)
eph.table.remove_column('epoch')
elif service == 'mpc':
**kwargs,
)
eph.table.remove_column("epoch")
elif service == "mpc":
eph = Ephem.from_mpc(
targetid,
epochs=self[self[id_field] == targetid][epoch_field],
location=location,
**kwargs)
eph.table.remove_column('Date')
elif service == 'miriade':
**kwargs,
)
eph.table.remove_column("Date")
elif service == "miriade":
eph = Ephem.from_miriade(
targetid,
epochs=self[self[id_field] == targetid][epoch_field],
location=location,
**kwargs)
eph.table.remove_column('epoch')
**kwargs,
)
eph.table.remove_column("epoch")
else:
raise QueryError('service {} not known.'.format(service))
raise QueryError("service {} not known.".format(service))

if all_eph is None:
all_eph = eph.table
else:
all_eph = vstack([all_eph, eph.table])

# identify field names that both obs and eph have in common
fieldnames_intersect = set(all_eph.columns).intersection(
all_obs.columns)
for fieldname in fieldnames_intersect:
if modify_fieldnames == 'obs':
all_obs.rename_column(fieldname, fieldname+'_obs')
elif modify_fieldnames == 'eph':
all_eph.rename_column(fieldname, fieldname+'_eph')

return Obs.from_table(hstack([all_obs, all_eph]),
meta=self.meta)
# promote to sbpy objects to normalize field names
all_obs = Obs.from_table(all_obs, meta=self.meta)
all_eph = Ephem.from_table(all_eph)

# insert eph columns into obs, renaming conflicts as requested
for k in all_eph.field_names:
name = k
if name in all_obs:
if modify_fieldnames == "obs":
all_obs[name].name = name + "_obs"
elif modify_fieldnames == "eph":
name = k + "_eph"
else:
raise ValueError(f"Invalid modify_fieldnames={modify_fieldnames}")
all_obs[name] = all_eph[k]

return all_obs
Loading
Loading