#Read a csv file defining iasp91, write it out to vgrids format import misc_tools import numpy as np #Load the parameters of the output vgrids file outvel = misc_tools.Fmm_vgrids() outvel.read() #Read isap csv file fnam = 'iasp.csv' dep, rad, vp, vs = np.genfromtxt(fnam, delimiter=',').transpose() #Build matrix from iasp vvec = [] radvec = np.arange(outvel.orad, outvel.orad + outvel.nrad) for i in radvec: ind = misc_tools.find_nearest_index(rad, i) if i <= rad[ind]: vvec = np.append(vvec, vp[ind]) else: vvec = np.append(vvec, vp[ind + 1]) #Replace 3D velocity with iasp for ilat in np.arange(outvel.nlat): for ilon in np.arange(outvel.nlon): outvel.vel[ilon][ilat] = vvec outvel.write()
#Read a csv file defining iasp91, write it out to vgrids format import misc_tools import numpy as np #Load the parameters of the output vgrids file outvel=misc_tools.Fmm_vgrids() outvel.read() #Read isap csv file fnam='iasp.csv' dep,rad,vp,vs=np.genfromtxt(fnam,delimiter=',').transpose() #Build matrix from iasp vvec=[] radvec=np.arange(outvel.orad,outvel.orad+outvel.nrad) for i in radvec: ind=misc_tools.find_nearest_index(rad,i) if i<=rad[ind]: vvec=np.append(vvec,vp[ind]) else: vvec=np.append(vvec,vp[ind+1]) #Replace 3D velocity with iasp for ilat in np.arange(outvel.nlat): for ilon in np.arange(outvel.nlon): outvel.vel[ilon][ilat]=vvec outvel.write()
arrsta = [] #a list of station names for arrival in ev.arrivals: if arrival.phase is 'P': arrvec.append(arrival.ttime) absvec.append(arrival.epoch) arrsta.append(arrival.staname) if not os.path.isfile(arrival.staname + 'traveltime'): continue absvec = asarray(absvec) arrvec = asarray(arrvec) #Return the entire misfit matrix dstep = int(loc_params['dstep2']) dx, dy, dz = nlon / dstep, nlat / dstep, nz / dstep dx, dy, dz = 1, 1, 1 qx, qy, qz = range(0, nlon, dx), range(0, nlat, dy), range(0, nz, dz) #minx, miny, minz, orgmin ,orimean,oristd= misc_tools.exp_grid_search(arrsta, qx, qy,qz, absvec, li,ev.epoch) #orimean,oristd= misc_tools._grid_search_traveltimes_origin(arrsta, qx, qy,qz, absvec, li) minx, miny, minz, orimean, oristd = misc_tools.exp_grid_search( arrsta, qx, qy, qz, absvec, li) #Plot idepth = misc_tools.find_nearest_index(earth_rad - qdep, ev.depth) faultlon, faultlat = misc_tools.load_faults() figid = plt.figure(1) figid.clf() plt.plot(faultlon, faultlat, 'k') plt.axis([min(qlon), max(qlon), min(qlat), max(qlat)]) pc_id = plt.pcolor(qlon, qlat, oristd[:, :, idepth]) figid.colorbar(pc_id) figid.show()
arrvec=[] arrsta=[] #a list of station names for arrival in ev.arrivals: if arrival.phase is 'P': arrvec.append(arrival.ttime) absvec.append(arrival.epoch) arrsta.append(arrival.staname) if not os.path.isfile(arrival.staname+'traveltime'): continue absvec=asarray(absvec) arrvec=asarray(arrvec) #Return the entire misfit matrix dstep = int(loc_params['dstep2']) dx, dy, dz = nlon / dstep, nlat / dstep, nz / dstep dx,dy,dz=1,1,1 qx, qy, qz = range(0, nlon, dx), range(0, nlat, dy), range(0, nz, dz); #minx, miny, minz, orgmin ,orimean,oristd= misc_tools.exp_grid_search(arrsta, qx, qy,qz, absvec, li,ev.epoch) #orimean,oristd= misc_tools._grid_search_traveltimes_origin(arrsta, qx, qy,qz, absvec, li) minx,miny,minz,orimean,oristd=misc_tools.exp_grid_search(arrsta,qx,qy,qz,absvec,li) #Plot idepth=misc_tools.find_nearest_index(earth_rad-qdep,ev.depth) faultlon,faultlat=misc_tools.load_faults() figid=plt.figure(1) figid.clf(); plt.plot(faultlon,faultlat,'k') plt.axis([min(qlon),max(qlon),min(qlat),max(qlat)]) pc_id=plt.pcolor(qlon,qlat,oristd[:,:,idepth] ) figid.colorbar(pc_id) figid.show()