def find_two_peaks(data, remove_background=True):
y  = _n.array( data            )<EOL>x  = _n.array( list(range(<NUM_LIT:0>,len(y))) )<EOL>if remove_background:<EOL><INDENT>[slope, offset] = fit_linear(x,y)<EOL>y = y - slope*x<EOL>y = y - min(y)<EOL><DEDENT>max1   = max(y)<EOL>n1     = index(max1, y)<EOL>np = n1+<NUM_LIT:1><EOL>nm = n1-<NUM_LIT:1><EOL>yp = max1<EOL>ym = max1<EOL>width = <NUM_LIT:0><EOL>while <NUM_LIT:0> < np < len(y) and <NUM_LIT:0> < nm < len(y):<EOL><INDENT>yp = y[np]<EOL>ym = y[nm]<EOL>if yp <= <NUM_LIT:0.5>*max1 or ym <= <NUM_LIT:0.5>*max1:<EOL><INDENT>width = np - n1<EOL>break<EOL><DEDENT>np += <NUM_LIT:1><EOL>nm -= <NUM_LIT:1><EOL><DEDENT>if width == <NUM_LIT:0>:<EOL><INDENT>return [n1,-<NUM_LIT:1>]<EOL><DEDENT>n2 = nm<EOL>while <NUM_LIT:1> < np < len(y)-<NUM_LIT:1> and <NUM_LIT:1> < nm < len(y)-<NUM_LIT:1>:<EOL><INDENT>if y[np] > y[n2]:<EOL><INDENT>n2 = np<EOL><DEDENT>if y[nm] > y[n2]:<EOL><INDENT>n2 = nm<EOL><DEDENT>np += <NUM_LIT:1><EOL>nm -= <NUM_LIT:1><EOL><DEDENT>return([n1,n2])<EOL>
Returns two indicies for the two maxima