def test_point_distance(self, chi_coords, distance_threshold): """ Test if the distance between the supplied point and the bank is less than the supplied distance theshold. Parameters ----------- chi_coords : numpy.array The position of the point in the chi coordinates. distance_threshold : float The **SQUARE ROOT** of the metric distance to test as threshold. E.g. if you want to test to a minimal match of 0.97 you would use 1 - 0.97 = 0.03 for this value. Returns -------- Boolean True if point is within the distance threshold. False if not. """ chi1_bin, chi2_bin = self.find_point_bin(chi_coords) for chi1_bin_offset, chi2_bin_offset in self.bin_loop_order: curr_chi1_bin = chi1_bin + chi1_bin_offset curr_chi2_bin = chi2_bin + chi2_bin_offset for bank_chis in self.bank[curr_chi1_bin][curr_chi2_bin]: dist = coord_utils.calc_point_dist(chi_coords, bank_chis) if dist < distance_threshold: return True else: return False
def calc_point_distance(self, chi_coords): """ Calculate distance between point and the bank. Return the closest distance. Parameters ----------- chi_coords : numpy.array The position of the point in the chi coordinates. Returns -------- min_dist : float The smallest **SQUARED** metric distance between the test point and the bank. indexes : The chi1_bin, chi2_bin and position within that bin at which the closest matching point lies. """ chi1_bin, chi2_bin = self.find_point_bin(chi_coords) min_dist = 1000000000 indexes = None for chi1_bin_offset, chi2_bin_offset in self.bin_loop_order: curr_chi1_bin = chi1_bin + chi1_bin_offset curr_chi2_bin = chi2_bin + chi2_bin_offset for idx, bank_chis in \ enumerate(self.bank[curr_chi1_bin][curr_chi2_bin]): dist = coord_utils.calc_point_dist(chi_coords, bank_chis) if dist < min_dist: min_dist = dist indexes = (curr_chi1_bin, curr_chi2_bin, idx) return min_dist, indexes