@@ -48,7 +48,8 @@ def plotImage(
4848 streamOpts = None ,
4949 gridOpts = None ,
5050 numbering = True , annotationColor = 'w' ,
51- range_x = None , range_y = None , sample_grid = None
51+ range_x = None , range_y = None , sample_grid = None ,
52+ stream_threshold = None
5253 ):
5354 """
5455 Mesh.plotImage(v)
@@ -116,7 +117,7 @@ def plotImage(
116117 ax = ax , clim = clim , showIt = showIt ,
117118 pcolorOpts = pcolorOpts , streamOpts = streamOpts ,
118119 gridOpts = gridOpts , range_x = range_x , range_y = range_y ,
119- sample_grid = sample_grid
120+ sample_grid = sample_grid , stream_threshold = stream_threshold
120121 )
121122 elif self .dim == 3 :
122123 # get copy of image and average to cell-centers is necessary
@@ -186,14 +187,15 @@ def plotImage(
186187 plt .show ()
187188 return ph
188189
189- def plotSlice (self , v , vType = 'CC' ,
190- normal = 'Z' , ind = None , grid = False , view = 'real' ,
191- ax = None , clim = None , showIt = False ,
192- pcolorOpts = None ,
193- streamOpts = None ,
194- gridOpts = None ,
195- range_x = None , range_y = None
196- ):
190+ def plotSlice (
191+ self , v , vType = 'CC' ,
192+ normal = 'Z' , ind = None , grid = False , view = 'real' ,
193+ ax = None , clim = None , showIt = False ,
194+ pcolorOpts = None ,
195+ streamOpts = None ,
196+ gridOpts = None ,
197+ range_x = None , range_y = None
198+ ):
197199
198200 """
199201 Plots a slice of a 3D mesh.
@@ -321,7 +323,8 @@ def _plotImage2D(
321323 gridOpts = None ,
322324 range_x = None ,
323325 range_y = None ,
324- sample_grid = None
326+ sample_grid = None ,
327+ stream_threshold = None
325328 ):
326329
327330 if pcolorOpts is None :
@@ -427,8 +430,21 @@ def _plotImage2D(
427430 U = Ui
428431 V = Vi
429432
430- out += (ax .pcolormesh (x , y , np .sqrt (U ** 2 + V ** 2 ).T , vmin = clim [0 ], vmax = clim [1 ], ** pcolorOpts ),)
431- out += (ax .streamplot (tMi .vectorCCx , tMi .vectorCCy , Ui .T , Vi .T , ** streamOpts ),)
433+ if stream_threshold is not None :
434+ mask_me = np .sqrt (U ** 2 + V ** 2 ) <= stream_threshold
435+ Ui = np .ma .masked_where (mask_me , Ui )
436+ Vi = np .ma .masked_where (mask_me , Vi )
437+
438+ out += (
439+ ax .pcolormesh (
440+ x , y , np .sqrt (U ** 2 + V ** 2 ).T , vmin = clim [0 ], vmax = clim [1 ],
441+ ** pcolorOpts ),
442+ )
443+ out += (
444+ ax .streamplot (
445+ tMi .vectorCCx , tMi .vectorCCy , Ui .T , Vi .T , ** streamOpts
446+ ),
447+ )
432448
433449 if grid :
434450 xXGrid = np .c_ [self .vectorNx , self .vectorNx , np .nan * np .ones (self .nNx )].flatten ()
0 commit comments