Skip to content

Commit

Permalink
Merge pull request #3 from jchate6/patch-1
Browse files Browse the repository at this point in the history
Quick patch to prevent returning incorrect numbered asteroids when re…
  • Loading branch information
jchate6 authored Jun 21, 2024
2 parents 57e6595 + dd67634 commit ddb163f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion simbad2k/simbad2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ def get_result(self):
schemes = [*self.scheme_mapping]
for scheme in schemes:
for query_param in self.query_params_mapping[scheme]:
params = {'target_type': self.scheme_mapping[scheme], query_param: self.query}
# astroquery has a very robust matching algorythm for "number" and will return elements for
# asteroid #2000 if you ask for "2000 JD1". We do not want to ask for a number when our object name
# is actually a preliminary designation.
# Numbered objects will not have a designation.
# Comets will have letters in their "numbers" i.e. 12P.
if query_param == 'number' and self.scheme_mapping[scheme] == 'asteroid':
try:
params = {'target_type': self.scheme_mapping[scheme], query_param: int(self.query)}
except ValueError:
return None
else:
params = {'target_type': self.scheme_mapping[scheme], query_param: self.query}
result = MPC.query_objects_async(**params).json()
ret_dict = {}
if len(result) > 1:
Expand Down

0 comments on commit ddb163f

Please sign in to comment.