示例#1
0
文件: fileLib.py 项目: ChrisBail/NEW
def timeIt(who,t0):
   t1 = time()
   dt = t1 - t0
   t = t0
   if dt > 0.05:
      msg.message(" ".join([who,"[TIME]",str(dt),"seconds"]))
      t = t1
   return t
示例#2
0
def timeIt(who, t0):
    t1 = time()
    dt = t1 - t0
    t = t0
    if dt > 0.05:
        msg.message(" ".join([who, "[TIME]", str(dt), "seconds"]))
        t = t1
    return t
示例#3
0
def time_it(who, t0):
    """Compute elapsed time since the last cal."""
    t1 = time()
    dt = t1 - t0
    t = t0
    if dt > 0.05:
        msg_lib.message(f'{who} [TIME] {dt:0.2f} seconds')
        t = t1
    return t
示例#4
0
   param = importlib.import_module(paramFile)
else:
   msgLib.error('bad parameter file name [' + paramFile + ']', 2)
   usage()
   sys.exit()

VERBOSE      = param.VERBOSE

#
# flag to run in verbose mode
#
VERBOSE  = 0
arg = getParam(args,'mode',msgLib,'verbose')
print "MODE",arg
if arg == 'verbose':
      msgLib.message("VERBOSE RUN")
      VERBOSE   = 1
      print "\n\n[INFO] script: %s" % script
      print "[INFO] ARG#",len(sys.argv)
      print "[INFO] ARGS",sys.argv

#
# RUN ARGUMENTS:
#
network     = getParam(args,'net',msgLib,None)
station     = getParam(args,'sta',msgLib,None)
location    = staLib.getLocation(getParam(args,'loc',msgLib,None))
channel     = getParam(args,'chan',msgLib,None)
if len(channel) <3:
   channel += "*"
示例#5
0
    param = importlib.import_module(paramFile)
else:
    msgLib.error('bad parameter file name [' + paramFile + ']', 2)
    usage()
    sys.exit()

VERBOSE = param.VERBOSE

#
# flag to run in verbose mode
#
VERBOSE = 0
arg = getParam(args, 'mode', msgLib, 'verbose')
print "MODE", arg
if arg == 'verbose':
    msgLib.message("VERBOSE RUN")
    VERBOSE = 1
    print "\n\n[INFO] script: %s" % script
    print "[INFO] ARG#", len(sys.argv)
    print "[INFO] ARGS", sys.argv

#
# RUN ARGUMENTS:
#
network = getParam(args, 'net', msgLib, None)
station = getParam(args, 'sta', msgLib, None)
location = staLib.getLocation(getParam(args, 'loc', msgLib, None))
channel = getParam(args, 'chan', msgLib, None)
if len(channel) < 3:
    channel += "*"
示例#6
0
        client = Client(user_agent=utils_lib.param(param, 'userAgent').userAgent)
    else:
        msg_lib.info(f'accessing logon client as {user}')
        client = Client(user_agent=utils_lib.param(param, 'userAgent').userAgent, user=user, password=password)
    response_directory = None
else:
    msg_lib.info('[INFO] data and metadata from files')
    response_directory = utils_lib.param(param, 'respDirectory').respDirectory

# Keep track of what you are doing.
action = str()

# Runtime arguments.
t0 = time()
t1 = utils_lib.time_it('START', t0)
msg_lib.message('START')

request_network = utils_lib.get_param(args, 'net', None, usage)
request_station = utils_lib.get_param(args, 'sta', None, usage)
request_location = sta_lib.get_location(utils_lib.get_param(args, 'loc', None, usage))

# Maximum period needed to compute value at maxT period point.
max_period = utils_lib.param(param, 'maxT').maxT * pow(2, octave_window_width / 2.0)

# Minimum frequency  needed to compute value at 1.0/maxT frequency point.
min_frequency = 1.0 / float(max_period)

if timing:
    t0 = utils_lib.time_it('ARGS', t0)

if verbose:
示例#7
0
VERBOSE = msgLib.param(param, 'VERBOSE').VERBOSE

#
# flag to run in verbose mode
# verbose run will take place if:
#    - VERBOSE > 0
#    OR
#    -  len(sys.argv) > 8
#
TIMING = 0
doPlot = 0
VERBOSE = 0
arg = getParam(args, 'mode', msgLib, 'verbose')
print "MODE", arg
if arg == 'plot':
    msgLib.message("PLOT RUN")
    doPlot = 1
elif arg == 'time':
    msgLib.message("TIMING RUN")
    TIMING = 1
elif arg == 'verbose':
    msgLib.message("VERBOSE RUN")
    VERBOSE = 1

if VERBOSE > 0:
    print "\n\n[INFO] script: %s" % script
    print "[INFO] ARG#", len(sys.argv)
    print "[INFO] ARGS", sys.argv

import matplotlib
            # Compute power.
            if len(period) > 0:
                # Sort them to keep the code simple.
                period, psd = zip(*sorted(zip(period, psd)))

                """Go through the records and for each bin convert to power from dB
                   NOTE: PSD is equal to the power as the a measure point divided by the width of the bin
                        PSD = P / W
                        log(PSD) = Log(P) - log(W)
                        log(P) = log(PSD) + log(W)  here W is width in frequency
                        log(P) = log(PSD) - log(Wt) here Wt is width in period
                """
                for k in range(len(bins)):
                    if verbose > 1:
                        msg_lib.message(f' CHAN: {channel}, DATE": {previous_date} {previous_time}'
                                        f'PERIOD: {bins[k]} from {bin_start[k]} to {bin_end[k]}')

                    """
                      For each bin perform rectangular integration to compute power
                      power is assigned to the period at the begining of the interval
                           _   _
                          | |_| |
                          |_|_|_|
                    """

                    for j in range(0, len(psd) - 1):
                        # Since to calculate the area we take the width between point j and j+1, as a result we
                        # only accept the point if it falls before the end point, hence (<).
                        if float(bin_start[k]) <= float(period[j]) < float(bin_end[k]):

                            # Here we want to add the area just before the first sample if our window start
示例#9
0
VERBOSE      = msgLib.param(param,'VERBOSE').VERBOSE           

#
# flag to run in verbose mode
# verbose run will take place if:
#    - VERBOSE > 0
#    OR
#    -  len(sys.argv) > 8
#
TIMING   = 0
doPlot   = 0
VERBOSE  = 0
arg = getParam(args,'mode',msgLib,'verbose')
print "MODE",arg
if arg == 'plot':
      msgLib.message("PLOT RUN")
      doPlot = 1
elif arg == 'time':
      msgLib.message("TIMING RUN")
      TIMING = 1
elif arg == 'verbose':
      msgLib.message("VERBOSE RUN")
      VERBOSE        = 1

if VERBOSE >0 :
   print "\n\n[INFO] script: %s" % script
   print "[INFO] ARG#",len(sys.argv)
   print "[INFO] ARGS",sys.argv

import matplotlib