def _cleanstarlog(file_in):
file_out=file_in+'<STR_LIT>'<EOL>f = open(file_in)<EOL>lignes = f.readlines()<EOL>f.close()<EOL>nb    = np.array([],dtype=int)   <EOL>nb    = np.concatenate((nb    ,[  int(lignes[len(lignes)-<NUM_LIT:1>].split()[ <NUM_LIT:0>])]))<EOL>nbremove = np.array([],dtype=int)   <EOL>i=-<NUM_LIT:1><EOL>for i in np.arange(len(lignes)-<NUM_LIT:1>,<NUM_LIT:0>,-<NUM_LIT:1>):<EOL><INDENT>line = lignes[i-<NUM_LIT:1>]<EOL>if i > <NUM_LIT:6> and line != "<STR_LIT>" :<EOL><INDENT>if int(line.split()[ <NUM_LIT:0>])>=nb[-<NUM_LIT:1>]:<EOL><INDENT>nbremove = np.concatenate((nbremove,[i-<NUM_LIT:1>]))<EOL><DEDENT>else:<EOL><INDENT>nb = np.concatenate((nb    ,[  int(line.split()[ <NUM_LIT:0>])]))<EOL><DEDENT><DEDENT><DEDENT>i=-<NUM_LIT:1><EOL>for j in nbremove:<EOL><INDENT>lignes.remove(lignes[j])<EOL><DEDENT>fout = open(file_out,'<STR_LIT:w>')<EOL>for j in np.arange(len(lignes)):<EOL><INDENT>fout.write(lignes[j])<EOL><DEDENT>fout.close()<EOL>
cleaning history.data or star.log file, e.g. to take care of
repetitive restarts.

private, should not be called by user directly

Parameters
----------
file_in : string
    Typically the filename of the mesa output history.data or
    star.log file, creates a clean file called history.datasa or
    star.logsa.

(thanks to Raphael for providing this tool)