@@ -206,7 +206,8 @@ def plotSlice(
206206 range_x = None ,
207207 range_y = None ,
208208 sample_grid = None ,
209- stream_threshold = None
209+ stream_threshold = None ,
210+ stream_thickness = None
210211 ):
211212
212213 """
@@ -249,7 +250,8 @@ def plotSlice(
249250 v , vType = vTypeI , normal = normal , ind = ind , grid = grid ,
250251 view = view , ax = ax , clim = clim , showIt = False ,
251252 pcolorOpts = pcolorOpts , streamOpts = streamOpts ,
252- gridOpts = gridOpts , stream_threshold = stream_threshold
253+ gridOpts = gridOpts , stream_threshold = stream_threshold ,
254+ stream_thickness = stream_thickness
253255 )
254256 ]
255257 return out
@@ -351,7 +353,9 @@ def doSlice(v):
351353 range_x = range_x ,
352354 range_y = range_y ,
353355 sample_grid = sample_grid ,
354- stream_threshold = stream_threshold
356+ stream_threshold = stream_threshold ,
357+ stream_thickness = stream_thickness
358+
355359 )
356360
357361 ax .set_xlabel ('y' if normal == 'X' else 'x' )
@@ -368,7 +372,8 @@ def _plotImage2D(
368372 range_x = None ,
369373 range_y = None ,
370374 sample_grid = None ,
371- stream_threshold = None
375+ stream_threshold = None ,
376+ stream_thickness = None
372377 ):
373378
374379 if pcolorOpts is None :
@@ -494,6 +499,36 @@ def _plotImage2D(
494499 Ui = np .ma .masked_where (mask_me , Ui )
495500 Vi = np .ma .masked_where (mask_me , Vi )
496501
502+
503+ if stream_thickness is not None :
504+ scaleFact = np .copy (stream_thickness )
505+
506+ # Calculate vector amplitude
507+ vecAmp = np .sqrt (U ** 2 + V ** 2 ).T
508+
509+ # Form bounds to knockout the top and bottom 10%
510+ vecAmp_sort = np .sort (vecAmp .ravel ())
511+ nVecAmp = vecAmp .size
512+ tenPercInd = int (np .ceil (0.1 * nVecAmp ))
513+ lowerBound = vecAmp_sort [tenPercInd ]
514+ upperBound = vecAmp_sort [- tenPercInd ]
515+
516+ lowInds = np .where (vecAmp < lowerBound )
517+ vecAmp [lowInds ] = lowerBound
518+
519+ highInds = np .where (vecAmp > upperBound )
520+ vecAmp [highInds ] = upperBound
521+
522+ # Normalize amplitudes 0-1
523+ norm_thickness = vecAmp / vecAmp .max ()
524+
525+ # Scale by user defined thickness factor
526+ stream_thickness = scaleFact * norm_thickness
527+
528+ # Add linewidth to streamOpts
529+ streamOpts .update ({'linewidth' :stream_thickness })
530+
531+
497532 out += (
498533 ax .pcolormesh (
499534 x , y , np .sqrt (U ** 2 + V ** 2 ).T , vmin = clim [0 ], vmax = clim [1 ],
0 commit comments