@@ -146,8 +146,8 @@ def wiggle(stream1, stream2=None, sort=None, tmin=0., tmax=30, normalize=True,
146
146
147
147
# PLot wiggles according to either baz or slowness
148
148
def wiggle_bins (stream1 , stream2 = None , tr1 = None , tr2 = None ,
149
- btyp = 'baz' , tmin = 0. , tmax = 30. , xtyp = 'time' , scale = None ,
150
- norm = None , save = False , title = None , form = 'png' ):
149
+ btyp = 'baz' , trange = [ 0. , 30. ] , xtyp = 'time' ,
150
+ norm = None , save = None , folder = None , show = True ):
151
151
"""
152
152
Function to plot receiver function according to either baz or
153
153
slowness bins. By default,
@@ -167,16 +167,19 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
167
167
Trace to plot at the top of ``stream2``
168
168
btyp : str
169
169
Type of plot to produce (either 'baz', 'slow', or 'dist')
170
- tmax : float
171
- Maximum x-axis value displayed in the Figure.
170
+ trange : list of two floats
171
+ Range of x-axis values displayed in the Figure.
172
172
xtyp : str
173
173
Type of x-axis label (either 'time' or 'depth')
174
- scale : float
175
- Scale factor applied to trace amplitudes for plotting
176
- save : bool
177
- Whether or not to save the Figure
178
- title : str
179
- Title of plot
174
+ norm : float
175
+ Normalization value applied to all traces. If not specified,
176
+ default amplitude ranges will be set.
177
+ save : str
178
+ Filename of figure to be saved, including extension.
179
+ folder : str
180
+ Folder name where figure will be saved.
181
+ show : bool
182
+ Whether or not to show the figure upon execution.
180
183
181
184
"""
182
185
@@ -188,35 +191,31 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
188
191
raise (Exception ("Cannot plot by slowness if data is migrated" ))
189
192
190
193
# Figure out scaling here
191
- if scale :
192
- maxval = scale
193
- maxvalT = maxval
194
- else :
195
- if norm :
196
- for tr in stream1 :
194
+ if norm is not None :
195
+ for tr in stream1 :
196
+ tr .data /= norm
197
+ if stream2 :
198
+ for tr in stream2 :
197
199
tr .data /= norm
198
- if stream2 :
199
- for tr in stream2 :
200
- tr .data /= norm
201
- if btyp == 'baz' :
202
- maxval = 10.
203
- maxvalT = maxval
204
- elif btyp == 'slow' :
205
- maxval = 0.001
206
- maxvalT = 2. * maxval
207
- elif btyp == 'dist' :
208
- maxval = 1
209
- maxvalT = maxval
210
- else :
211
- if btyp == 'baz' :
212
- maxval = 100
213
- maxvalT = maxval
214
- elif btyp == 'slow' :
215
- maxval = 0.02
216
- maxvalT = maxval
217
- elif btyp == 'dist' :
218
- maxval = 20
219
- maxvalT = maxval
200
+ if btyp == 'baz' :
201
+ maxval = 10.
202
+ maxvalT = maxval
203
+ elif btyp == 'slow' :
204
+ maxval = 0.001
205
+ maxvalT = 2. * maxval
206
+ elif btyp == 'dist' :
207
+ maxval = 1
208
+ maxvalT = maxval
209
+ else :
210
+ if btyp == 'baz' :
211
+ maxval = 100
212
+ maxvalT = maxval
213
+ elif btyp == 'slow' :
214
+ maxval = 0.02
215
+ maxvalT = maxval
216
+ elif btyp == 'dist' :
217
+ maxval = 20
218
+ maxvalT = maxval
220
219
221
220
# Time axis
222
221
nn = stream1 [0 ].stats .npts
@@ -270,7 +269,7 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
270
269
ax1 .set_yticks (())
271
270
ax1 .set_xticks (())
272
271
ax1 .set_title ('Radial' )
273
- ax1 .set_xlim (tmin , tmax )
272
+ ax1 .set_xlim (trange [ 0 ], trange [ 1 ] )
274
273
275
274
# Plot binned SV traces in back-azimuth on bottom left
276
275
for tr in stream1 :
@@ -299,7 +298,7 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
299
298
ax2 .plot (time , y + tr .data * maxval ,
300
299
linewidth = 0.25 , c = 'k' )
301
300
302
- ax2 .set_xlim (tmin , tmax )
301
+ ax2 .set_xlim (trange [ 0 ], trange [ 1 ] )
303
302
304
303
if btyp == 'baz' :
305
304
ax2 .set_ylim (- 5 , 370 )
@@ -337,7 +336,7 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
337
336
linewidth = 0 )
338
337
ax3 .plot (time , tr2 .data ,
339
338
linewidth = 0.25 , c = 'k' )
340
- ax3 .set_xlim (tmin , tmax )
339
+ ax3 .set_xlim (trange [ 0 ], trange [ 1 ] )
341
340
ax3 .set_ylim (- 1. * ylimT , ylimT )
342
341
ax3 .set_yticks (())
343
342
ax3 .set_xticks (())
@@ -371,7 +370,7 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
371
370
ax4 .plot (time , y + tr .data * maxvalT ,
372
371
linewidth = 0.25 , c = 'k' )
373
372
374
- ax4 .set_xlim (tmin , tmax )
373
+ ax4 .set_xlim (trange [ 0 ], trange [ 1 ] )
375
374
376
375
if btyp == 'baz' :
377
376
ax4 .set_ylim (- 5 , 370 )
@@ -390,13 +389,15 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
390
389
if not ax3 :
391
390
ax4 .set_title ('Transverse' )
392
391
393
- if title :
394
- plt .suptitle (title )
395
-
396
392
if save :
397
- plt .savefig ('RF_PLOTS/' + stream1 [0 ].stats .station +
398
- '.' + title + '.' + form , format = form )
399
- else :
393
+ if folder is not None :
394
+ plt .savefig (folder + '/' + stream1 [0 ].stats .station +
395
+ '.' + save , format = save .split ('.' )[- 1 ], dpi = 300 )
396
+ else :
397
+ plt .savefig ('RF_PLOTS/' + stream1 [0 ].stats .station +
398
+ '.' + save , format = save .split ('.' )[- 1 ], dpi = 300 )
399
+
400
+ if show :
400
401
plt .show ()
401
402
402
403
plt .close ()
0 commit comments