ESM4714
Scientific Visual Data Analysis and Multimedia
Exercise #2: PV-Wave Introduction


Objectives:
Understand how to use basic PV-Wave commands and data formats to generate images.

Procedure: NOTE: Highlighted italic text denotes user response.
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.

  1. Logon to mecury -> pluto.smvc.vt.edu in the the SMVC classroom.

  2. Mount your optical disk (see procedure for mounting scsi devices).

  3. If you are on a workstaions mercury->pluto in the SMVC you should be able to find the file ESM4714.tar.gz one directory below your home directory (cd ../homework) and copy this file into your home directory and/or onto your optical disk. If you lose or destroy any files you can go back to get the original ESM4714.tar.gz. When you are done with this exercise you can remove the directory and all its contents recursively by using a single UNIX command % \rm -rf "your new directory name". Be careful when you use this command: the system does not query you before the files and directories are actually deleted.

    If your optical disk was just formatted you must first get a copy of ESM4714.tar.gz:

    With your optical disk mounted at /rmdisk/rmdisk0:

    • cd ~username (This will place you at your home directory)

    • cd ../homework (The ESM4714.tar.gz file is archived in this directory)

    • ls -la (In this list of files and directories you should see ESM4714.tar.gz)
      NOTE: the rwx permissions assigned to ESM4714.tar.gz should give you read privilages which
      means you should be able to copy ESM4714.tar.gz to your optical disk or your home directory

    • cp ESM4714.tar.gz /rmdisk/rmdisk0 (copy file to your optical disk) OR
    • cp ESM4714.tar.gz ~username (copy file to your home directory)

    • cd /rmdisk/rmdisk0 (go to optical disk directory where you just copied ESM4714.tar.gz)

    • ls -la (verify that the file ESM4714.tar.gz was indeed copied correctly)

    • gunzip ESM4714.tar.gz (uncompress the file)

    • ls -la (verify that the file was uncompress by noticing that the *.gz extension is gone)

    • tar xvf ESM4714.tar (untar the file into it's directories and files)

    • ls -la (verify that a new directory ESM4714 was created)
      Now you are ready to work with ESM4714 data files either on your optical disk or in your home directory.

  4. Initiate PV-Wave:

    % wave
    and the system returns the prompt
    wave>

  5. Load the file brown.ascii.start and assign it to unit 1.

    wave> openr,1,'brown.ascii.start'

  6. Create an integer array "a" for storing data:

    wave> a=intarr(64,64)

  7. Read data from unit 1 and place data into array "a".

    wave> readf,1,a

  8. 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

  9. 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.

  10. Find the maximum and minimum values and print them.

    wave> maxa=max(a)
    wave> mina=min(a)
    wave> print,mina,maxa

  11. 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.

  12. 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.

  13. 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

  14. 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.

  15. 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.

  16. 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.

  17. 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

  18. Do it -->

    % wave
    wave> create_images
    wave> show_images

    NOTE: If you decrease the image size the animation plays faster, Try it

Click image to return to Visualization home page.
R.D. Kriz
Virginia Tech
College of Engineering
Revised 01/10/03

http://www.sv.vt.edu/classes/ESM4714/exercises/exer2/exer2.html