parameters: (ax, mesh, data, startStream=3, coarseMesh=None, quiver=False,
                  **kwargs)
docstring: Draw streamlines based on an unstructured mesh.
  
      Every cell contains only one streamline and every new stream line
      starts in the center of a cell. You can alternatively provide a second mesh
      with coarser mesh to draw streams for.
  
      Parameters
      ----------
      ax : matplotlib.ax
          ax to draw into
      mesh : :gimliapi:`GIMLI::Mesh`
          2d mesh
      data : iterable float | [float, float] | pg.core.R3Vector
          If data is an array (per cell or node) gradients are calculated
          otherwise the data will be interpreted as vector field per nodes or
          cell centers.
      startStream : int
          variate the start stream drawing, try values from 1 to 3 what every
          you like more.
      coarseMesh : :gimliapi:`GIMLI::Mesh`
          Instead of draw a stream for every cell in mesh, draw a streamline
          segment for each cell in coarseMesh.
      quiver : bool [False]
          Draw arrows instead of streamlines.
  
      Keyword Arguments
      -----------------
      **kwargs
          Additional kwargs forwarded to axe.quiver, drawStreamLine_
  
      Examples
      --------
      >>> import numpy as np
      >>> import matplotlib.pyplot as plt
      >>> import pygimli as pg
      >>> from pygimli.viewer.mpl import drawStreams
      >>> n = np.linspace(0, 1, 10)
      >>> mesh = pg.createGrid(x=n, y=n)
      >>> nx = pg.x(mesh.positions())
      >>> ny = pg.y(mesh.positions())
      >>> data = np.cos(1.5 * nx) * np.sin(1.5 * ny)
      >>> fig, ax = plt.subplots()
      >>> drawStreams(ax, mesh, data, color='red')
      >>> drawStreams(ax, mesh, data, dropTol=0.9)
      >>> drawStreams(ax, mesh, pg.solver.grad(mesh, data),
      ...             color='green', quiver=True)
      >>> ax.set_aspect('equal')
      >>> pg.wait()
docstring_summary: Draw streamlines based on an unstructured mesh.
docstring_tokens: Draw streamlines based on an unstructured mesh .
function: def drawStreams(ax, mesh, data, startStream=3, coarseMesh=None, quiver=False,
                  **kwargs):
      """Draw streamlines based on an unstructured mesh.
  
      Every cell contains only one streamline and every new stream line
      starts in the center of a cell. You can alternatively provide a second mesh
      with coarser mesh to draw streams for.
  
      Parameters
      ----------
      ax : matplotlib.ax
          ax to draw into
      mesh : :gimliapi:`GIMLI::Mesh`
          2d mesh
      data : iterable float | [float, float] | pg.core.R3Vector
          If data is an array (per cell or node) gradients are calculated
          otherwise the data will be interpreted as vector field per nodes or
          cell centers.
      startStream : int
          variate the start stream drawing, try values from 1 to 3 what every
          you like more.
      coarseMesh : :gimliapi:`GIMLI::Mesh`
          Instead of draw a stream for every cell in mesh, draw a streamline
          segment for each cell in coarseMesh.
      quiver : bool [False]
          Draw arrows instead of streamlines.
  
      Keyword Arguments
      -----------------
      **kwargs
          Additional kwargs forwarded to axe.quiver, drawStreamLine_
  
      Examples
      --------
      >>> import numpy as np
      >>> import matplotlib.pyplot as plt
      >>> import pygimli as pg
      >>> from pygimli.viewer.mpl import drawStreams
      >>> n = np.linspace(0, 1, 10)
      >>> mesh = pg.createGrid(x=n, y=n)
      >>> nx = pg.x(mesh.positions())
      >>> ny = pg.y(mesh.positions())
      >>> data = np.cos(1.5 * nx) * np.sin(1.5 * ny)
      >>> fig, ax = plt.subplots()
      >>> drawStreams(ax, mesh, data, color='red')
      >>> drawStreams(ax, mesh, data, dropTol=0.9)
      >>> drawStreams(ax, mesh, pg.solver.grad(mesh, data),
      ...             color='green', quiver=True)
      >>> ax.set_aspect('equal')
      >>> pg.wait()
      """
      viewMesh = None
      dataMesh = None
  
      if quiver:
  
          x = None
          y = None
          u = None
          v = None
  
          if len(data) == mesh.nodeCount():
              x = pg.x(mesh.positions())
              y = pg.y(mesh.positions())
          elif len(data) == mesh.cellCount():
              x = pg.x(mesh.cellCenters())
              y = pg.y(mesh.cellCenters())
          elif len(data) == mesh.boundaryCount():
              x = pg.x(mesh.boundaryCenters())
              y = pg.y(mesh.boundaryCenters())
  
          if isinstance(data, pg.core.R3Vector):
              u = pg.x(data)
              v = pg.y(data)
          else:
              u = data[:, 0]
              v = data[:, 1]
  
          ax.quiver(x, y, u, v, **kwargs)
  
          updateAxes_(ax)
          return
  
      if coarseMesh is not None:
          viewMesh = coarseMesh
          dataMesh = mesh
          dataMesh.createNeighborInfos()
      else:
          viewMesh = mesh
  
      viewMesh.createNeighborInfos()
  
      for c in viewMesh.cells():
          c.setValid(True)
  
      if startStream == 1:
          # start a stream from each boundary cell
          for y in np.linspace(viewMesh.ymin(), viewMesh.ymax(), 100):
              c = viewMesh.findCell(
                  [(viewMesh.xmax() - viewMesh.xmax()) / 2.0, y])
              if c is not None:
                  if c.valid():
                      drawStreamLine_(ax, viewMesh, c, data, dataMesh, **kwargs)
  
      elif startStream == 2:
          # start a stream from each boundary cell
          for x in np.linspace(viewMesh.xmin(), viewMesh.xmax(), 100):
              c = viewMesh.findCell(
                  [x, (viewMesh.ymax() - viewMesh.ymax()) / 2.0])
              if c is not None:
                  if c.valid():
                      drawStreamLine_(ax, viewMesh, c, data, dataMesh, **kwargs)
  
      elif startStream == 3:
          # start a stream from each boundary cell
          for b in viewMesh.findBoundaryByMarker(1, 99):
              c = b.leftCell()
              if c is None:
                  c = b.rightCell()
  
              if c.valid():
                  drawStreamLine_(ax, viewMesh, c, data, dataMesh, **kwargs)
  
      # start a stream from each unused cell
      for c in viewMesh.cells():
          if c.valid():
              drawStreamLine_(ax, viewMesh, c, data, dataMesh, **kwargs)
  
      for c in viewMesh.cells():
          c.setValid(True)
  
      updateAxes_(ax)
function_tokens: def drawStreams ( ax , mesh , data , startStream = 3 , coarseMesh = None , quiver = False , * * kwargs ) : viewMesh = None dataMesh = None if quiver : x = None y = None u = None v = None if len ( data ) == mesh . nodeCount ( ) : x = pg . x ( mesh . positions ( ) ) y = pg . y ( mesh . positions ( ) ) elif len ( data ) == mesh . cellCount ( ) : x = pg . x ( mesh . cellCenters ( ) ) y = pg . y ( mesh . cellCenters ( ) ) elif len ( data ) == mesh . boundaryCount ( ) : x = pg . x ( mesh . boundaryCenters ( ) ) y = pg . y ( mesh . boundaryCenters ( ) ) if isinstance ( data , pg . core . R3Vector ) : u = pg . x ( data ) v = pg . y ( data ) else : u = data [ : , 0 ] v = data [ : , 1 ] ax . quiver ( x , y , u , v , * * kwargs ) updateAxes_ ( ax ) return if coarseMesh is not None : viewMesh = coarseMesh dataMesh = mesh dataMesh . createNeighborInfos ( ) else : viewMesh = mesh viewMesh . createNeighborInfos ( ) for c in viewMesh . cells ( ) : c . setValid ( True ) if startStream == 1 : # start a stream from each boundary cell for y in np . linspace ( viewMesh . ymin ( ) , viewMesh . ymax ( ) , 100 ) : c = viewMesh . findCell ( [ ( viewMesh . xmax ( ) - viewMesh . xmax ( ) ) / 2.0 , y ] ) if c is not None : if c . valid ( ) : drawStreamLine_ ( ax , viewMesh , c , data , dataMesh , * * kwargs ) elif startStream == 2 : # start a stream from each boundary cell for x in np . linspace ( viewMesh . xmin ( ) , viewMesh . xmax ( ) , 100 ) : c = viewMesh . findCell ( [ x , ( viewMesh . ymax ( ) - viewMesh . ymax ( ) ) / 2.0 ] ) if c is not None : if c . valid ( ) : drawStreamLine_ ( ax , viewMesh , c , data , dataMesh , * * kwargs ) elif startStream == 3 : # start a stream from each boundary cell for b in viewMesh . findBoundaryByMarker ( 1 , 99 ) : c = b . leftCell ( ) if c is None : c = b . rightCell ( ) if c . valid ( ) : drawStreamLine_ ( ax , viewMesh , c , data , dataMesh , * * kwargs ) # start a stream from each unused cell for c in viewMesh . cells ( ) : if c . valid ( ) : drawStreamLine_ ( ax , viewMesh , c , data , dataMesh , * * kwargs ) for c in viewMesh . cells ( ) : c . setValid ( True ) updateAxes_ ( ax )