Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions docs/locales/en/LC_MESSAGES/Tutorial/dynamic/strain_stress.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PyGRT 0.6.1.dev1+g4641a40.d20250422\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-08-05 13:28+0800\n"
"POT-Creation-Date: 2025-09-21 23:21+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand Down Expand Up @@ -48,10 +48,11 @@ msgstr ""
"To compute these tensors, the spatial derivatives of displacement "
":math:`\\partial z,\\partial r,\\partial \\theta` [#partial]_ need to be "
"calculated. Starting from the calculation of Green's functions "
"(:doc:`/Tutorial/dynamic/gfunc`) and the formula for displacement synthesis "
"(:doc:`/Tutorial/dynamic/syn`), the spatial derivatives of displacement are computed in"
" two steps, and then strain, rotation, and stress tensors are synthesized"
" based on the geometric and constitutive equations."
"(:doc:`/Tutorial/dynamic/gfunc`) and the formula for displacement "
"synthesis (:doc:`/Tutorial/dynamic/syn`), the spatial derivatives of "
"displacement are computed in two steps, and then strain, rotation, and "
"stress tensors are synthesized based on the geometric and constitutive "
"equations."

#: ../../source/Tutorial/dynamic/strain_stress.rst:12
msgid ""
Expand Down Expand Up @@ -261,12 +262,10 @@ msgid ""
msgstr ""

#: ../../source/Tutorial/dynamic/strain_stress.rst:141
msgid ""
"在 :rst:dir:`syn_dc_zne/` 原路径下,生成 "
":file:`*.strain.??.sac`,文件名中包括分量名,如ZZ、ZN等。"
msgid "在 :rst:dir:`syn_dc_zne/` 原路径下,生成 :file:`strain_??.sac`,文件名中包括分量名,如ZZ、ZN等。"
msgstr ""
"In the original path :rst:dir:`syn_dc_zne/`, files named "
":file:`*.strain.??.sac` are generated, with component names such as ZZ, "
":file:`strain_??.sac` are generated, with component names such as ZZ, "
"ZN included in the file names."

#: ../../source/Tutorial/dynamic/strain_stress.rst:150
Expand Down Expand Up @@ -294,10 +293,10 @@ msgstr ""
#: ../../source/Tutorial/dynamic/strain_stress.rst:173
msgid ""
"在 :rst:dir:`syn_dc_zne/` 原路径下,生成 "
":file:`*.rotation.??.sac`,文件名中包括分量名,如ZN,ZE,NE。"
":file:`rotation_??.sac`,文件名中包括分量名,如ZN,ZE,NE。"
msgstr ""
"In the original path :rst:dir:`syn_dc_zne/`, files named "
":file:`*.rotation.??.sac` are generated, with component names such as ZN,"
":file:`rotation_??.sac` are generated, with component names such as ZN,"
" ZE, NE included in the file names."

#: ../../source/Tutorial/dynamic/strain_stress.rst:182
Expand All @@ -321,12 +320,10 @@ msgid ""
msgstr ""

#: ../../source/Tutorial/dynamic/strain_stress.rst:207
msgid ""
"在 :rst:dir:`syn_dc_zne/` 原路径下,生成 "
":file:`*.stress.??.sac`,文件名中包括分量名,如ZZ、ZN等。"
msgid "在 :rst:dir:`syn_dc_zne/` 原路径下,生成 :file:`stress_??.sac`,文件名中包括分量名,如ZZ、ZN等。"
msgstr ""
"In the original path :rst:dir:`syn_dc_zne/`, files named "
":file:`*.stress.??.sac` are generated, with component names such as ZZ, "
":file:`stress_??.sac` are generated, with component names such as ZZ, "
"ZN included in the file names."

#: ../../source/Tutorial/dynamic/strain_stress.rst:224
Expand Down
12 changes: 6 additions & 6 deletions docs/source/Tutorial/dynamic/run_upar/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ grt syn -GGRN/milrow_2_0_10 -S1e24 -A30 -M33/50/120 -Osyn_dc_zne -e -N

# --------------------------------------------------------------------------------------
# BEGIN STRAIN
# 指定文件夹以及中间名,会在原文件夹内输出SAC格式的应变张量
grt strain syn_dc_zne/out
# 指定文件夹,会在原文件夹内输出SAC格式的应变张量
grt strain syn_dc_zne
# END STRAIN
# --------------------------------------------------------------------------------------

# --------------------------------------------------------------------------------------
# BEGIN ROTATION
# 指定文件夹以及中间名,会在原文件夹内输出SAC格式的旋转张量
grt rotation syn_dc_zne/out
# 指定文件夹,会在原文件夹内输出SAC格式的旋转张量
grt rotation syn_dc_zne
# END ROTATION
# --------------------------------------------------------------------------------------


# --------------------------------------------------------------------------------------
# BEGIN STRESS
# 指定文件夹以及中间名,会在原文件夹内输出SAC格式的应力张量
grt stress syn_dc_zne/out
# 指定文件夹,会在原文件夹内输出SAC格式的应力张量
grt stress syn_dc_zne
# END STRESS
# --------------------------------------------------------------------------------------
6 changes: 3 additions & 3 deletions docs/source/Tutorial/dynamic/strain_stress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
:start-after: BEGIN STRAIN
:end-before: END STRAIN

在 :rst:dir:`syn_dc_zne/` 原路径下,生成 :file:`*.strain.??.sac`,文件名中包括分量名,如ZZ、ZN等。
在 :rst:dir:`syn_dc_zne/` 原路径下,生成 :file:`strain_??.sac`,文件名中包括分量名,如ZZ、ZN等。

.. group-tab:: Python

Expand Down Expand Up @@ -170,7 +170,7 @@
:start-after: BEGIN ROTATION
:end-before: END ROTATION

在 :rst:dir:`syn_dc_zne/` 原路径下,生成 :file:`*.rotation.??.sac`,文件名中包括分量名,如ZN,ZE,NE。
在 :rst:dir:`syn_dc_zne/` 原路径下,生成 :file:`rotation_??.sac`,文件名中包括分量名,如ZN,ZE,NE。

.. group-tab:: Python

Expand Down Expand Up @@ -204,7 +204,7 @@
:start-after: BEGIN STRESS
:end-before: END STRESS

在 :rst:dir:`syn_dc_zne/` 原路径下,生成 :file:`*.stress.??.sac`,文件名中包括分量名,如ZZ、ZN等。
在 :rst:dir:`syn_dc_zne/` 原路径下,生成 :file:`stress_??.sac`,文件名中包括分量名,如ZZ、ZN等。

.. group-tab:: Python

Expand Down
33 changes: 16 additions & 17 deletions example/compare_c_py/run_grt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,40 @@ grt greenfn -M${modname} -O${out} -N${nt}/${dt} -D${depsrc}/${deprcv} -R${dist}

# convolve different signals
G=$out/${modname}_${depsrc}_${deprcv}_${dist}
P=cout
S=1e24
az=39.2
for N in "" "-N" ; do
grt syn -G$G -Osyn_ex -P$P -A$az -S$S -Dt/0.2/0.2/0.4 -e $N
grt strain syn_ex/$P
grt rotation syn_ex/$P
grt stress syn_ex/$P
grt syn -G$G -Osyn_ex$N -A$az -S$S -Dt/0.2/0.2/0.4 -e $N
grt strain syn_ex$N
grt rotation syn_ex$N
grt stress syn_ex$N

fn=2
fe=-1
fz=4
grt syn -G$G -Osyn_sf -P$P -A$az -S$S -F$fn/$fe/$fz -Dt/0.1/0.3/0.6 -e $N
grt strain syn_sf/$P
grt rotation syn_sf/$P
grt stress syn_sf/$P
grt syn -G$G -Osyn_sf$N -A$az -S$S -F$fn/$fe/$fz -Dt/0.1/0.3/0.6 -e $N
grt strain syn_sf$N
grt rotation syn_sf$N
grt stress syn_sf$N

stk=77
dip=88
rak=99
grt syn -G$G -Osyn_dc -P$P -A$az -S$S -M$stk/$dip/$rak -Dp/0.6 -e $N
grt strain syn_dc/$P
grt rotation syn_dc/$P
grt stress syn_dc/$P
grt syn -G$G -Osyn_dc$N -A$az -S$S -M$stk/$dip/$rak -Dp/0.6 -e $N
grt strain syn_dc$N
grt rotation syn_dc$N
grt stress syn_dc$N

M11=1
M12=-2
M13=-5
M22=0.5
M23=3
M33=1.2
grt syn -G$G -Osyn_mt -P$P -A$az -S$S -T$M11/$M12/$M13/$M22/$M23/$M33 -Dr/3 -e $N
grt strain syn_mt/$P
grt rotation syn_mt/$P
grt stress syn_mt/$P
grt syn -G$G -Osyn_mt$N -A$az -S$S -T$M11/$M12/$M13/$M22/$M23/$M33 -Dr/3 -e $N
grt strain syn_mt$N
grt rotation syn_mt$N
grt stress syn_mt$N
done


Expand Down
37 changes: 19 additions & 18 deletions example/compare_c_py/run_pygrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def compare3(st_py:Stream, c_prefix:str, ZNE:bool=False, dim2:bool=False):
nerr = 0
for tr_c in st_c:
tr_py = st_py.select(channel=tr_c.stats.channel)[0]
tr_c.data[tr_c.data == 0.0] = 1.0
rerr = np.mean(np.abs(tr_c.data - tr_py.data) / np.abs(tr_c.data))
if np.isnan(rerr) or np.isinf(rerr):
rerr = 0.0
Expand Down Expand Up @@ -53,7 +54,7 @@ def static_compare3(resDct:dict, c_prefix:str):
continue
val1 = resDct[k]
val2 = f.variables[k][:]
print(k, np.mean(np.abs(val1 - val2)), np.max(val2))
print(k, np.mean(np.abs(val1 - val2)), np.max(np.abs(val2)))

val2[val2 == 0.0] = 1.0

Expand Down Expand Up @@ -105,52 +106,52 @@ def static_compare3(resDct:dict, c_prefix:str):
M33=1.2

for ZNE in [False, True]:
suffix = "-N" if ZNE else ""
# synthetic

st = pygrt.utils.gen_syn_from_gf_EX(st_grn, S, az, ZNE=ZNE, calc_upar=True)
sigs = pygrt.sigs.gen_triangle_wave(0.4, dt)
pygrt.utils.stream_convolve(st, sigs)
AVGRERR.append(compare3(st, "syn_ex/cout", ZNE=ZNE))
AVGRERR.append(compare3(st, f"syn_ex{suffix}/", ZNE=ZNE))
ststrain = pygrt.utils.compute_strain(st)
strotation = pygrt.utils.compute_rotation(st)
ststress = pygrt.utils.compute_stress(st)
AVGRERR.append(compare3(ststrain, "syn_ex/cout.strain.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(strotation, "syn_ex/cout.rotation.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststress, "syn_ex/cout.stress.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststrain, f"syn_ex{suffix}/strain_", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(strotation, f"syn_ex{suffix}/rotation_", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststress, f"syn_ex{suffix}/stress_", ZNE=ZNE, dim2=True))


st = pygrt.utils.gen_syn_from_gf_SF(st_grn, S, fn, fe, fz, az, ZNE=ZNE, calc_upar=True)
sigs = pygrt.sigs.gen_trap_wave(0.1, 0.3, 0.6, dt)
pygrt.utils.stream_convolve(st, sigs)
AVGRERR.append(compare3(st, "syn_sf/cout", ZNE=ZNE))
AVGRERR.append(compare3(st, f"syn_sf{suffix}/", ZNE=ZNE))
ststrain = pygrt.utils.compute_strain(st)
strotation = pygrt.utils.compute_rotation(st)
ststress = pygrt.utils.compute_stress(st)
AVGRERR.append(compare3(ststrain, "syn_sf/cout.strain.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(strotation, "syn_sf/cout.rotation.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststress, "syn_sf/cout.stress.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststrain, f"syn_sf{suffix}/strain_", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(strotation, f"syn_sf{suffix}/rotation_", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststress, f"syn_sf{suffix}/stress_", ZNE=ZNE, dim2=True))

st = pygrt.utils.gen_syn_from_gf_DC(st_grn, S, stk, dip, rak, az, ZNE=ZNE, calc_upar=True)
sigs = pygrt.sigs.gen_parabola_wave(0.6, dt)
pygrt.utils.stream_convolve(st, sigs)
AVGRERR.append(compare3(st, "syn_dc/cout", ZNE=ZNE))
AVGRERR.append(compare3(st, f"syn_dc{suffix}/", ZNE=ZNE))
ststrain = pygrt.utils.compute_strain(st)
strotation = pygrt.utils.compute_rotation(st)
ststress = pygrt.utils.compute_stress(st)
AVGRERR.append(compare3(ststrain, "syn_dc/cout.strain.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(strotation, "syn_dc/cout.rotation.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststress, "syn_dc/cout.stress.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststrain, f"syn_dc{suffix}/strain_", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(strotation, f"syn_dc{suffix}/rotation_", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststress, f"syn_dc{suffix}/stress_", ZNE=ZNE, dim2=True))

st = pygrt.utils.gen_syn_from_gf_MT(st_grn, S, [M11,M12,M13,M22,M23,M33], az, ZNE=ZNE, calc_upar=True)
sigs = pygrt.sigs.gen_ricker_wave(3, dt)
pygrt.utils.stream_convolve(st, sigs)
AVGRERR.append(compare3(st, "syn_mt/cout", ZNE=ZNE))
AVGRERR.append(compare3(st, f"syn_mt{suffix}/", ZNE=ZNE))
ststrain = pygrt.utils.compute_strain(st)
strotation = pygrt.utils.compute_rotation(st)
ststress = pygrt.utils.compute_stress(st)
AVGRERR.append(compare3(ststrain, "syn_mt/cout.strain.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(strotation, "syn_mt/cout.rotation.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststress, "syn_mt/cout.stress.", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststrain, f"syn_mt{suffix}/strain_", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(strotation, f"syn_mt{suffix}/rotation_", ZNE=ZNE, dim2=True))
AVGRERR.append(compare3(ststress, f"syn_mt{suffix}/stress_", ZNE=ZNE, dim2=True))


#-------------------------- Static -----------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions example/compute_strain_stress/dynamic/run_grt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ az=30
grt syn -G${out}/${modname}_${depsrc}_${deprcv}_${dist} -A$az -S$S -M$stk/$dip/$rak -Dp/0.6 -Osyn_dc -e


grt strain syn_dc/out
grt stress syn_dc/out
grt strain syn_dc
grt stress syn_dc
13 changes: 7 additions & 6 deletions example/convolve_signals/plot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ rm -rf $out
mkdir -p $out


for synpath in syn*; do
for cout in $synpath/cout*; do
fname=$(basename $cout)
echo $cout $(dirname $cout)/p${fname:1:}
for synpath in syn_ex syn_sf syn_dc syn_mt; do
for ch in Z R T; do
cname=c_$synpath/$ch.sac
pname=p_$synpath/$ch.sac
echo $cname $pname
sac << EOF
r $cout $(dirname $cout)/p${fname:1}
r $cname $pname
qdp off
color red inc list blue red
p1
saveimg $out/compare_${synpath}_${fname}.pdf
saveimg $out/compare_${synpath}_${ch}.pdf
q
EOF

Expand Down
12 changes: 7 additions & 5 deletions example/convolve_signals/run_grt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,32 @@ dt=0.01
modname="milrow"
out="GRN"

rm -rf $out

grt greenfn -M${modname} -O${out} -N${nt}/${dt} -D${depsrc}/${deprcv} -R${dist}

rm -rf c_syn* p_syn*
# convolve different signals
G=$out/${modname}_${depsrc}_${deprcv}_${dist}
P=cout
S=1e24
az=39.2
grt syn -G$G -Osyn_ex -P$P -A$az -S$S -Dt/0.2/0.2/0.4
grt syn -G$G -Oc_syn_ex -A$az -S$S -Dt/0.2/0.2/0.4

fn=2
fe=-1
fz=4
grt syn -G$G -Osyn_sf -P$P -A$az -S$S -F$fn/$fe/$fz -Dt/0.1/0.3/0.6
grt syn -G$G -Oc_syn_sf -A$az -S$S -F$fn/$fe/$fz -Dt/0.1/0.3/0.6

stk=77
dip=88
rak=99
grt syn -G$G -Osyn_dc -P$P -A$az -S$S -M$stk/$dip/$rak -Dp/0.6
grt syn -G$G -Oc_syn_dc -A$az -S$S -M$stk/$dip/$rak -Dp/0.6

M11=1
M12=-2
M13=-5
M22=0.5
M23=3
M33=1.2
grt syn -G$G -Osyn_mt -P$P -A$az -S$S -T$M11/$M12/$M13/$M22/$M23/$M33 -Dr/3
grt syn -G$G -Oc_syn_mt -A$az -S$S -T$M11/$M12/$M13/$M22/$M23/$M33 -Dr/3

8 changes: 4 additions & 4 deletions example/convolve_signals/run_pygrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
st = pygrt.utils.gen_syn_from_gf_EX(st_grn, S, az)
sigs = pygrt.sigs.gen_triangle_wave(0.4, dt)
pygrt.utils.stream_convolve(st, sigs)
pygrt.utils.stream_write_sac(st, "syn_ex/pout")
pygrt.utils.stream_write_sac(st, "p_syn_ex/")

st = pygrt.utils.gen_syn_from_gf_SF(st_grn, S, 2, -1, 4, az)
sigs = pygrt.sigs.gen_trap_wave(0.1, 0.3, 0.6, dt)
pygrt.utils.stream_convolve(st, sigs)
pygrt.utils.stream_write_sac(st, "syn_sf/pout")
pygrt.utils.stream_write_sac(st, "p_syn_sf/")

st = pygrt.utils.gen_syn_from_gf_DC(st_grn, S, 77, 88, 99, az)
sigs = pygrt.sigs.gen_parabola_wave(0.6, dt)
pygrt.utils.stream_convolve(st, sigs)
pygrt.utils.stream_write_sac(st, "syn_dc/pout")
pygrt.utils.stream_write_sac(st, "p_syn_dc/")

st = pygrt.utils.gen_syn_from_gf_MT(st_grn, S, [1,-2,-5,0.5,3,1.2], az)
sigs = pygrt.sigs.gen_ricker_wave(3, dt)
pygrt.utils.stream_convolve(st, sigs)
pygrt.utils.stream_write_sac(st, "syn_mt/pout")
pygrt.utils.stream_write_sac(st, "p_syn_mt/")
2 changes: 1 addition & 1 deletion example/seafloor/run_grt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ grt greenfn -M${modname} -O${out} -N${nt}/${dt} -D${depsrc}/${deprcv} -R${dist}
# just give a random focal mechanism
grt syn -G${out}/${modname}_${depsrc}_${deprcv}_${dist} -A20 -S1e20 -M100/20/120 -OSYN -e
# compute stress
grt stress SYN/out
grt stress SYN
Loading