
"""
%prog

Michael Coughlin (coughlim@carleton.edu)

This program runs seismon_run.py.

"""

# =============================================================================
#
#                               PREAMBLE
#
# =============================================================================


import os, time

__author__ = "Michael Coughlin <coughlim@carleton.edu>"
__date__ = "2012/2/7"
__version__ = "0.1"

while 1:

   #paramsFile = "/usr/local/seismon/seismon/seismon/input/seismon_params_traveltimes.txt"

#   tconvert_command = '/home/michael.coughlin/LAL/master/bin/lalapps_tconvert now'

   paramsFile = '/home/michael.coughlin/Seismon/seismon/input/seismon_params_traveltimes.txt'

   tconvert_command = 'tconvert now'

   timewindow=4*3600
   gpsStart = int(os.popen('tconvert now').readline()) - timewindow
   gpsEnd = gpsStart + timewindow
   minMagnitude = 4.0

   start_time = time.time()
   print("python seismon_traveltimes -p %s -s %d -e %d --minMagnitude %.1f --doPrivate --doPublic"%(paramsFile,gpsStart,gpsEnd,minMagnitude))
   print(stop)
   os.system("python seismon_traveltimes -p %s -s %d -e %d --minMagnitude %.1f --doPrivate --doPublic"%(paramsFile,gpsStart,gpsEnd,minMagnitude))
   end_time = time.time()
   elapsed_time = end_time - start_time
   print("Elapsed time for Seismon: %f"%(elapsed_time))


   print(stop)
