Exercise #2: PV-Wave Introduction
Understand how to use basic PV-Wave commands and data formats to generate images. NOTE: Highlighted italic text denotes user response.
Objective:
Create images and a animation sequence from a 3-Dimensional(3D) data set, brown.ascii (Gas-Air Mixture simulation), using TV-grayscale, contours, raised 3D-surfaces, and gouraud shaded 3D-surfaces.
Procedure:
- Logon to viz1(SUN), viz2(SUN), viz5(SGI), viz6(SGI), viz9(SGI), or viz10(DEC)
- If you are on viz1 or viz2 mount your optical disk (see procedure for mounting scsi devices). If you are on the SGI or DEC workstations remote mount your optical disk on viz1 or viz2, or ftp filename brown.ascii form your optical disk on viz1 or viz2. If all goes right for this semester each workstation should have a directory WorkSpace/ESM5984 with the same information that is on your optical disk so that you do not have to remote mount your optical disk. If
you use this directory PLEASE KEEP THIS DIRECTORY CLEAN for others to use.
- From exercise#1 you should be able to relocate the file brown.ascii.start.Z in the brown directory and make a new directory with "your last name" uncompress this file and move it into the directory with "your last name". This keeps things clean. When you are done with this exercise you can remove the directory and all its contents recursively by using a single UNIX command % \rm -r "your last name". Be careful when you use this command: the system does not query you before the files and directories are actually deleted.
- % mkdir "your last name"
- % uncompress brown.ascii.start.Z
- % cp brown.ascii.start "your last name"
- % cd "your last name"
- Initiate PV-Wave:
- % wave
- and the system returns the prompt
- wave>
- Load the file brown.ascii.start and assign it to unit 1.
- wave> openr,1,'brown.ascii.start'
- Create an integer array "a" for storing data:
- wave> a=intarr(64,64)
- Read data from unit 1 and place data into array "a".
- wave> readf,1,a
- Create a window (number 1) with 64 pixels along the x-horizontal and 64 pixels along the vertical (xsize=64, ysize=64) and position the lower left corner of this window 200 pixels left of the CRT screen and 600 pixels up from the bottom of the CRT.
- wave> window,1,xsize=64,ysize=64,xpos=200,ypos=600
- Scale array (find maximum and minimum values and scale them to 255 and 0 repectively) and then draw this array as a black-white (grayscale) TV image.
- wave> tvscl,a look at this image
- wave> tv,a compare it with this image where no scaling is done
- NOTE: There is a difference in the two images because brown.ascii.start is already a scaled 3D interger field with a minimum of 0 and a maximum of 255 but these values may not always exist in each 2D layer (slice) of the 3D data. This is verified below.
- Find the maximum and minimum values and print them.
- wave> maxa=max(a)
- wave> mina=min(a)
- wave> print,mina,maxa
- Read the next field (slice)(64,64) of the 3D data set and satisfy yourself that the minimum and maximum values can vary in adjacent slices and are not necessarily 0 or 255.
- Create a larger window but scaled by an integer multiple of 4.
- wave> window,2,xsize=256,ysize=256,xpos=400,ypos=400
- wave> tvscl,a check out this image
- NOTE: The original data appers as a small scaled tv-grayscale image in the lower left corner. This should tell you where PV-Wave locates the image origin at the lower left corner which is different when viewing the same data in SpyGlass where the image is in the upper left corner.
- Scale image to full size of the window and draw the newly scaled image.
- wave> aa=congrid(a,256,256)
- wave> tvscl,aa look at this image and
- wave> tvscl,a and compare it with thisimage
- With the larger window draw arrays "a" and "aa" with contour lines for comparison.
- wave> contour,a compare this image with one that has more contour lines
- wave> contour,aa
- If you want more contour lines you can over-ride the default with the nlevels parameter.
- wave> contour,a,nlevels=25 this image has more contour lines.
- Within the same window (window#2) familiarize yourself with the features of other visualization routines that either operate on "a" or "aa" arrays. For example.
- For a coarse mesh < 50
- wave> surface,a look at this image
- wave> surface,aa and compare it with this image
- For a fine mesh > 50
- wave> shade_surf,a look at this image
- wave> shade_surf,aa and compare it with this image
- Recommendation: You may now try other PV-Wave routines such as "smooth" or you could tilt the shade_surf image by rotating about the horizontal, ax=30 (default), and/or rotation about the vertical axis, az=30 (default). A different tilt angle view can reveal new information.
- If you want to store your image as a binary "byte" array first open a filename in which the image will be stored, then create the byte array name with dimensions the same as the window size, and then finally transfer the image to this "bytarr" array.
- wave> openw,2,'image.byt'
- wave> image=assoc(2,bytarr(256,26))
- wave> image(1)=tvrd(0,0,256,256)
- NOTE: Here we stored only one image. We could also create a sequence of images, "animation", one image for each slice, and store all these images in one large file. This can be done by writing a procedure file of PV-Wave commands with a "for" loop command.
B
- Create and store Shade_surf images for all 44 slices from brown.ascii and store these images in file named "images.byt" and play back this image sequence as an animation by using PV-Wave procedure files which are listed below. Using the "vi" editor, create these two procedure files listed below.
- Procedure filename "create_images.pro" : % vi create_images.pro
- __________________________________________________________
- pro create_images
- ;procedure creates and image sequence stroed in file "images.byt"
- openr,1,'brown.ascii.start'
- openw,2,'images.byt'
- a=intarr(64,64)
- images=assoc(2,bytarr(256,256))
- window,3,xsize=256,ysize=256,xpos=500,ypos=500
- for i=1,44 do begin
- readf,1,a
- shade_surf,a,ax=50,az=40
- images(i)=tvrd(0,0,256,256)
- endfor
- close,1
- close,2
- return
- end
- Procedure filename "show_images.pro": % vi show_images.pro
- ____________________________________________________________
- pro show_images
- ;procedure plays an image sequence as an animation
- openr,1,'images.byt'
- images=assoc(1,bytarr(256,256))
- window,4,xsize=256,ysize=256,xpos=500,ypos=200
- for i=1,44 do begin
- tv,images(i)
- empty
- endfor
- close,1
- return
- end
- Do it -->
- % wave
- wave> create_images
- wave> show_images
- NOTE: If you decrease the image size the animation plays faster, Try it