mirror of
https://github.com/HongjianFang/DSurfTomo.git
synced 2025-09-16 08:28:10 +08:00
Initial commit
change 1e-2 to 'ftol' in CalSurfG.f90, which may cause problem with small study region (~2 km)
This commit is contained in:
32
scripts/GenerateIniMOD.py
Normal file
32
scripts/GenerateIniMOD.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
# how to run:
|
||||
# ./GenerateIniMOD.py
|
||||
# remember to move MOD to the directory where you want to run DSurfTomo
|
||||
import numpy as np
|
||||
|
||||
#parameters need to be changed
|
||||
#start
|
||||
nx=18
|
||||
ny=18
|
||||
nz=9
|
||||
minvel=0.9
|
||||
velgrad=0.6
|
||||
dep1=np.array([0,0.2,0.4,0.6,0.8,1.1,1.4,1.8,2.5])
|
||||
#end
|
||||
vs1=np.zeros(nz)
|
||||
mod=np.zeros((nz*ny,nx))
|
||||
for k in range(nz):
|
||||
for j in range(ny):
|
||||
for i in range(nx):
|
||||
mod[k*ny+j,i]= minvel+dep1[k]*velgrad
|
||||
with open('MOD','w') as fp:
|
||||
for i in range(nz):
|
||||
fp.write('%5.1f' % dep1[i])
|
||||
fp.write('\n')
|
||||
for k in range(nz):
|
||||
for j in range(ny):
|
||||
for i in range(nx):
|
||||
fp.write('%7.3f' % mod[k*ny+j,i])
|
||||
fp.write('\n')
|
||||
for i in range(nz):
|
||||
print dep1[i],
|
42
scripts/GenerateTrueMOD.py
Normal file
42
scripts/GenerateTrueMOD.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python
|
||||
# the checkerboard should use the initial model as background model, then add
|
||||
# some pertubations
|
||||
# remember to move MOD.true to the directory where you want to run DSurfTomo
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
#parameters you need to change
|
||||
#start
|
||||
nx=18
|
||||
ny=18
|
||||
nz=9
|
||||
minvel=0.9
|
||||
velgrad=0.6
|
||||
dep1=[0,0.2,0.4,0.6,0.8,1.1,1.4,1.8,2.5]
|
||||
anosize=1.0
|
||||
amplitude=0.4
|
||||
#end
|
||||
x=range(1,nx+1)
|
||||
y=range(1,ny+1)
|
||||
z=range(1,nz+1)
|
||||
z=np.ones(nz)
|
||||
bg=np.zeros((nz,nx,ny))
|
||||
cross=np.zeros((nz,ny))
|
||||
vs1=np.zeros(nz)
|
||||
xy=np.kron(np.sin(anosize*np.array(y)),np.sin(anosize*np.array(x)))
|
||||
xyz=np.kron(z,xy)
|
||||
pxy=xyz.reshape(nz,nx,ny)
|
||||
for k in range(nz):
|
||||
for j in range(ny):
|
||||
for i in range(nx):
|
||||
bg[k,i,j]= minvel+dep1[k]*velgrad
|
||||
mod=np.zeros((nz*ny,nx))
|
||||
for k in range(nz):
|
||||
for j in range(ny):
|
||||
for i in range(nx):
|
||||
mod[(k)*ny+j,i]=bg[k,i,j]+pxy[k,i,j]*amplitude
|
||||
k=5
|
||||
plt.imshow(mod[k*ny:(k+1)*ny,:],cmap='jet_r',interpolation='bicubic')
|
||||
np.savetxt('MOD.true',mod,fmt='%4.4f')
|
||||
plt.colorbar()
|
||||
plt.show()
|
||||
|
93
scripts/extractnew.py
Normal file
93
scripts/extractnew.py
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# a python script to extract data for the direct inversion of
|
||||
# surface wave dispersion measurements
|
||||
# By Hongjian Fang @ USTC(fanghj@mail.ustc.edu.cn) 2014/04/24
|
||||
# the data format is
|
||||
# # sta1_lat sta1_lon nt iwave igr
|
||||
# sta2_lat sta2_lon phase/group velocity
|
||||
# ......
|
||||
import os
|
||||
import numpy as np
|
||||
'''how to use it?
|
||||
python extractSurfTomo.py > surfdata.dat
|
||||
remember to read note.txt after this
|
||||
and move surfdata.dat to the directory where you want to run DSurfTomo
|
||||
'''
|
||||
|
||||
# parameters need to change according to your case
|
||||
# start
|
||||
nsrc=20
|
||||
nrc=20
|
||||
nf=26
|
||||
MinP=0.5
|
||||
MaxP=3.0
|
||||
interval=0.1
|
||||
wavetp=2
|
||||
veltp=0
|
||||
d = {}
|
||||
d['TB01']=1
|
||||
d['TB02']=2
|
||||
d['TB03']=3
|
||||
d['TB04']=4
|
||||
d['TB05']=5
|
||||
d['TB06']=6
|
||||
d['TB07']=7
|
||||
d['TB08']=8
|
||||
d['TB09']=9
|
||||
d['TB10']=10
|
||||
d['TB11']=11
|
||||
d['TB12']=12
|
||||
d['TB13']=13
|
||||
d['TB14']=14
|
||||
d['TB15']=15
|
||||
d['TB16']=16
|
||||
d['TB17']=17
|
||||
d['TB18']=18
|
||||
d['TB19']=19
|
||||
d['TB20']=20
|
||||
#end
|
||||
|
||||
phav=np.zeros((nrc,nsrc,nf))
|
||||
sta1la=np.zeros((nrc,nsrc,nf))
|
||||
sta1lo=np.zeros((nrc,nsrc,nf))
|
||||
sta2la=np.zeros((nrc,nsrc,nf))
|
||||
sta2lo=np.zeros((nrc,nsrc,nf))
|
||||
for file in os.listdir('.'):
|
||||
if 'CD' in file:
|
||||
data=np.loadtxt(file)
|
||||
shape=data.shape
|
||||
# you may need to change the following 2 lines depend on your file name
|
||||
source=file.split('-')[0].split('.')[1]
|
||||
receiver=file.split('-')[1].split('.')[0]
|
||||
for i in range(2,shape[0]):
|
||||
if data[i,0]>=MinP and data[i,0]<=MaxP:
|
||||
f=np.int(np.rint((data[i,0]-MinP)/interval+1))
|
||||
rc=d[receiver]-1
|
||||
src=d[source]-1
|
||||
phav[rc,src,f-1]=data[i,1]
|
||||
sta1la[rc,src,f-1]=data[0,1]
|
||||
sta1lo[rc,src,f-1]=data[0,0]
|
||||
sta2la[rc,src,f-1]=data[1,1]
|
||||
sta2lo[rc,src,f-1]=data[1,0]
|
||||
|
||||
srclat=-999.9
|
||||
per=-999
|
||||
nsrcout=0
|
||||
|
||||
for ifr in range(nf):
|
||||
for isrc in range(nsrc):
|
||||
for irc in range(nrc):
|
||||
if phav[irc,isrc,ifr]>0:
|
||||
if np.abs(sta1la[irc,isrc,ifr]-srclat)>1e-4 or abs(ifr+1-per)>1e-4:
|
||||
nsrcout=nsrcout+1
|
||||
print ('%s %10.6f %10.6f %d %d %d') % ('#',sta1la[irc,isrc,ifr],sta1lo[irc,isrc,ifr],ifr+1,wavetp,veltp)
|
||||
print ('%10.6f %10.6f %6.4f') % (sta2la[irc,isrc,ifr],sta2lo[irc,isrc,ifr],phav[irc,isrc,ifr])
|
||||
else:
|
||||
print ('%10.6f %10.6f %6.4f') % (sta2la[irc,isrc,ifr],sta2lo[irc,isrc,ifr],phav[irc,isrc,ifr])
|
||||
srclat=sta1la[irc,isrc,ifr]
|
||||
per=ifr+1
|
||||
note=open('note.txt','w+')
|
||||
note.write('write this number to the eighth line in DSurfTomo.in\n')
|
||||
note.write(str(nsrcout))
|
||||
note.close()
|
48
scripts/plotslice.gmt
Normal file
48
scripts/plotslice.gmt
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/csh
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# 2015-06-08 Hongjian Fang
|
||||
# how to run:
|
||||
# ./plotslice.gmt ModelFile depth1 depth2 depth3 depth4, e.g.
|
||||
# csh plotslice.gmt SurfTomo.in.tvMeasure.dat 0.2 0.4 0.8 1.4
|
||||
#-----------------------------------------------------------
|
||||
|
||||
gmtset ANOT_FONT_SIZE 6
|
||||
gmtset LABEL_FONT_SIZE 6
|
||||
gmtset FRAME_WIDTH=0.1c
|
||||
gmtset LABEL_OFFSET=0.1c
|
||||
gmtset LABEL_FONT_SIZE=5p
|
||||
gmtset TICK_LENGTH=0.1c
|
||||
gmtset TICK_PEN=0.3p
|
||||
set inp3D = $1
|
||||
set ps = horizVsnew.ps
|
||||
set J = -JM2i #size for plot
|
||||
set cpt = slice.cpt
|
||||
|
||||
# start
|
||||
makecpt -Cseis -T0.6/1.5/0.1 > $cpt #velocity boundary
|
||||
set RMAP = `minmax -C $inp3D | awk '{print "-R"$1"/"$2"/"$3"/"$4}'`
|
||||
psbasemap $RMAP $J -Ba0.1f0.05WseN -P -K -Y5i >$ps
|
||||
awk '{if($3==depth1) print $1,$2,$4}' depth1=$2 $inp3D|xyz2grd -R -I0.017/0.015 -Gtmp.grd
|
||||
grdimage tmp.grd $J $RMAP -BSenW -E100 -C$cpt -O -K >> $ps
|
||||
rm -rf tmp.grd
|
||||
psscale -Cslice.cpt -Ba0.1f0.05:'S velocity (km/s)': -D1.0i/-0.15i/3.00/0.2h -O -K -P >> $ps
|
||||
|
||||
makecpt -Cseis -T0.8/1.8/0.1 > $cpt #velocity boundary
|
||||
psbasemap $RMAP $J -Ba0.1f0.05NwsE -P -K -O -X2.3i >>$ps
|
||||
awk '{if($3==depth2) print $1,$2,$4}' depth2=$3 $inp3D|xyz2grd -R -I0.017/0.015 -Gtmp.grd
|
||||
grdimage tmp.grd $J $RMAP -BSenW -E100 -C$cpt -O -K >> $ps
|
||||
psscale -Cslice.cpt -Ba0.2f0.1:'S velocity (km/s)': -D1.0i/-0.15i/3.00/0.2h -O -K -P >> $ps
|
||||
|
||||
makecpt -Cseis -T1.1/2.0/0.1 > $cpt #velocity boundary
|
||||
psbasemap $RMAP $J -Ba0.1f0.05WneS -P -K -O -Y-2.7i -X-2.3i >>$ps
|
||||
awk '{if($3==depth2) print $1,$2,$4}' depth2=$4 $inp3D|xyz2grd -R -I0.017/0.015 -Gtmp.grd
|
||||
grdimage tmp.grd $J $RMAP -BSenW -E100 -C$cpt -O -K >> $ps
|
||||
psscale -Cslice.cpt -Ba0.2f0.1:'S velocity (km/s)': -D1.0i/-0.25i/3.00/0.2h -O -K -P >> $ps
|
||||
|
||||
makecpt -Cseis -T1.3/2.4/0.1 > $cpt #velocity boundary
|
||||
psbasemap $RMAP $J -Ba0.1f0.05SwnE -P -K -O -X2.3i >>$ps
|
||||
awk '{if($3==depth2) print $1,$2,$4}' depth2=$5 $inp3D|xyz2grd -R -I0.017/0.015 -Gtmp.grd
|
||||
grdimage tmp.grd $J $RMAP -BSenW -E100 -C$cpt -O -K >> $ps
|
||||
psscale -Cslice.cpt -Ba0.2f0.1:'S velocity (km/s)': -D1.0i/-0.25i/3.00/0.2h -O -P >> $ps
|
||||
|
Reference in New Issue
Block a user