def find_subpixel_peak_position(corr, subpixel_method='<STR_LIT>'):
<EOL>default_peak_position = (corr.shape[<NUM_LIT:0>]/<NUM_LIT:2>,corr.shape[<NUM_LIT:1>]/<NUM_LIT:2>)<EOL>peak1_i, peak1_j, dummy = find_first_peak(corr)<EOL>try:<EOL><INDENT>c = corr[peak1_i, peak1_j]<EOL>cl = corr[peak1_i-<NUM_LIT:1>, peak1_j]<EOL>cr = corr[peak1_i+<NUM_LIT:1>, peak1_j]<EOL>cd = corr[peak1_i, peak1_j-<NUM_LIT:1>] <EOL>cu = corr[peak1_i, peak1_j+<NUM_LIT:1>]<EOL>if np.any(np.array([c,cl,cr,cd,cu]) < <NUM_LIT:0>) and subpixel_method == '<STR_LIT>':<EOL><INDENT>subpixel_method = '<STR_LIT>'<EOL><DEDENT>try: <EOL><INDENT>if subpixel_method == '<STR_LIT>':<EOL><INDENT>subp_peak_position = (((peak1_i-<NUM_LIT:1>)*cl+peak1_i*c+(peak1_i+<NUM_LIT:1>)*cr)/(cl+c+cr),<EOL>((peak1_j-<NUM_LIT:1>)*cd+peak1_j*c+(peak1_j+<NUM_LIT:1>)*cu)/(cd+c+cu))<EOL><DEDENT>elif subpixel_method == '<STR_LIT>':<EOL><INDENT>subp_peak_position = (peak1_i + ((np.log(cl)-np.log(cr))/(<NUM_LIT:2>*np.log(cl) - <NUM_LIT:4>*np.log(c) + <NUM_LIT:2>*np.log(cr))),<EOL>peak1_j + ((np.log(cd)-np.log(cu))/( <NUM_LIT:2>*np.log(cd) - <NUM_LIT:4>*np.log(c) + <NUM_LIT:2>*np.log(cu)))) <EOL><DEDENT>elif subpixel_method == '<STR_LIT>':<EOL><INDENT>subp_peak_position = (peak1_i +  (cl-cr)/(<NUM_LIT:2>*cl-<NUM_LIT:4>*c+<NUM_LIT:2>*cr),<EOL>peak1_j +  (cd-cu)/(<NUM_LIT:2>*cd-<NUM_LIT:4>*c+<NUM_LIT:2>*cu)) <EOL><DEDENT><DEDENT>except: <EOL><INDENT>subp_peak_position = default_peak_position<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>subp_peak_position = default_peak_position<EOL><DEDENT>return subp_peak_position[<NUM_LIT:0>], subp_peak_position[<NUM_LIT:1>]<EOL>
Find subpixel approximation of the correlation peak.

This function returns a subpixels approximation of the correlation
peak by using one of the several methods available. If requested, 
the function also returns the signal to noise ratio level evaluated 
from the correlation map.

Parameters
----------
corr : np.ndarray
    the correlation map.

subpixel_method : string
     one of the following methods to estimate subpixel location of the peak: 
     'centroid' [replaces default if correlation map is negative], 
     'gaussian' [default if correlation map is positive], 
     'parabolic'.

Returns
-------
subp_peak_position : two elements tuple
    the fractional row and column indices for the sub-pixel
    approximation of the correlation peak.

Original code from openPIV pyprocess