introduction to visualization: paraview - mcgill hpc · 2 outline what is scientific visualization?...
TRANSCRIPT
2
Outline● What is scientific visualization?
● ParaView and visualization pipelines
● data import● 1D, 2D, 3D data visualization
● Animation
● Isosurfaces and volume rendering
● Data sets and formats (VTK)
● Putting it all together
3
Agenda (approximate)
● 9:00-10:30 - Introduction to Visualization and Paraview● 10:30 - 10:45 Coffee break● 10:45 - 12:00 Hands-on Activities● 12:00 - 1:00 Lunch Break● 1:00 - 2:30 Hands-on Activities cont.● 2:30 - 2:45 Coffee Break● 2:45 - 4:00 Project
Introduction to visualization and ParaView
Coffee
Hands-onActivities
Lunch Hands-onActivities
Coffee
Project
9:00 10:00 11:00 12:00 1:00 2:00 3:00
4
Acknowledgements: Workshop History● Based on University of Alberta Visualization Workshop
– Jon Johansson, Chris Want @ UofA● Original materials and data sets
– Delivered many times at UofA
– BCNet/HPCS 2012 in May
– Westgrid Visualization Roadshow● SFU (2), USask, URegina
– HPCS 2013 - Brian Corrie
– Aug 2013 - McGill HPC
– Aug 2014 - McGill HPC
– May 2015 - École d'été Calcul Québec
– Today @ McGill
5
Are you ready?● Ensure that you have:
– Paraview installed on your laptop/workstation
– paraview.zip - exercise files● unzip paraview.zip (Linux/Unix)● double click (Mac/Windows)
– PVExercises.pdf - exercise descriptions
6
What is Scientific Visualization?● Data into knowledge: Visualization presents scientific data to the
human visual and cognitive system for analysis and interpretation● The goal: extract/communicate knowledge/insight.● Our goal: Convert scientific data into visual form
– Exploration: understand the data– Interactively examine the data – Looking for aspects of the data that are interesting– Communication: communicate the data to peers
● within the research group● to external community (presentations, publications)
7
Tables of numbers● You may become good at seeing meaning in
tables of numbers
● This does not mean that your colleagues, or peer reviewers, or funding agencies are equally as good as you
● Want to show them the wonderful things you see with minimal time/effort on their part
8
Neo: Do you always look at it encoded?Neo: Do you always look at it encoded?Cypher: You get used to it. All I see is blonde, brunette, red-head...Cypher: You get used to it. All I see is blonde, brunette, red-head...
9
10
ParaView● Paraview provides a full set of tools for
manipulating, transforming, processing, rendering and animating data
● Allows for visualization and analysis methods based on points, lines, areas, volumes, images or geometric primitives in any combination
● Provides powerful parallel execution and advanced display (3D stereoscopic viewing)
● http://www.paraview.org
11
ParaView● Project began in 2000
– Kitware, Inc. and Los Alamos National Laboratory.
● ParaView is open source– ParaView is supported by Kitware
– Kitware contributes to ParaView development
● ParaView is built on top of the Visualization Toolkit (VTK)– VTK came out of GE Research
● First public release in October 2002: ParaView 0.6
12
ParaView Architecture● ParaView uses a client-server model
– In stand-alone mode the client does all processing on the local machine
● The client process is the user interface– it always runs on a workstation (desktop)
● The server does computation– In a single process on a local/remote machine, or
– In many processes on a cluster
13
Paraview Modes● Stand-alone mode
– Computations and user interface are run on same machine
● Client/server mode– Computations are run
on a server
● Parallel mode– Server launches an
mpi job on a cluster
14
Exercise 1: Starting ParaView● Linux/Unix: type paraview
● Windows: Select paraview from start menu
● Mac: click ParaView in App folder
● ParaView GUI should start up
● The server “pvserver” is run for you
16
ParaView Interface
Menus
Toolbars
PipelineBrowser
ObjectInspector
3D view
17
Visualization Pipeline
Reader Filter Filter Mapper Renderer
Imports data from a source(e.g. data file)
modify and/ormanipulatedata
modify and/ormanipulatedata
Transform datato geometry(e.g. points, lines, polygons,colours)
Converts geometryinto an image(e.g. pixels,vector graphics,polygons, volume rendering)
Filter
modify and/ormanipulatedata
18
Visualization Pipeline● Most visualization packages use a pipeline
model (ParaView, VTK, VisIT, Avizo)
● Pipeline components can be combined in many different ways to create a visualization
● Developers can add new components to the system to extend the package's functionality– ParaView allows python scripts as filters
19
Object-Based Rendering● Object based model with lighting
● Arrange the view (camera)● Render image from the camera position
20
Object Rendering● Results in an image
as seen from the camera's viewpoint
● Lights give shading, highlights and can modify color
● Surfaces nearest the camera occlude those behind
21
ParaView Objects● ParaView supports many techniques for
generating renderable objects from data.
● For scalar data these include:– Points and glyphs
– Contours and isosurfaces
– Histograms
– Two-dimensional and three-dimensional plots
● For vector data– Arrow plots, streamlines, etc
22
ParaView Objects● Annotations
– Ribbons, tubes, axes, text
– Display of data locations, meshes and boundaries
● Data interactions are also supported:– probing (selecting a location in a volume)
– picking (selecting a location on the surface of an object)
– arbitrary surface and volume sampling
– arbitrary cutting/mapping planes
23
Importing Data● Avoid data conversion!● For best results generate
your data in a vtk file format– STRUCTURED_POINTS
– STRUCTURED_GRID
– RECTILINEAR_GRID
– UNSTRUCTURED_GRID
– POLYDATA
– VTK XML
● Many common scientific data file formats can be opened and visualized
24
Legacy and XML VTK formats● Legacy VTK
– Simpler
– Can be read and written programmatically or by hand
● XML VTK– More flexible
– Supports random access, parallel I/O, compression
– Preferred format for VTK applications (Paraview)
25
VTK Data Formats● Visualization ToolKit
● Primary data format for paraview● Documentation:
– www.vtk.org/VTK/img/file-formats.pdf
26
VTK Data FormatsStructured Points Structured GridRectilinear Grid
Unstructured Grid PolyData
Data are regularly and uniformly spaced Spacing can be not uniform Not regular and not uniform
Like SG, but can handle all cell types Polygonal data
27
VTK Data Formats
DATASET STRUCTURED_POINTS
ORIGIN x y z
SPACING dx dy dz
DIMENSIONS nx ny nz
DATASET STRUCTURED_GRID
DIMENSIONS nx ny nz
POINTS n dataType
p0x p0y p0z
p1x p1y p1z
...
p(nx*ny*nz-1)x p(nx*ny*nz-1)y p(nx*ny*nz-1)z
DATASET RECTILINEAR_GRID
DIMENSIONS nx ny nz
X_COORDINATES nx dataType
x0 x1 ... x(nx-1)
Y_COORDINATES ny dataType
y0 y1 ... y(ny-1)
Z_COORDINATES nz dataType
z0 z1 ... z(nz-1)
Structured Points Structured GridRectilinear Grid
28
ParaView Data Formats
● VTK: .vtk, .pvtk, .vtp, .vtu, .vti, .vts, .vtr, .pvtp, .pvtu, .pvti, .pvts, .pvtr, .vtm, .vtmb, .vthb● Paraview: .pvd● Self-describing data formats: HDF5, netCDF● Ensight: .case, .sos● Protein Data Bank: .pdb● Xmol Molecule Files: .xyz● Gaussian Cube Files: .cube● POP Ocean Files: .pop● Images: .png, .tif● RAW (binary): .raw● lots of others, look at: File → Open File → Files of type:
● Open Source: Add a custom reader for your own data format
29
Getting Data into VTK format● Avoid data conversion!: Use/build applications that can
output to VTK formats
● If your data is not in a supported format, use the python library EVTK (Export VTK) to create a file converter
from evtk.hl import imageToVTK import numpy as np def readfile(file):
... #Implement file reader nx, ny, nz = 6, 6, 2 #Dimensionsreturn numpyArray.reshape((nx+1, ny+1, nz+1), order='C')
pressure = readfile(“Pdata.txt”)temp = readfile(“Tdata.txt”) imageToVTK("./image", cellData = {"pressure" : pressure}, \
pointData = {"temp" : temp} )
30
Pipelines● A program in
ParaView is called a “visualization pipeline”
● The eye icon controls whether the output of a filter is visible in the active window
● Data flows from the data source/reader down through the filters
PVServer →Data Source →
Filters →
Data F
low
31
Pipelines● The highlighted filter
can be configured through the “Object Inspector”
● The data produced by the filter is described in the “Information” tab
32
Pipelines● You can change a
filter's behaviour in the “Properties” tab
● Click “Apply” when you want your changes to take effect
33
Exercise 2: Pipelines● File->Open the
sample data set paraview/Bumps/ Bumps.vtk
● Change the colors for the data– Properties->Edit
– Select the “Rainbow” colormap
34
35
Exercise 2: Pipelines● Add dimension to
data– Use WarpByScalar
filter
– Uses scalar value as Z-dimension
● Scale magnitude of offset– Set the scale factor to
5
36
Exercise 3: ParaView Windows● Reproduce this
image:– Use objects from the
“Sources” menu● Cone● Sphere● Box● Cylinder
– Use the icons in the upper right of a window to split the view
37
ParaView Views● ParaView has many
types of views
● Some filters open a view window suitable to the filter's output– e.g. histograms
38
Exercise 4: 1D data● Please do activity 2
from the handout
● You will recreate the plots seen here
39
Exercise 5: 2D data● Please do activity 3
from the handout
● You will recreate the plots seen here
40
Exercise 6: Animation● ParaView is capable of easily making simple
animations– Not designed for complex animations
● Activity: Please do activity 4 from your handout
41
Exercise 7: 3D Data● 3D regular grid data - e.g. Medical CT scan
● Slice planes through gridded data● Please reconstruct the following image using
Slice filters on the jaw_16bit.vti data file:
42
Exercise 8: Isosurfaces● Use isosurfaces to
generate the visualization– 3D-Data/jaw_8bit.vti
● Isosurfaces with different colours represent the jaw, spine and skin
43
Big Project: Electric Field● Let's put together what we've learned to create
a visualization project involving:– A scalar field
– A vector field
– Annotations
44
Electric Potential● Consider the electric potential due to a
dielectric cylinder introduced into a constant electric field, .
● The parameters used are:
45
The Goal: Create this visualization
46
Which filters do you see?
47
Task 1: Create a VTK File● In the directory paraview/EPot is a file
containing the electric potential data in ascii text format
● Add an appropriate header to create a vtk file
● Hints:– refer to Bumps.vtk
– The origin is -50 for each axis
– The data spacing is 1 with 101 points along each axis
– There are 1013 points in the volume
48
Task 2: Slice the data set
● Open your .vtk file with ParaView
● Add a slice filter– Origin = 0, 0, -49.99
(not -50.0)
– Z Normal
49
Task 3: Contour Lines
● Add a contour filter– Delete the default range and click on Add Range
● From = -1750, To = 1750, Steps = 8
● This adds 8 lines
● Can you make them tubes?
50
51
Task 4: Compute Electric Field● Use the Gradient filter and the Calculator filter
to compute the electric field from the electric potential:
– Use the Gradient filter on the potential
– In the properties tab of the Calculator set Result Array name to ElectricField
– Calculate the expression:
-EPotentialGradient
52
Electric Field● Use a slice filter to put a
slice in the center of the volume
● If the input of the slice is a vector field, the magnitude will be displayed
53
Magnitude of the Electric Field
54
Streamlines
● Use a StreamTracer filter to the Calculator generating the Electric field
● Use a line source to seed the streamlines– Seed Type: Line Source
– Point1 = (50,50,0)
– Point2 = (50,-50,0)
– Resolution=10
● Add tubes to the lines
55
Streamlines
56
Glyphs● The top slice of our goal visualization shows glyphs at some
grid points of the electric field– Arrows indicating the direction and magnitude of the vector field
● Add a slice filter to the Calculator filter (electric field)– Origin=(0,0,50)
● Use a MaskPoints filter to control the points in the slice that will be glyphed– Set On Ratio to 10, Check the Random box with Randomized ID
strides
● Add a Glyph module with– Glyph Type: Arrow
– Scale Mode: Vector
– Adjust the arrow size parameters to your liking
57
Glyphs
58
Final view of the data● We have created
three visualizations of the data on three different slices
● We are still lacking context!
● Add information to help the viewer understand what they are looking at
59
Adding Meaning● Annotations: titles, labels, explanations
● Outline: define the volume of space being visualized
● Axes: orientation, scale
● Legend: map the colours to a scale
● Geometry: Add a cylinder to represent the dielectric cylinder
60
Annotations
61
Adding Meaning
● Annotations: titles, labels, explanations– Sources -> Text
● Outline: define the volume of space being visualized– Use “Outline” filter on
original data, add tubes
● Axes: orientation, scale– Display tab, “Show Cube
Axes”
● Legend: map the colours to a scale– Display tab, Edit Color Map
● Geometry: Add a cylinder to represent the dielectric cylinder– Sources -> Cylinder
– Height: 100
– Radius: 10
– Resolution: 50
– Opacity: 0.5
– Orientation: (90,0,0)
62
Putting it all together...
63
Putting it all together...● Goals of the exercise...
– Extract relevant information from the data set
– Show a variety of techniques that can be applied to the data set
– Provide enough annotation to orient the viewer
– Provide a visualization that communicates insight/understanding
64
Workshop Summary● Today, we learned how to...
– Import data and sources into Paraview
– Setup multiple views
– Construct a pipeline of filters to achieve desired visualizations out of 1D, 2D, and 3D data
● Contour, slice, glyph, gradient, calculator, stream tracer, warp by scalar, 2D plot
– Create and use visualization toolkit (VTK) file formats
– Create animations out of time-sliced data
– Add meaning to your visualizations● Annotations, axes labels, colours, geometry cues
65
Visualization Information● Compute Canada
– https://www.computecanada.ca/research-portal/visualization/
● Software– Kitware - http://www.kitware.com
– ParaView - http://www.paraview.org
– VTK - http://www.vtk.org
– VisIT - http://wci.llnl.gov/codes/visit/
– Avizo - http://www.vsg3d.com/avizo/overview
– MayaVI - http://mayavi.sourceforge.net/