ImageD11.closest
index
c:\python25\lib\site-packages\imaged11\closest.pyd

/* *******************************************************************
* closest.c  Two useful functions for indexing grains 
*
* 1. From python: closest(cosines_allowed, cosine_measured)
*    Take 1 peak with hkl's assigned, compute the cosines to
*    another powder ring (angles between this peak and peaks in
*    that ring). This extension finds the best peak in the
*    other ring to pair up with.
*
*    More generally closest(array, values) finds the closest
*    item in values to one of the values in array.  Returns the
*    difference and the index of the closest thing it finds.
*
*    Both arguments should be one dimensional Numeric arrays
*    of type Numeric.Float
*
* 2. From python: score(ubi, gv, tol) where ubi is an orientation
*    matrix and gv are an array of g-vectors. Returns the number
*    of g-vectors which have integer hkl peaks within tolerance
*    tol. Uses the conv_double_to_int_fast function in here for 
*    factor of !EIGHT! speed increase compared to rounding in 
*    C. In fact this gives the nearest even integer, instead
*    of the nearest integer, but we don't care, as a peak having
*    hkl of 0.5 is nowhere near being indexed anyway.
*
*    Returns and integer - number of peaks indexed
*    UBI is a 3x3 Numeric.Float array (figure out the transposing yourself)
*    GV is a nx3 Numeric.Float array, and you should try to make the 3 
*       be the fast index for best performance
*       
* 3. From python: same as score, I hope, but ubi is overwritten
*    with refined matrix following paciorek algorithm which is 
*    in indexing.py
*    
* ****************************************************************** */

 
Functions
       
closest(...)
int,float closest(x,v)
Find element in x closest to one in v
x,v 1D flat Float arrays
score(...)
int score(ubi,gv,tol)
Find number of gv which are integer h within tol
score_and_refine(...)
int score_and_refine(ubi,gv,tol)
Find number of gv which are integer h within tol and overwrite UB with refined