@@ -22,6 +22,7 @@ def compare3(st_py:Stream, c_prefix:str, ZNE:bool=False, dim2:bool=False):
2222 nerr = 0
2323 for tr_c in st_c :
2424 tr_py = st_py .select (channel = tr_c .stats .channel )[0 ]
25+ tr_c .data [tr_c .data == 0.0 ] = 1.0
2526 rerr = np .mean (np .abs (tr_c .data - tr_py .data ) / np .abs (tr_c .data ))
2627 if np .isnan (rerr ) or np .isinf (rerr ):
2728 rerr = 0.0
@@ -53,7 +54,7 @@ def static_compare3(resDct:dict, c_prefix:str):
5354 continue
5455 val1 = resDct [k ]
5556 val2 = f .variables [k ][:]
56- print (k , np .mean (np .abs (val1 - val2 )), np .max (val2 ))
57+ print (k , np .mean (np .abs (val1 - val2 )), np .max (np . abs ( val2 ) ))
5758
5859 val2 [val2 == 0.0 ] = 1.0
5960
@@ -105,52 +106,52 @@ def static_compare3(resDct:dict, c_prefix:str):
105106M33 = 1.2
106107
107108for ZNE in [False , True ]:
109+ suffix = "-N" if ZNE else ""
108110 # synthetic
109-
110111 st = pygrt .utils .gen_syn_from_gf_EX (st_grn , S , az , ZNE = ZNE , calc_upar = True )
111112 sigs = pygrt .sigs .gen_triangle_wave (0.4 , dt )
112113 pygrt .utils .stream_convolve (st , sigs )
113- AVGRERR .append (compare3 (st , "syn_ex/cout " , ZNE = ZNE ))
114+ AVGRERR .append (compare3 (st , f "syn_ex{ suffix } / " , ZNE = ZNE ))
114115 ststrain = pygrt .utils .compute_strain (st )
115116 strotation = pygrt .utils .compute_rotation (st )
116117 ststress = pygrt .utils .compute_stress (st )
117- AVGRERR .append (compare3 (ststrain , "syn_ex/cout.strain. " , ZNE = ZNE , dim2 = True ))
118- AVGRERR .append (compare3 (strotation , "syn_ex/cout.rotation. " , ZNE = ZNE , dim2 = True ))
119- AVGRERR .append (compare3 (ststress , "syn_ex/cout.stress. " , ZNE = ZNE , dim2 = True ))
118+ AVGRERR .append (compare3 (ststrain , f "syn_ex{ suffix } /strain_ " , ZNE = ZNE , dim2 = True ))
119+ AVGRERR .append (compare3 (strotation , f "syn_ex{ suffix } /rotation_ " , ZNE = ZNE , dim2 = True ))
120+ AVGRERR .append (compare3 (ststress , f "syn_ex{ suffix } /stress_ " , ZNE = ZNE , dim2 = True ))
120121
121122
122123 st = pygrt .utils .gen_syn_from_gf_SF (st_grn , S , fn , fe , fz , az , ZNE = ZNE , calc_upar = True )
123124 sigs = pygrt .sigs .gen_trap_wave (0.1 , 0.3 , 0.6 , dt )
124125 pygrt .utils .stream_convolve (st , sigs )
125- AVGRERR .append (compare3 (st , "syn_sf/cout " , ZNE = ZNE ))
126+ AVGRERR .append (compare3 (st , f "syn_sf{ suffix } / " , ZNE = ZNE ))
126127 ststrain = pygrt .utils .compute_strain (st )
127128 strotation = pygrt .utils .compute_rotation (st )
128129 ststress = pygrt .utils .compute_stress (st )
129- AVGRERR .append (compare3 (ststrain , "syn_sf/cout.strain. " , ZNE = ZNE , dim2 = True ))
130- AVGRERR .append (compare3 (strotation , "syn_sf/cout.rotation. " , ZNE = ZNE , dim2 = True ))
131- AVGRERR .append (compare3 (ststress , "syn_sf/cout.stress. " , ZNE = ZNE , dim2 = True ))
130+ AVGRERR .append (compare3 (ststrain , f "syn_sf{ suffix } /strain_ " , ZNE = ZNE , dim2 = True ))
131+ AVGRERR .append (compare3 (strotation , f "syn_sf{ suffix } /rotation_ " , ZNE = ZNE , dim2 = True ))
132+ AVGRERR .append (compare3 (ststress , f "syn_sf{ suffix } /stress_ " , ZNE = ZNE , dim2 = True ))
132133
133134 st = pygrt .utils .gen_syn_from_gf_DC (st_grn , S , stk , dip , rak , az , ZNE = ZNE , calc_upar = True )
134135 sigs = pygrt .sigs .gen_parabola_wave (0.6 , dt )
135136 pygrt .utils .stream_convolve (st , sigs )
136- AVGRERR .append (compare3 (st , "syn_dc/cout " , ZNE = ZNE ))
137+ AVGRERR .append (compare3 (st , f "syn_dc{ suffix } / " , ZNE = ZNE ))
137138 ststrain = pygrt .utils .compute_strain (st )
138139 strotation = pygrt .utils .compute_rotation (st )
139140 ststress = pygrt .utils .compute_stress (st )
140- AVGRERR .append (compare3 (ststrain , "syn_dc/cout.strain. " , ZNE = ZNE , dim2 = True ))
141- AVGRERR .append (compare3 (strotation , "syn_dc/cout.rotation. " , ZNE = ZNE , dim2 = True ))
142- AVGRERR .append (compare3 (ststress , "syn_dc/cout.stress. " , ZNE = ZNE , dim2 = True ))
141+ AVGRERR .append (compare3 (ststrain , f "syn_dc{ suffix } /strain_ " , ZNE = ZNE , dim2 = True ))
142+ AVGRERR .append (compare3 (strotation , f "syn_dc{ suffix } /rotation_ " , ZNE = ZNE , dim2 = True ))
143+ AVGRERR .append (compare3 (ststress , f "syn_dc{ suffix } /stress_ " , ZNE = ZNE , dim2 = True ))
143144
144145 st = pygrt .utils .gen_syn_from_gf_MT (st_grn , S , [M11 ,M12 ,M13 ,M22 ,M23 ,M33 ], az , ZNE = ZNE , calc_upar = True )
145146 sigs = pygrt .sigs .gen_ricker_wave (3 , dt )
146147 pygrt .utils .stream_convolve (st , sigs )
147- AVGRERR .append (compare3 (st , "syn_mt/cout " , ZNE = ZNE ))
148+ AVGRERR .append (compare3 (st , f "syn_mt{ suffix } / " , ZNE = ZNE ))
148149 ststrain = pygrt .utils .compute_strain (st )
149150 strotation = pygrt .utils .compute_rotation (st )
150151 ststress = pygrt .utils .compute_stress (st )
151- AVGRERR .append (compare3 (ststrain , "syn_mt/cout.strain. " , ZNE = ZNE , dim2 = True ))
152- AVGRERR .append (compare3 (strotation , "syn_mt/cout.rotation. " , ZNE = ZNE , dim2 = True ))
153- AVGRERR .append (compare3 (ststress , "syn_mt/cout.stress. " , ZNE = ZNE , dim2 = True ))
152+ AVGRERR .append (compare3 (ststrain , f "syn_mt{ suffix } /strain_ " , ZNE = ZNE , dim2 = True ))
153+ AVGRERR .append (compare3 (strotation , f "syn_mt{ suffix } /rotation_ " , ZNE = ZNE , dim2 = True ))
154+ AVGRERR .append (compare3 (ststress , f "syn_mt{ suffix } /stress_ " , ZNE = ZNE , dim2 = True ))
154155
155156
156157#-------------------------- Static -----------------------------------------
0 commit comments