Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tickets/dm 48561 #189

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions doc/news/DM-48561.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated the `find_target_simbad` method in `base_tcs.py` to comply with Simbad queries in astroquery version 0.4.8.
45 changes: 23 additions & 22 deletions python/lsst/ts/observatory/control/base_tcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import logging
import typing
import warnings
from functools import partial
from os.path import splitext

import astropy.units as u
Expand Down Expand Up @@ -1682,45 +1683,45 @@ async def find_target_simbad(

customSimbad = Simbad()

customSimbad.add_votable_fields("distance_result", "fluxdata(V)")
customSimbad.add_votable_fields("V", "rvz_redshift", "ident")
customSimbad.TIMEOUT = self.long_long_timeout

radec = self.radec_from_azel(az=az, el=el)

_ra = radec.ra.to_string(u.deg, decimal=True)
_dec = radec.dec.to_string(u.deg, decimal=True, alwayssign=True)
r = Angle(radius * u.deg).to_string(u.deg, decimal=True)

# Build the ADQL-like criteria for V magnitude + HD catalog
criteria = (
f"region(circle,ICRS,{_ra} {_dec},{r}d) & "
f"Vmag > {mag_limit} & Vmag < {mag_limit+mag_range} & "
"cat = HD"
f"V>{mag_limit} AND V<{mag_limit + mag_range} AND ident.id LIKE 'HD%'"
)

loop = asyncio.get_event_loop()
query_callable = partial(
customSimbad.query_region,
coordinates=radec,
radius=radius * u.deg,
criteria=criteria,
)

loop = asyncio.get_event_loop()
try:
result_table = await loop.run_in_executor(
None, customSimbad.query_criteria, criteria
)
result_table = await loop.run_in_executor(None, query_callable)
except Exception as e:
self.log.exception("Querying Simbad failed. {criteria=}")
raise RuntimeError(f"Query {criteria=} failed: {e!r}")
self.log.exception("Querying Simbad failed.")
raise RuntimeError(f"Query region for {radec} failed: {e!r}")

if result_table is None:
raise RuntimeError(f"No result from query: {criteria}.")
if result_table is None or len(result_table) == 0:
raise RuntimeError(f"No results found for region around {radec}.")

result_table.sort("FLUX_V")
result_table.sort("V")

target_main_id = str(result_table["MAIN_ID"][0])
target_ident_id = str(result_table["id"][0])

radec_icrs = ICRS(
ra=Angle(result_table[0]["RA"], unit=u.hourangle),
dec=Angle(result_table[0]["DEC"], unit=u.deg),
ra=Angle(result_table[0]["ra"], unit=u.deg),
dec=Angle(result_table[0]["dec"], unit=u.deg),
)
self.object_list_add(f"{target_main_id}".rstrip(), radec_icrs)

return f"{target_main_id}".rstrip()
self.object_list_add(f"{target_ident_id}".rstrip(), radec_icrs)

return f"{target_ident_id}".rstrip()

async def find_target_local_catalog(
self,
Expand Down