-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrics.py
More file actions
34 lines (26 loc) · 936 Bytes
/
metrics.py
File metadata and controls
34 lines (26 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 25 18:07:42 2017
@author: vostok
"""
from numpy import empty_like
def icp_metric(image_stars, catalog_stars, vectors=False):
closest_distances = empty_like(image_stars['X'])
closest_indices = empty_like(image_stars['X'])
catalog_X, catalog_Y = catalog_stars
for i, star in enumerate(image_stars):
dx = star['X'] - catalog_X
dy = star['Y'] - catalog_Y
r2 = dx**2 + dy**2
closest_distances[i] = r2.min()
closest_indices[i] = r2.argmin()
if not vectors:
return closest_distances.sum()
return closest_distances.sum(), \
closest_distances, closest_indices.astype('int')
def metric(image_stars, catalog_stars):
catalog_X, catalog_Y = catalog_stars
dx = image_stars['X'] - catalog_X
dy = image_stars['Y'] - catalog_Y
r2 = dx**2 + dy**2
return r2.sum()