original_docstring:  Cleanup up noise and cands files.
      Finds all segments in each scan and merges them into single cand/noise file per scan.
      
docstring: Cleanup up noise and cands files.
  Finds all segments in each scan and merges them into single cand/noise file per scan.
docstring_tokens: Cleanup up noise and cands files . Finds all segments in each scan and merges them into single cand / noise file per scan .
code: def cleanup(fileroot, scans):
      """ Cleanup up noise and cands files.
      Finds all segments in each scan and merges them into single cand/noise file per scan.
      """
  
      import realtime.parsecands as pc
  
      # merge cands files
      for scan in scans:
          try:
              pkllist = glob.glob('cands_' + fileroot + '_sc' + str(scan) + 'seg*.pkl')
              pc.merge_pkl(pkllist, fileroot + '_sc' + str(scan))
          except AssertionError:
              print 'No cands files found for scan %d' % scan
  
          if os.path.exists('cands_' + fileroot + '_sc' + str(scan) + '.pkl'):
              for cc in pkllist:
                  os.remove(cc)
  
          # merge noise files
          try:
              pkllist = glob.glob('noise_' + fileroot + '_sc' + str(scan) + 'seg*.pkl')
              pc.merge_pkl(pkllist, fileroot + '_sc' + str(scan))
          except AssertionError:
              print 'No noise files found for scan %d' % scan
  
          if os.path.exists('noise_' + fileroot + '_sc' + str(scan) + '.pkl'):
              for cc in pkllist:
                  os.remove(cc)
code_tokens: def cleanup ( fileroot , scans ) : import realtime . parsecands as pc for scan in scans : try : pkllist = glob . glob ( 'cands_' + fileroot + '_sc' + str ( scan ) + 'seg*.pkl' ) pc . merge_pkl ( pkllist , fileroot + '_sc' + str ( scan ) ) except AssertionError : print 'No cands files found for scan %d' % scan if os . path . exists ( 'cands_' + fileroot + '_sc' + str ( scan ) + '.pkl' ) : for cc in pkllist : os . remove ( cc ) try : pkllist = glob . glob ( 'noise_' + fileroot + '_sc' + str ( scan ) + 'seg*.pkl' ) pc . merge_pkl ( pkllist , fileroot + '_sc' + str ( scan ) ) except AssertionError : print 'No noise files found for scan %d' % scan if os . path . exists ( 'noise_' + fileroot + '_sc' + str ( scan ) + '.pkl' ) : for cc in pkllist : os . remove ( cc )
short_docstring: Cleanup up noise and cands files.
short_docstring_tokens: Cleanup up noise and cands files .
comment: """ Cleanup up noise and cands files.
      Finds all segments in each scan and merges them into single cand/noise file per scan.
      """$SEP$# merge cands files$SEP$# merge noise files