timeL, laL, loL = tool.dayTimeDis(quakeLs, staInfos, mlL0, minCover=0.0, isBox=True) tool.compareTime(timeL, timeL0, laL, loL, laL00, loL00) quakeL = [] loc = locator(staInfos) for qL in quakeLs: for q in qL: q, res = loc.locate(q, maxDT=50) if res < 2 and res > 0: print(q) quakeL.append(q) tool.saveQuakeLs([quakeL], 'NM/phaseLsNM20190901All') m=detecQuake.plotQuakeDis([quakeL],output='NM/quakeStaDis.pdf',R=[36,44,96,105],staInfos=staInfos,\ markersize=0.8,alpha=0.6,minCover=0.2,minSta=3,cmd='.b',topo='Ordos.grd',laL0=laL0,loL0=loL0,isBox=True) quakeLsTrain = tool.readQuakeLs('phaseLst_Train', staInfos) dTimeL = [] for qL in quakeLsTrain: for q in qL: for r in q: dTimeL.append(r[2] - r[1]) plt.hist(np.array(dTimeL), np.arange(100)) plt.show() modelL = [\ trainPS.loadModel('modelP_320000_0-2-15'),\ trainPS.loadModel('modelS_320000_0-2-15')] wk = '201412/D20141201000108_20/'
aMat = sacTool.areaMat(laL, loL, laN, loN) staTimeML = detecQuake.getStaTimeL(staInfos, aMat, taupM=taupM) quakeLs = list() ############################# for date in range(int(bSec), int(eSec), 86400): dayNum = int(date / 86400) dayDir = workDir + 'output/' + str(dayNum) if os.path.exists(dayDir): print('done') continue date = UTCDateTime(float(date)) print('pick on ', date) staL = detecQuake.getStaL(staInfos, aMat, staTimeML,\ modelL, date, getFileName=nameFunction,\ mode='norm',f=[2,15]) quakeLs.append(detecQuake.associateSta(staL, aMat, \ staTimeML, timeR=10, maxDTime=3, N=1,locator=\ locator(staInfos))) ''' save: result's in workDir+'phaseLst' result's waveform in workDir+'output/' result's plot picture in workDir+'output/' ''' tool.saveQuakeLs(quakeLs, workDir + 'phaseLst') tool.saveQuakeLWaveform(staL, quakeLs[-1], \ matDir=workDir+'output/',\ index0=-1500,index1=1500) detecQuake.plotResS(staL, quakeLs[-1], outDir=workDir + 'output/') staL = [] # clear data to save memory
staInfos = sacTool.readStaInfos(staLstFile) 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(2015, 6, 1).timestamp + 0 * 86400 * 230 eSec = UTCDateTime(2015, 10, 1).timestamp + 0 * 86400 * 231 for date in range(int(bSec), int(eSec), 86400): dayNum = int(date / 86400) dayDir = workDir + 'output20190901/' + str(dayNum) if os.path.exists(dayDir): print('done') continue date = UTCDateTime(float(date)) print('pick on ', date) staL = detecQuake.getStaL(staInfos, aMat, staTimeML,\ modelL, date, getFileName=names.NMFileName,\ mode='norm',f=[2,15]) quakeLs.append(detecQuake.associateSta(staL, aMat, \ staTimeML, timeR=10, maxDTime=3, N=1,locator=\ locator(staInfos))) tool.saveQuakeLWaveform(staL, quakeLs[-1], \ matDir=workDir+'output20190901/',\ index0=-1500,index1=1500) tool.saveQuakeLs(quakeLs, workDir + 'phaseLsNM20190901V6') detecQuake.plotResS(staL, quakeLs[-1], outDir=workDir + 'output20190901/') staL = []
quakeLs=tool.readQuakeLsByP('phaseLstDir/phaseLstAll*',staInfos) quakeCCLs=tool.readQuakeLsByP('NM/phaseCCLstNew?',staInfos) quakeL=[] R=[35,45,96,105] for quakeLTmp in quakeLs: quakeL=quakeL+quakeLTmp detecQuake.plotQuakeCCDis(quakeCCLs,quakeL,R=R,staInfos=staInfos,alpha=1,mul=0.1,markersize=0.05) mt.plotInline([quakeL],[39,106],[40,107]) mt.plotInline([quakeL],[39,106],[40,107],along=False) loc=locator(staInfos) for quake in quakeL: quake,res=loc.locate(quake) print(res) quakeTomoL=tool.selectQuake([quakeL],R,staInfos,minSta=12,maxCount=30) tool.saveQuakeLs([quakeTomoL],'phaseLstDir/phaseLstTomo') quakeL=tool.readQuakeLsByP('phaseLstDir/phaseLstTomo',staInfos)[0] waveformTomoL,tmpNameL=tool.loadWaveformLByQuakeL(quakeTomoL,isCut=True) dTM=tomoDD.calDTM(quakeTomoL,waveformTomoL,staInfos,maxD=0.3,minC=0.7,minSameSta=5) dTM=tomoDD.loadDTM() tomoDD.plotDT(waveformTomoL,dTM,0,132,staInfos) tomoDD.preEvent(quakeL,staInfos) tomoDD.preABS(quakeL,staInfos) tomoDD.preMod(R) tomoDD.preSta(staInfos) tomoDD.preDTCC(quakeL,staInfos,dTM) quakeRelocL=tomoDD.getReloc(quakeL) tool.saveQuakeLs([quakeRelocL],'phaseLstDir/phaseLstTomoReloc') detecQuake.plotQuakeDis([quakeRelocL],R=R,staInfos=staInfos,topo='Ordos.grd') detecQuake.plotQuakeDis([quakeRelocL],R=R,staInfos=staInfos,topo='Ordos.grd',alpha=0.8) quakeTomoL=tomoDD.selectQuake([quakeRelocL],R,staInfos,minSta=12,maxCount=30)
import torch staInfos = sacTool.readStaInfos('staLst_NM') R = [37.5, 43, 95, 104.5] RML = [38.7, 39.3, 101.8, 102] loc = locate.locator(staInfos) quakeTomoRelocLs = tool.readQuakeLs('NM/phaseLstTomoReloc', staInfos) quakeWLXL=tool.selectQuake(quakeTomoRelocLs,RML,staInfos,minSta=8,maxCount=5,outDir='NM/output/',\ minCover=0.7,laN=5,loN=5) quakeWLXL=tool.selectQuake([quakeTomoL],RML,staInfos,minSta=6,maxCount=5,outDir='NM/output/',\ minCover=0.7,laN=5,loN=5) for quake in quakeWLXL: loc.locate(quake, isDel=True) tool.saveQuakeLs([quakeWLXL], 'NM/phaseLstWLX') WLXDIR = '/home/jiangyr/MatchLocate/NM2/' tmpDir = WLXDIR + 'Template/' for quake in quakeWLXL: sacTool.cutSacByQuakeForCmpAz(quake,staInfos,names.NMFileNameHour,R=[38,40,100,104],outDir=tmpDir,\ decMul=2,B=0,E=70,isFromO=True,nameMode='ML',maxDT=30) traceDir = WLXDIR + 'Trace/' date = UTCDateTime(2015, 9, 19, 0, 0, 10) sacTool.cutSacByDate(date,staInfos,names.NMFileName,R=[38,40,100,104],outDir=traceDir,\ decMul=2,B=0,E=86400-10,isFromO=True,nameMode='ML') traceDir = WLXDIR + 'Trace/' date = UTCDateTime(2015, 1, 1, 0, 0, 10) for i in range(30): date += 86400
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')]#-with aMat = sacTool.areaMat(laL, loL, laN, loN) staTimeML = detecQuake.getStaTimeL(staInfos, aMat, taupM=taupM) quakeLs = list() bSec = UTCDateTime(2015, 1, 1).timestamp + 0 * 86400 * 230 eSec = UTCDateTime(2015, 2, 1).timestamp + 0 * 86400 * 231 for date in range(int(bSec), int(eSec), 86400): dayNum = int(date / 86400) dayDir = workDir + 'output20191003/' + str(dayNum) if os.path.exists(dayDir): print('done') continue date = UTCDateTime(float(date)) print('pick on ', date) staL = detecQuake.getStaL(staInfos, aMat, staTimeML, modelL, date, \ getFileName=names.NMFileName,mode='norm',f=[2,15]) quakeLs.append(detecQuake.associateSta(staL, aMat, staTimeML,\ timeR=10, maxDTime=3, N=1,locator=locator(staInfos))) tool.saveQuakeLWaveform(staL, quakeLs[-1], matDir=workDir+'output20191003/',\ index0=-1500,index1=1500) tool.saveQuakeLs(quakeLs, workDir + 'phaseLsNM20191003V7') detecQuake.plotResS(staL, quakeLs[-1], outDir=workDir + 'output20191003/') staL = []
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): print('done') continue staL = detecQuake.getStaL(staInfos, aMat, staTimeML, modelL, date, taupM=taupM, mode='mid') quakeLs.append(detecQuake.associateSta(staL, aMat, staTimeML, timeR=10, maxDTime=3, N=1,\ locator=locator(staInfos))) tool.saveQuakeLs(quakeLs, 'phaseLst2') tool.saveQuakeLWaveform(staL, quakeLs[-1], matDir='output/') detecQuake.plotResS(staL,quakeLs[-1]) tool.saveQuakeLs(quakeLs, 'phaseLst2') 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
sacFileNames=sacFileNames+glob(fileP) return sacFileNames taupM=tool.quickTaupModel(modelFile='iaspTaupMat') laL=[32,44] loL=[102,118] laN=40 loN=40 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() bSec=UTCDateTime(2014,1,1).timestamp+0*86400*230 eSec=UTCDateTime(2017,2,4).timestamp+0*86400*231 for date in range(int(bSec),int(eSec),86400): dayNum=int(date/86400) dayDir='output/'+str(dayNum) if os.path.exists(dayDir): print('done') continue date=UTCDateTime(float(date)) print('pick on ',date) #date = UTCDateTime(2015,1,1)+i*86400 staL = detecQuake.getStaL(staInfos, aMat, staTimeML, modelL, date, getFileName=NMFileName,mode='mid') quakeLs.append(detecQuake.associateSta(staL, aMat, staTimeML, timeR=10, maxDTime=3, N=1,locator=locator(staInfos))) tool.saveQuakeLWaveform(staL, quakeLs[-1], matDir='output/') tool.saveQuakeLs(quakeLs, 'phaseLstHimaNewV100') detecQuake.plotResS(staL,quakeLs[-1]) staL=[]