예제 #1
0
def main():
    # parse commandline
    opts = parse_commandline()

    ## get the segments on which triggers are retrieved
    # case 1: segment file is given   
    if opts.segment_file is not None:
      # read segment file
      seg_list = KW_veto_utils.read_segfile(opts.segment_file)
    # case 2: start and end GPS time are given
    else:
      seg_list = segmentlist([segment(opts.gps_start_time,opts.gps_end_time)])
    
    try:
      dbname, GW_working_filename, GWconnection, GWcursor, GWnum =\
         get_trigs(opts.trigger_files, seg_list, opts.min_thresh, name_tag = opts.name_tag, scratch_dir=opts.scratch_dir, verbose=opts.verbose)

      # save/display the result
      outname = os.path.splitext(dbname)[0]+opts.out_format
      KW_veto_utils.save_db(GWcursor,"GWtrigs",outname,GW_working_filename,
                      order_by=opts.order_by,verbose=opts.verbose)
   
      # close the connection to the database
      GWconnection.close()
    finally:
      # erase temporal database
      if globals().has_key('GW_working_filename'):
        db = globals()["GW_working_filename"]
        if opts.verbose:
          print >> sys.stderr, "removing temporary workspace '%s'..." % db
        os.remove(db)
def main():
    ## parse the command line
    opts = parse_commandline()

    ## get the segments on which triggers are retrieved
    # case 1: segment file is given
    if opts.segment_file is not None:
        # read segment file
        if opts.segment_file.endswith(".txt"):
            seg_list = utils.read_segfile(opts.segment_file)
        elif opts.segment_file.endswith(".xml") or opts.segment_file.endswith(
                ".xml.gz"):
            seg_list = utils.read_segfile_xml(opts.segment_file, opts.verbose)
    # case 2: start and end GPS time are given
    else:
        seg_list = segmentlist(
            [segment(opts.gps_start_time, opts.gps_end_time)])

    ## loop over each channels and get KW triggers
    for chan in opts.channel_name:
        # wrap in try/finally clause so that the code can erase temporary database
        # when it encounters an error and had to stop in the middle
        try:
            ## get triggers
            dbname, KW_working_filename, KWconnection, KWcursor, full_chan_name = \
                get_trigs(chan,seg_list,opts.min_thresh,trigs_loc=opts.KW_location,name_tag=opts.name_tag,scratch_dir=opts.scratch_dir,verbose=opts.verbose)

            # save/display the result
            outname = dbname.replace(chan, full_chan_name).replace(
                ".db", opts.out_format)
            utils.save_db(KWcursor,
                          "KWtrigs",
                          outname,
                          KW_working_filename,
                          order_by=opts.order_by,
                          verbose=opts.verbose)

            # close the connection to database
            KWconnection.close()

        finally:
            # erase temporal database
            if globals().has_key('KW_working_filename'):
                db = globals()['KW_working_filename']
                if opts.verbose:
                    print >> sys.stderr, "removing temporary workspace '%s'..." % db
                os.remove(db)
예제 #3
0
def main():
    ## parse the command line
    opts = parse_commandline()
    
    ## get the segments on which triggers are retrieved
    # case 1: segment file is given   
    if opts.segment_file is not None:
      # read segment file
      if opts.segment_file.endswith(".txt"):
        seg_list = utils.read_segfile(opts.segment_file)
      elif opts.segment_file.endswith(".xml") or opts.segment_file.endswith(".xml.gz"):
        seg_list = utils.read_segfile_xml(opts.segment_file,opts.verbose)
    # case 2: start and end GPS time are given
    else:
      seg_list = segmentlist([segment(opts.gps_start_time,opts.gps_end_time)])
   
    ## loop over each channels and get KW triggers
    for chan in opts.channel_name:      
      # wrap in try/finally clause so that the code can erase temporary database
      # when it encounters an error and had to stop in the middle
      try:
        ## get triggers
        dbname, KW_working_filename, KWconnection, KWcursor, full_chan_name = \
            get_trigs(chan,seg_list,opts.min_thresh,trigs_loc=opts.KW_location,name_tag=opts.name_tag,scratch_dir=opts.scratch_dir,verbose=opts.verbose)
    
        # save/display the result
        outname = dbname.replace(chan, full_chan_name).replace(".db", opts.out_format)
        utils.save_db(KWcursor, "KWtrigs", outname, KW_working_filename,
                      order_by=opts.order_by, verbose=opts.verbose)
     
        # close the connection to database
        KWconnection.close()
           
      finally:
        # erase temporal database
        if globals().has_key('KW_working_filename'):
          db = globals()['KW_working_filename']
          if opts.verbose:
            print >> sys.stderr, "removing temporary workspace '%s'..." % db
          os.remove(db)
예제 #4
0
def main():
    # parse commandline
    opts = parse_commandline()

    ## get the segments on which triggers are retrieved
    # case 1: segment file is given
    if opts.segment_file is not None:
        # read segment file
        seg_list = KW_veto_utils.read_segfile(opts.segment_file)
    # case 2: start and end GPS time are given
    else:
        seg_list = segmentlist(
            [segment(opts.gps_start_time, opts.gps_end_time)])

    try:
        dbname, GW_working_filename, GWconnection, GWcursor, GWnum =\
           get_trigs(opts.trigger_files, seg_list, opts.min_thresh, name_tag = opts.name_tag, scratch_dir=opts.scratch_dir, verbose=opts.verbose)

        # save/display the result
        outname = os.path.splitext(dbname)[0] + opts.out_format
        KW_veto_utils.save_db(GWcursor,
                              "GWtrigs",
                              outname,
                              GW_working_filename,
                              order_by=opts.order_by,
                              verbose=opts.verbose)

        # close the connection to the database
        GWconnection.close()
    finally:
        # erase temporal database
        if globals().has_key('GW_working_filename'):
            db = globals()["GW_working_filename"]
            if opts.verbose:
                print >> sys.stderr, "removing temporary workspace '%s'..." % db
            os.remove(db)