def neighbours(self, effective_temperature, surface_gravity, metallicity, N,
scales=None):
"""
Return indices of the `N`th-nearest neighbours in the grid. The three
parameters are scaled by the peak-to-peak range in the grid, unless
`scales` are indicates.
:param effective_temperature:
The effective temperature of the star.
:param surface_gravity:
The surface gravity of the star.
:param metallicity:
The metallicity of the star.
:param N:
The number of neighbouring indices to return.
:returns:
An array of length `N` that contains the indices of the closest
neighbours in the grid.
"""
point = np.array([effective_temperature, surface_gravity, metallicity])
if scales is None:
scales = np.ptp(self._grid, axis=0)
distance = np.sum(((self._grid - point)/scales)**2, axis=1)
return np.argsort(distance)[:N]
评论列表
文章目录