/[escript]/trunk/doc/user/pyvisi.tex
ViewVC logotype

Diff of /trunk/doc/user/pyvisi.tex

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

revision 1193 by jongui, Thu May 24 01:04:17 2007 UTC revision 1194 by jongui, Thu Jun 14 05:53:49 2007 UTC
# Line 115  Rotate the camera to view the isometric Line 115  Rotate the camera to view the isometric
115  \end{methoddesc}  \end{methoddesc}
116    
117  \begin{methoddesc}[Camera]{dolly}{distance}  \begin{methoddesc}[Camera]{dolly}{distance}
118  Move the camera towards (greater than 1) and away (less than 1) from  Move the camera towards (greater than 1) the rendered object. However,
119  the rendered object.  the camera is unable to be moved away from the rendered object.
120  \end{methoddesc}  \end{methoddesc}
121    
122  \subsubsection{\Light class}  \subsubsection{\Light class}
# Line 242  can either be colored or grey-scaled, de Line 242  can either be colored or grey-scaled, de
242  \end{classdesc}  \end{classdesc}
243    
244  The following are some of the methods available:\\  The following are some of the methods available:\\
245  Methods from \ActorThreeD.  Methods from \ActorThreeD and \DataSetMapper.
246    
247  A typical usage of \Map is shown below.  A typical usage of \Map is shown below.
248    
# Line 292  m2 = Map(scene = s, data_collector = dc2 Line 292  m2 = Map(scene = s, data_collector = dc2
292          lut = Lut.COLOR, cell_to_point = True, outline = True)          lut = Lut.COLOR, cell_to_point = True, outline = True)
293    
294  # Create a Camera for the third viewport  # Create a Camera for the third viewport
295  c1 = Camera(scene = s, viewport = Viewport.NORTH_EAST)  c2 = Camera(scene = s, viewport = Viewport.NORTH_EAST)
296    
297  # Render the object.  # Render the object.
298  s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))  s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
# Line 309  X, Y and Z axes. Line 309  X, Y and Z axes.
309  \end{classdesc}  \end{classdesc}
310    
311  The following are some of the methods available:\\  The following are some of the methods available:\\
312  Methods from \ActorThreeD and \Transform.  Methods from \ActorThreeD, \Transform and \DataSetMapper.
313    
314  \subsubsection{\MapOnPlaneClip class}  \subsubsection{\MapOnPlaneClip class}
315    
# Line 321  scalar field clipped using a plane. Line 321  scalar field clipped using a plane.
321  \end{classdesc}  \end{classdesc}
322    
323  The following are some of the methods available:\\  The following are some of the methods available:\\
324  Methods from \ActorThreeD, \Transform and \Clipper.  Methods from \ActorThreeD, \Transform, \Clipper and \DataSetMapper.
325    
326  \subsubsection{\MapOnScalarClip class}  \subsubsection{\MapOnScalarClip class}
327    
# Line 333  field clipped using a scalar value. Line 333  field clipped using a scalar value.
333  \end{classdesc}  \end{classdesc}
334    
335  The following are some of the methods available:\\  The following are some of the methods available:\\
336  Methods from \ActorThreeD and \Clipper.  Methods from \ActorThreeD, \Clipper and \DataSetMapper.
337    
338  \subsubsection{\Velocity class}  \subsubsection{\Velocity class}
339    
# Line 348  using two-dimensional or three-dimension Line 348  using two-dimensional or three-dimension
348  \end{classdesc}  \end{classdesc}
349    
350  The following are some of the methods available:\\  The following are some of the methods available:\\
351  Methods from \ActorThreeD, \GlyphThreeD and \MaskPoints.  Methods from \ActorThreeD, \GlyphThreeD, \MaskPoints and \DataSetMapper.
352    
353  \subsubsection{\VelocityOnPlaneCut class}  \subsubsection{\VelocityOnPlaneCut class}
354    
# Line 361  it shows a vector field using arrows cut Line 361  it shows a vector field using arrows cut
361  \end{classdesc}  \end{classdesc}
362    
363  The following are some of the methods available:\\  The following are some of the methods available:\\
364  Methods from \ActorThreeD, \GlyphThreeD, \Transform and \MaskPoints.  Methods from \ActorThreeD, \GlyphThreeD, \Transform, \MaskPoints and
365    \DataSetMapper.
366    
367  A typical usage of \VelocityOnPlaneCut is shown below.  A typical usage of \VelocityOnPlaneCut is shown below.
368    
# Line 420  vector field using arrows clipped using Line 421  vector field using arrows clipped using
421  \end{classdesc}  \end{classdesc}
422    
423  The following are some of the methods available:\\  The following are some of the methods available:\\
424  Methods from \ActorThreeD, \GlyphThreeD, \Transform, \Clipper and  Methods from \ActorThreeD, \GlyphThreeD, \Transform, \Clipper,
425  \MaskPoints.  \MaskPoints and \DataSetMapper.
426    
427  \subsubsection{\Ellipsoid class}  \subsubsection{\Ellipsoid class}
428    
# Line 433  colored or grey-scaled, depending on the Line 434  colored or grey-scaled, depending on the
434  \end{classdesc}  \end{classdesc}
435    
436  The following are some of the methods available:\\  The following are some of the methods available:\\
437  Methods from \ActorThreeD, \Sphere, \TensorGlyph and \MaskPoints.  Methods from \ActorThreeD, \Sphere, \TensorGlyph, \MaskPoints and
438    \DataSetMapper.
439    
440  \subsubsection{\EllipsoidOnPlaneCut class}  \subsubsection{\EllipsoidOnPlaneCut class}
441    
# Line 445  a tensor field using ellipsoids cut usin Line 447  a tensor field using ellipsoids cut usin
447  \end{classdesc}  \end{classdesc}
448    
449  The following are some of the methods available:\\  The following are some of the methods available:\\
450  Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform and  Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform,
451  \MaskPoints.  \MaskPoints and \DataSetMapper.
452    
453  \subsubsection{\EllipsoidOnPlaneClip class}  \subsubsection{\EllipsoidOnPlaneClip class}
454    
# Line 458  tensor field using ellipsoids clipped us Line 460  tensor field using ellipsoids clipped us
460  \end{classdesc}  \end{classdesc}
461                    
462  The following are some of the methods available:\\  The following are some of the methods available:\\
463  Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform, \Clipper  Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform, \Clipper,
464  and \MaskPoints.  \MaskPoints and \DataSetMapper.
465    
466  A typical usage of \EllipsoidOnPlaneClip is shown below.  A typical usage of \EllipsoidOnPlaneClip is shown below.
467    
# Line 517  class can also be used to generate iso s Line 519  class can also be used to generate iso s
519  \end{classdesc}  \end{classdesc}
520    
521  The following are some of the methods available:\\  The following are some of the methods available:\\
522  Methods from \ActorThreeD and \ContourModule.  Methods from \ActorThreeD, \ContourModule and \DataSetMapper.
523    
524  A typical usage of \Contour is shown below.  A typical usage of \Contour is shown below.
525    
# Line 569  scalar field using contour surfaces cut Line 571  scalar field using contour surfaces cut
571  \end{classdesc}  \end{classdesc}
572    
573  The following are some of the methods available:\\  The following are some of the methods available:\\
574  Methods from \ActorThreeD, \ContourModule and \Transform.  Methods from \ActorThreeD, \ContourModule, \Transform and \DataSetMapper.
575    
576  \subsubsection{\ContourOnPlaneClip class}  \subsubsection{\ContourOnPlaneClip class}
577    
# Line 581  scalar field using contour surfaces clip Line 583  scalar field using contour surfaces clip
583  \end{classdesc}  \end{classdesc}
584    
585  The following are some of the methods available:\\  The following are some of the methods available:\\
586  Methods from \ActorThreeD, \ContourModule, \Transform and \Clipper.  Methods from \ActorThreeD, \ContourModule, \Transform, \Clipper and
587    \DataSetMapper.
588    
589  \subsubsection{\StreamLine class}  \subsubsection{\StreamLine class}
590    
# Line 595  modes, either using vector data or scala Line 598  modes, either using vector data or scala
598  \end{classdesc}  \end{classdesc}
599    
600  The following are some of the methods available:\\  The following are some of the methods available:\\
601  Methods from \ActorThreeD, \PointSource, \StreamLineModule and \Tube.  Methods from \ActorThreeD, \PointSource, \StreamLineModule, \Tube and
602    \DataSetMapper.
603    
604  A typical usage of \StreamLine is shown below.  A typical usage of \StreamLine is shown below.
605    
# Line 628  sl1 = StreamLine(scene = s, data_collect Line 632  sl1 = StreamLine(scene = s, data_collect
632          viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR,          viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR,
633          lut = Lut.COLOR, cell_to_point = False, outline = True)          lut = Lut.COLOR, cell_to_point = False, outline = True)
634  sl1.setTubeRadius(radius = 0.02)  sl1.setTubeRadius(radius = 0.02)
635    sl1.setTubeNumberOfSides(3)
636    sl1.setTubeRadiusToVaryByScalar()
637    
638  # Create a Camera.  # Create a Camera.
639  c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)  c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
# Line 649  Similarly, the plane can be deformated e Line 655  Similarly, the plane can be deformated e
655  \end{classdesc}  \end{classdesc}
656    
657  The following are some of the methods available:\\  The following are some of the methods available:\\
658  Methods from \ActorThreeD, \Warp and \Transform.  Methods from \ActorThreeD, \Warp, \Transform and \DataSetMapper.
659    
660  A typical usage of \Carpet is shown below.  A typical usage of \Carpet is shown below.
661    
# Line 693  c1.isometricView() Line 699  c1.isometricView()
699  s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))  s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME))
700  \end{python}  \end{python}
701    
702    \subsubsection{\Legend class}
703    
704    \begin{classdesc}{Legend}{scene, data_collector,
705    viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, legend = LegendType.SCALAR}
706    Class that shows a scalar field on a domain surface. The domain surface
707    can either be colored or grey-scaled, depending on the lookup table used
708    \end{classdesc}
709    
710    The following are some of the methods available:\\
711    Methods from \ActorThreeD, \ScalarBar and \DataSetMapper.
712    
713  \subsubsection{\Image class}  \subsubsection{\Image class}
714    
715  \begin{classdesc}{Image}{scene, image_reader, viewport = Viewport.SOUTH_WEST}  \begin{classdesc}{Image}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
# Line 768  of the logo can be specified. Line 785  of the logo can be specified.
785  The following are some of the methods available:\\  The following are some of the methods available:\\
786  Methods from \ImageReslice and \ActorTwoD.  Methods from \ImageReslice and \ActorTwoD.
787    
788    \subsubsection{\Movie class}
789    
790    \begin{classdesc}{Movie}{parameter_file = "make_movie"}
791    Class that creates a file called 'make_movie' by default (if a parameter
792    file name is not speficied) which contains a list of parameters required
793    by the 'ppmtompeg' command to generate a movie from a series of images.
794    \end{classdesc}
795    
796    The following are some of the methods available:\\
797    \begin{methoddesc}[Movie]{makeMovie}{input_directory, first_image, last_image,
798    movie}
799    Generate the movie.
800    \end{methoddesc}
801    
802    A typical usage of \Image is shown below.
803    
804    \begin{python}
805    # Import the necessary modules.
806    from esys.pyvisi import Scene, DataCollector, Map, Camera, Velocity, Legend
807    from esys.pyvisi import Movie, LocalPosition
808    from esys.pyvisi.constant import *
809    import os
810    
811    PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
812    PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
813    X_SIZE = 800
814    Y_SIZE = 800
815    
816    SCALAR_FIELD_POINT_DATA = "temp"
817    FILE_2D = "tempvel-"
818    IMAGE_NAME = "movie"
819    JPG_RENDERER = Renderer.ONLINE_JPG
820    
821    # Create a Scene.
822    s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
823            y_size = Y_SIZE)
824    
825    # Create a DataCollector reading from a XML file.
826    dc1 = DataCollector(source = Source.XML)
827    dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
828    
829    # Create a Map.
830    m1 = Map(scene = s, data_collector = dc1,
831            viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
832            outline = True)
833    
834    # Create a Camera.
835    cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
836    
837    # Create a movie.
838    mov = Movie()
839    
840    # Read in one file one after another and render the object.
841    for i in range(938, 949):
842        dc1.setFileName(file_name =  os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
843                FILE_2D + "%06d.vtu") % i)
844    
845        s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
846                IMAGE_NAME + "%06d.jpg") % i)
847    
848    # Generate the movie from the rendered images.
849    mov.makeMovie(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
850            first_image = IMAGE_NAME + "000938.jpg",
851            last_image = IMAGE_NAME + "000948.jpg",
852            movie = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))
853    \end{python}
854    
855    
856  %##############################################################################  %##############################################################################
857    
# Line 994  Mask every nth point. Line 1078  Mask every nth point.
1078  Enables the randomization of the points selected for masking.  Enables the randomization of the points selected for masking.
1079  \end{methoddesc}  \end{methoddesc}
1080    
1081    
1082    \subsubsection{\ScalarBar class}
1083    
1084    The following are some of the methods available:
1085    
1086    \begin{methoddesc}[ScalarBar]{setTitle}{title}
1087    Set the title of the scalar bar.
1088    \end{methoddesc}
1089    
1090    \begin{methoddesc}[ScalarBar]{setPosition}{position}
1091    Set the local position of the scalar bar.
1092    \end{methoddesc}
1093    
1094    \begin{methoddesc}[ScalarBar]{setOrientationToHorizontal}{}
1095    Set the orientation of the scalar bar to horizontal.
1096    \end{methoddesc}
1097    
1098    \begin{methoddesc}[ScalarBar]{setOrientationToVertical}{}
1099    Set the orientation of the scalar bar to vertical.
1100    \end{methoddesc}
1101    
1102    \begin{methoddesc}[ScalarBar]{setHeight}{height}
1103    Set the height of the scalar bar.
1104    \end{methoddesc}
1105    
1106    \begin{methoddesc}[ScalarBar]{setWidth}{width}
1107    Set the width of the scalar bar.
1108    \end{methoddesc}
1109    
1110    \begin{methoddesc}[ScalarBar]{setLabelColor}{color}
1111    Set the color of the scalar bar's label.
1112    \end{methoddesc}
1113    
1114    \begin{methoddesc}[ScalarBar]{setTitleColor}{color}
1115    Set the color of the scalar bar's title.
1116    \end{methoddesc}
1117    
1118  \subsubsection{\ImageReslice class}  \subsubsection{\ImageReslice class}
1119    
1120  The following are some of the methods available:  The following are some of the methods available:
# Line 1003  Set the size of the image (logo in parti Line 1124  Set the size of the image (logo in parti
1124  displays the image in its original size (which is the default).  displays the image in its original size (which is the default).
1125  \end{methoddesc}  \end{methoddesc}
1126    
1127    \subsubsection{\DataSetMapper class}
1128    
1129    The following are some of the methods available:
1130    
1131    \begin{methoddesc}[DataSetMapper]{setScalarRange}{lower_range, upper_range}
1132    Set the minimum and maximium scalar range for the data set mapper. This
1133    method is called when the range has been specified by the user.
1134    Therefore, the scalar range read from the source will be ignored.
1135    \end{methoddesc}
1136    
1137  % #############################################################################  % #############################################################################
1138    
# Line 1026  Y_SIZE = 300 Line 1156  Y_SIZE = 300
1156  SCALAR_FIELD_POINT_DATA_1 = "lava"  SCALAR_FIELD_POINT_DATA_1 = "lava"
1157  SCALAR_FIELD_POINT_DATA_2 = "talus"  SCALAR_FIELD_POINT_DATA_2 = "talus"
1158  FILE_2D = "phi_talus_lava."  FILE_2D = "phi_talus_lava."
 FIRST_FILE_NAME = "phi_talus_lava.0099.vtu"  
1159    
1160  IMAGE_NAME = "seriesofreads"  IMAGE_NAME = "seriesofreads"
1161  JPG_RENDERER = Renderer.ONLINE_JPG  JPG_RENDERER = Renderer.ONLINE_JPG
# Line 1035  JPG_RENDERER = Renderer.ONLINE_JPG Line 1164  JPG_RENDERER = Renderer.ONLINE_JPG
1164  s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,  s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
1165          y_size = Y_SIZE)          y_size = Y_SIZE)
1166    
1167  # Create a DataCollector reading from a XML file. An initial file must always  # Create a DataCollector reading from a XML file.
 # be assigned when the DataCollector is created, although the same file is  
 # read again in the for-loop.    
1168  dc1 = DataCollector(source = Source.XML)  dc1 = DataCollector(source = Source.XML)
 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \  
         FIRST_FILE_NAME))  
1169  dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)  dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)
1170    
1171  # Create a Contour.  # Create a Contour.
# Line 1051  mosc1.generateContours(0) Line 1176  mosc1.generateContours(0)
1176    
1177  # Create a second DataCollector reading from the same XML file.  # Create a second DataCollector reading from the same XML file.
1178  dc2 = DataCollector(source = Source.XML)  dc2 = DataCollector(source = Source.XML)
 dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \  
         FIRST_FILE_NAME))  
1179  dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2)  dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2)
1180    
1181  # Create a second Contour.  # Create a second Contour.
# Line 1078  for i in range(99, 104): Line 1201  for i in range(99, 104):
1201  \textsf{Manipulating A Single File with A Series of Translation}  \textsf{Manipulating A Single File with A Series of Translation}
1202    
1203  \begin{python}  \begin{python}
 # Import the necessary modules.  
 from esys.pyvisi import Scene, DataCollector, MapOnPlaneCut, Camera  
 from esys.pyvisi.constant import *  
 import os  
   
 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"  
 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"  
 X_SIZE = 400  
 Y_SIZE = 400  
   
 SCALAR_FIELD_POINT_DATA = "temperature"  
 FILE_3D = "interior_3D.xml"  
 IMAGE_NAME = "seriesofcuts"  
 JPG_RENDERER = Renderer.ONLINE_JPG  
   
 # Create a Scene.  
 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,  
         y_size = Y_SIZE)  
   
 # Create a DataCollector reading from a XML file.  
 dc1 = DataCollector(source = Source.XML)  
 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D))  
 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)  
   
 # Create a MapOnPlaneCut.  
 mopc1 = MapOnPlaneCut(scene = s, data_collector = dc1,  
         viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,  
         outline = True)  
 mopc1.setPlaneToYZ(offset = 0.1)  
   
 # Create a Camera.  
 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)  
 c1.isometricView()  
1204    
 # Render the object with multiple cuts from a series of translation.  
 for i in range(0, 5):  
     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME +  
             "%02d.jpg") % i)  
     mopc1.translate(0.6,0,0)  
1205  \end{python}  \end{python}
1206    
1207  \textsf{Reading Data Directly from Escript Objects}  \textsf{Reading Data Directly from Escript Objects}
# Line 1135  X_SIZE = 400 Line 1220  X_SIZE = 400
1220  Y_SIZE = 400  Y_SIZE = 400
1221  JPG_RENDERER = Renderer.ONLINE_JPG  JPG_RENDERER = Renderer.ONLINE_JPG
1222    
1223  #... Set some parameters ...  #... set some parameters ...
1224  xc=[0.02,0.002]  xc=[0.02,0.002]
1225  r=0.001  r=0.001
1226  qc=50.e6  qc=50.e6
# Line 1144  rhocp=2.6e6 Line 1229  rhocp=2.6e6
1229  eta=75.  eta=75.
1230  kappa=240.  kappa=240.
1231  tend=5.  tend=5.
1232  # ... Time, time step size and counter ...  # ... time, time step size and counter ...
1233  t=0  t=0
1234  h=0.1  h=0.1
1235  i=0  i=0
1236    
1237  #... Generate domain ...  #... generate domain ...
1238  mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)  mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
1239  #... open PDE ...  #... open PDE ...
1240  mypde=LinearPDE(mydomain)  mypde=LinearPDE(mydomain)
1241  mypde.setSymmetryOn()  mypde.setSymmetryOn()
1242  mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)  mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
1243  # ... Set heat source: ....  # ... set heat source: ....
1244  x=mydomain.getX()  x=mydomain.getX()
1245  qH=qc*whereNegative(length(x-xc)-r)  qH=qc*whereNegative(length(x-xc)-r)
1246  # ... set initial temperature ....  # ... set initial temperature ....
# Line 1175  m = Map(scene = s, data_collector = dc, Line 1260  m = Map(scene = s, data_collector = dc,
1260  # Create a Camera.  # Create a Camera.
1261  c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)  c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
1262    
1263  # ... Start iteration:  # ... start iteration:
1264  while t<tend:  while t<0.4:
1265        i+=1        i+=1
1266        t+=h        t+=h
1267        mypde.setValue(Y=qH+rhocp/h*T)        mypde.setValue(Y=qH+rhocp/h*T)

Legend:
Removed from v.1193  
changed lines
  Added in v.1194

  ViewVC Help
Powered by ViewVC 1.1.26