/[escript]/trunk/doc/examples/cookbook/cblib.py
ViewVC logotype

Diff of /trunk/doc/examples/cookbook/cblib.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2671 by jfenwick, Thu Sep 17 01:49:11 2009 UTC revision 2672 by ahallam, Fri Sep 18 01:46:47 2009 UTC
# Line 26  from esys.pycad import CurveLoop Line 26  from esys.pycad import CurveLoop
26    
27  # numpy for array handling  # numpy for array handling
28  import numpy as np  import numpy as np
29    import pylab as pl
30  # tools for dealing with PDEs - contains locator  # tools for dealing with PDEs - contains locator
31  from esys.escript.pdetools import Locator  from esys.escript.pdetools import Locator, Projector
32    
33  from esys.escript import *  from esys.escript import *
34  from esys.escript.linearPDEs import LinearPDE  from esys.escript.linearPDEs import LinearPDE
# Line 64  def toQuivLocs(quivshape,lenxax,lenyax,q Line 65  def toQuivLocs(quivshape,lenxax,lenyax,q
65      qu = np.array(qu) #turn into a numpy array      qu = np.array(qu) #turn into a numpy array
66      qulocs = quL.getX() #returns actual locations from data      qulocs = quL.getX() #returns actual locations from data
67      qulocs = np.array(qulocs) #turn into a numpy array      qulocs = np.array(qulocs) #turn into a numpy array
68      return qu,qulocs          return qu,qulocs
69        
70    
71        
72    
73  # Extract the X and Y coordinates of an array  # Extract the X and Y coordinates of an array
74  # coords :: escript coordiantes from .getX function  # coords :: escript coordiantes from .getX function
# Line 73  def toXYTuple(coords): Line 77  def toXYTuple(coords):
77      coordX = coords[:,0]; coordY = coords[:,1] #X and Y components.      coordX = coords[:,0]; coordY = coords[:,1] #X and Y components.
78      return coordX,coordY      return coordX,coordY
79    
80    def toRegGrid(grid,domain,newx,newy,width,depth):
81        oldspacecoords=domain.getX()
82        gridT = grid.toListOfTuples(scalarastuple=False)
83        cxy = Data(oldspacecoords, grid.getFunctionSpace())
84        cX, cY = toXYTuple(cxy)
85        xi = np.linspace(0.0,width,newx)    
86        yi = np.linspace(depth,0.0,newy)
87        # grid the data.
88        zi = pl.matplotlib.mlab.griddata(cX,cY,gridT,xi,yi)
89        return xi,yi,zi
90        
91    def gradtoRegGrid(grid,domain,newx,newy,width,depth,dim):
92        cxy = grid.getFunctionSpace().getX()
93        gridT = grid.toListOfTuples()#(scalarastuple=False)
94        #cxy = Data(oldspacecoords, grid.getFunctionSpace())
95        cX, cY = toXYTuple(cxy)
96        xi = np.linspace(0.0,width,newx)    
97        yi = np.linspace(depth,0.0,newy)
98        
99        gridT = np.array(gridT)
100        gridT = gridT[:,dim]
101        
102        # grid the data.
103        
104        zi = pl.matplotlib.mlab.griddata(cX,cY,gridT,xi,yi)
105        return xi,yi,zi
106  ########################################################  ########################################################
107  # subroutine: cbphones  # subroutine: cbphones
108  # Allows us to record the values of a PDE at various  # Allows us to record the values of a PDE at various

Legend:
Removed from v.2671  
changed lines
  Added in v.2672

  ViewVC Help
Powered by ViewVC 1.1.26