Skip to content

Commit

Permalink
add support for 'return_catalog' option
Browse files Browse the repository at this point in the history
  • Loading branch information
smroid committed Dec 25, 2024
1 parent a3220ce commit ed92db9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions examples/test_tetra3.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import tetra3

# centre is (y, x).
def draw_circle(img_draw, centre, radius, **kwargs):
bbox = [centre[1] - radius, centre[0] - radius, centre[1] + radius, centre[0] + radius]
img_draw.ellipse(bbox, **kwargs)
Expand Down Expand Up @@ -43,7 +44,6 @@ def draw_box(img_draw, centre, radius, **kwargs):
# path = EXAMPLES_DIR / 'data' / 'large_fov'
try:
for impath in path.glob('*'):
# for impath in path.glob('img_110ms_20241209_042605.bmp'):
try:
with Image.open(str(impath)) as img:
img = img.convert(mode='L')
Expand Down Expand Up @@ -81,19 +81,26 @@ def draw_box(img_draw, centre, radius, **kwargs):
trimmed_centroids = centroids[:30]
solution = t3.solve_from_centroids(
trimmed_centroids, (height, width),
return_matches=True, solve_timeout=5000,
return_matches=True, return_catalog=True, solve_timeout=5000,
distortion=0)

if 'matched_centroids' in solution:
# Draw a green box around each matched star.
for cent in solution['matched_centroids']:
draw_box(img_draw, cent, 6, outline=(32, 192, 32))
draw_box(img_draw, cent, 7, outline=(32, 192, 32))
# Draw a red box around each pattern star.
for cent in solution['pattern_centroids']:
draw_box(img_draw, cent, 6, outline=(192, 32, 32))
draw_box(img_draw, cent, 7, outline=(192, 32, 32))

if 'catalog_stars' in solution:
# Draw a yellow box around each catalog star.
for star in solution['catalog_stars']:
# star is (RA, Dec, mag, y, x).
draw_box(img_draw, [star[3], star[4]], 5, outline=(192, 192, 32))

# Don't clutter printed solution with these fields.
solution.pop('matched_centroids', None)
solution.pop('catalog_stars', None)
solution.pop('matched_stars', None)
solution.pop('matched_catID', None)
solution.pop('pattern_centroids', None)
Expand Down

0 comments on commit ed92db9

Please sign in to comment.