def _tp_finder(self, dcycle):   
<EOL>last_cycle = int(self.se.cycles[len(self.se.cycles)-<NUM_LIT:1>])<EOL>cyc_tp = list(range(<NUM_LIT:1>,last_cycle + dcycle, dcycle))<EOL>all_data = array(self.get(cyc_tp,['<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>']))<EOL>c_nf = np.zeros(len(all_data))<EOL>o_nf = np.zeros(len(all_data))<EOL>for i in range(len(all_data)):<EOL><INDENT>c_nf[i] = all_data[i][<NUM_LIT:0>] + all_data[i][<NUM_LIT:1>]<EOL>o_nf[i] = all_data[i][<NUM_LIT:2>] + all_data[i][<NUM_LIT:3>] + all_data[i][<NUM_LIT:4>]<EOL><DEDENT>co_ratio = (old_div(c_nf, o_nf)) * <NUM_LIT> / <NUM_LIT><EOL>tp_guess     = <NUM_LIT:200>   <EOL>tp_guess_max = <NUM_LIT:200>   <EOL>gi = <NUM_LIT:0><EOL>gn = <NUM_LIT:0><EOL>while gi != <NUM_LIT:1> and gn < <NUM_LIT>:<EOL><INDENT>tp_ind = list()<EOL>i = <NUM_LIT:0><EOL>while i < len(co_ratio)-<NUM_LIT:2>:<EOL><INDENT>gcompar= old_div(<NUM_LIT:1.>, (dcycle*tp_guess*<NUM_LIT>))<EOL>slope1 = old_div((co_ratio[i+<NUM_LIT:1>]-co_ratio[i]),(dcycle))<EOL>slope2 = old_div((co_ratio[i+<NUM_LIT:2>]-co_ratio[i+<NUM_LIT:1>]),dcycle)<EOL>if slope1 > gcompar and slope2 < gcompar and co_ratio[i+<NUM_LIT:1>] > co_ratio[i]:<EOL><INDENT>tp_ind.append(i+<NUM_LIT:1>)<EOL>i += <NUM_LIT:3>   <EOL><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>if abs(len(tp_ind) - tp_guess) < old_div(tp_guess,<NUM_LIT:2>):   <EOL><INDENT>gi = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>gn += <NUM_LIT:1><EOL>tp_guess /= <NUM_LIT:2><EOL><DEDENT><DEDENT>if len(tp_ind) > tp_guess_max:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>tp_startf = zeros(len(tp_ind))   <EOL>for i in range(len(tp_startf)):<EOL><INDENT>tp_startf[i] = cyc_tp[tp_ind[i]]<EOL><DEDENT>tp_limits = zeros(len(tp_startf)+<NUM_LIT:1>)<EOL>for i in range(len(tp_startf)):<EOL><INDENT>tp_limits[i] = tp_startf[i]<EOL><DEDENT>tp_limits[len(tp_limits)-<NUM_LIT:1>] = int(self.se.cycles[len(self.se.cycles)-<NUM_LIT:1>])<EOL>tp_pos = list()<EOL>for i in range(len(tp_startf)):<EOL><INDENT>tp_pos.append(int(tp_limits[i] + <NUM_LIT> * (tp_limits[i+<NUM_LIT:1>] - tp_limits[i])))<EOL><DEDENT>co_return = zeros(len(tp_pos))<EOL>for i in range(len(tp_pos)):<EOL><INDENT>co_return[i] = co_ratio[tp_ind[i]]<EOL><DEDENT>return tp_pos,co_return<EOL>
Routine to find thermal pulses in given star and returns an
index vector that gives the cycle number in which the thermal
pulse occure.

The routine looks for the C/O ratio jumping up and up, so only
useful in TP-AGB star.  A vector is given back that indicates
the position of the cycle that is at 95% of the thermal pulse
(to make sure it's not in the next one and that most of the
processing is done). The script also returns the co_ratio
vector - the C/O ratio (number fraction) at the given thermal
pulse.