def getStaL(staInfos, aMat, staTimeML, modelL, date, \
    getFileName=originFileName,taupM=tool.quickTaupModel(), \
    mode='mid', N=5,isPre=True,f=[2, 15],R=[-90,90,\
    -180,180]):
    staL = [None for i in range(len(staInfos))]
    threads = list()
    for i in range(len(staInfos)):
        staInfo = staInfos[i]
        nt = staInfo['net']
        st = staInfo['sta']
        loc = [staInfo['la'], staInfo['lo']]
        comp = staInfo['comp']
        print('process on sta: ', i)
        getSta(staL, i, nt, st, date, modelL, staTimeML[i], loc, \
            f, getFileName, taupM, mode,isPre=isPre,R=R,comp=comp)
    return staL
    for i in range(len(threads)):
        print('process on sta: ', i)
        thread = threads[i]
        while threading.activeCount() > N:
            time.sleep(0.1)
        thread.start()

    for i in range(len(threads)):
        threads[i].join()
        print('sta: ', i, ' completed')

    return staL
def getStaTimeL(staInfos, aMat, taupM=tool.quickTaupModel()):
    #manager=Manager()
    #staTimeML=manager.list()
    staTimeML = list()
    for staInfo in staInfos:
        loc = [staInfo['la'], staInfo['lo']]
        staTimeML.append(staTimeMat(loc, aMat, taupM=taupM))
    return staTimeML
 def __init__(self, net, station, day, modelL=None, staTimeM=None,\
  loc=None, comp=['BHE','BHN','BHZ'], getFileName=originFileName, \
  freq=[-1, -1], mode='mid', isClearData=False,\
  taupM=tool.quickTaupModel(),isPre=True,delta0=0.02,R=[-91,91,\
 -181,181]):
     self.net = net
     self.loc = loc
     self.station = station
     self.day = day
     self.comp = comp
     self.taupM = taupM
     if loc[0] < R[0] or loc[0] > R[1] or loc[1] < R[2] or loc[1] > R[3]:
         self.data = sacTool.Data(np.zeros((0, 3)))
         print('skip')
     else:
         self.data = getDataByFileName(self.getSacFileNamesL\
             (getFileName=getFileName), freq=freq,delta0=delta0,maxA=2e9)
     #print(len(sta.data.data))
     self.timeL = list()
     self.vL = list()
     self.mode = mode
     if isPre == True:
         indexLL = [range(750, 1250), range(1000, 1500)]
         if mode == 'norm':
             minValueL = [0.5, 0.5]
         if mode == 'high':
             minValueL = [0.4, 0.4]
         if mode == 'mid':
             minValueL = [0.25, 0.25]
         if mode == 'low':
             minValueL = [0.2, 0.2]
         minDeltaL = [500, 750]
         for i in range(len(modelL)):
             tmpL = getDetec(predictLongData(modelL[i], self.data.data,\
              indexL=indexLL[i]), minValue=minValueL[i], minDelta =\
               minDeltaL[i])
             self.timeL.append(tmpL[0])
             self.vL.append(tmpL[1])
         self.pairD = self.getPSPair()
         self.isPick = np.zeros(len(self.pairD))
         self.orignM = self.convertPS2orignM(staTimeM)
         if isClearData:
             self.clearData()
def getStaLByQuake(staInfos, aMat, staTimeML, modelL,quake,\
    getFileName=originFileName,taupM=tool.quickTaupModel(), \
    mode='mid', N=5,isPre=False,bTime=-100,delta0=0.02):
    staL = [None for i in range(len(staInfos))]
    threads = list()
    for i in range(len(staInfos)):
        staInfo = staInfos[i]
        nt = staInfo['net']
        st = staInfo['sta']
        loc = [staInfo['la'], staInfo['lo']]
        print('process on sta: ', i)
        dis=DistAz(quake.loc[0],quake.loc[1],staInfos[i]['la'],\
            staInfos[i]['lo']).getDelta()
        date = obspy.UTCDateTime(
            quake.time + taupM.get_travel_times(quake.loc[2], dis)[0].time +
            bTime)
        getSta(staL, i, nt, st, date, modelL, staTimeML[i], loc, \
            [0.01, 15], getFileName, taupM, mode,isPre=isPre,delta0=delta0)
    return staL
from locate import locator
import names
import mapTool as mt
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['Arial']
plt.rcParams['font.size'] = 6
staLstFile = 'staLst_NM_New'
workDir = '/home/jiangyr/accuratePickerV3/NM/'
R = [35, 45, 96, 105]  #[34,42,104,112]
staInfos = sacTool.readStaInfos(staLstFile)
laL = [35, 45]
loL = [96, 105]
laN = 35
loN = 35
taupM = tool.quickTaupModel(modelFile='iaspTaupMat')
modelL = [
    trainPS.loadModel('modelP_320000_100-2-15'),
    trainPS.loadModel('modelS_320000_100-2-15')
]
aMat = sacTool.areaMat(laL, loL, laN, loN)
staTimeML = detecQuake.getStaTimeL(staInfos, aMat, taupM=taupM)
quakeLs = list()
bSec = UTCDateTime(2014, 10, 1).timestamp + 0 * 86400 * 230
eSec = UTCDateTime(2015, 1, 1).timestamp + 0 * 86400 * 231

quakeLs = tool.readQuakeLsByP('NM/phaseLsNM20190901V?', staInfos)
detecQuake.plotQuakeDis(quakeLs,
                        output='NM/quakeStaDis.pdf',
                        R=[36, 44, 96, 105],
                        staInfos=staInfos,
Beispiel #6
0
 def __init__(self, staInfos, modelFile='iaspTaupMat'):
     self.staInfos = staInfos
     self.timeM = quickTaupModel(modelFile)
import os 
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
import detecQuake
import trainPS
import sacTool
from imp import reload
from obspy import UTCDateTime
import numpy as np
import tool
from glob import glob
from locate import locator
#import pyMFTCuda

taupM=tool.quickTaupModel()
staLstFile='staLst'
staInfos=sacTool.readStaInfos(staLstFile)
laL=[28,35]
loL=[102,106]
laN=20
loN=20
modelL = [trainPS.loadModel('modelPNew2_15'),trainPS.loadModel('modelSNew2_15')]
aMat=sacTool.areaMat(laL,loL,laN,loN)
staTimeML= detecQuake.getStaTimeL(staInfos, aMat, taupM=taupM)
quakeLs=list()

for i in range(181, 210):
    print('pick on ',i)
    date = UTCDateTime(2008,1,1)+i*86400
    dayNum=int(date.timestamp/86400)
    dayDir='output/'+str(dayNum)
    if os.path.exists(dayDir):