• No results found

Neutron Science Visualization Software

N/A
N/A
Protected

Academic year: 2021

Share "Neutron Science Visualization Software"

Copied!
20
0
0

Loading.... (view fulltext now)

Full text

(1)

1. September 2011

Mi tg lie d de r H el mh ol tz-G eme in sch af t

Neutron Science Visualization

Software

(2)

1. September 2011

2

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Contents

ü 

Visualization Software Requirements in Neutron Science

ü 

Available Software

ü 

Review

ü 

Possible Approaches

ü 

Pros and Cons

ü 

GR Basics

ü 

Real-life-examples

ü 

Conclusions

(3)

1. September 2011

3

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Visualization Software Requirements in Neutron

Science

User Aspects

Software Engineering Aspects

Ease of use

Easy to install

Fully-customizable

High quality graphics output in

various formats

Produce fast and reliable results

Standard APIs for the creation of

2D- or 3D-graphs

Publication-quality printing and

capturing capabilities

Embeddable in other applications,

especially GUIs and Web Apps

Native look and feel

Scripting capabilities

Usability over slow network

connections

Long-time support

Well-documented

Open Source based

(4)

1. September 2011

4

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Available Software

Graphics Application

Programming

Interfaces

Integrated

Visualization Systems

Graphical User

Interface Tools

ü

Cairo Graphics

ü

DISLIN

ü

GR / GKS

ü

Matplotlib

ü

OpenGL

ü

PGPlot

ü

Qwt3D

ü

SDL

ü

VTK

ü

Gnuplot

ü

GLI

ü

grpython

ü

IDL

ü

IGOR Pro

ü

MantidPlot

ü

Octave

ü

Origin

ü

PlotScript

ü

QtiKWS

ü

QtiPlot

ü

XmGrace

ü

FLTK

ü

Gtk / Gtk+

ü

Motif

ü

Qt4 / Qt3

ü

Tk

ü

Ultimate++

ü

wxWidgets

ü

XForms

(5)

1. September 2011

5

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

(6)

1. September 2011

6

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Review (continued)

Software developers are maintaining three principles:

ü 

Reusability (classes, objects, methods)

ü 

Extensibility (inheritance)

ü 

Simplicity (abstraction, encapsulation, polymorphism)

The above mentioned principles might have improved

maintainability, but did they really help users?

ü 

Linux distribution spins, flavors, …

ü 

Desktop environments: GNOME, KDE, Unity, …

(7)

1. September 2011

7

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Possible Approaches

Graphics Application

Programming

Interfaces

Integrated

Visualization Systems

Graphical User

Interface Tools

ü

 Cairo Graphics

ü

 DISLIN

ü

 GR / GKS

ü

 Matplotlib

ü

 OpenGL

ü

 PGPlot

ü

Qwt3D

ü

 SDL

ü

 VTK

ü

Gnuplot

ü

 GLI

ü

 grpython

ü

 IDL

ü

 IGOR Pro

ü

 MantidPlot

ü

 Octave

ü

 Origin

ü

PlotScript

ü

QtiKWS

ü

 QtiPlot

ü

 XmGrace

ü

 FLTK

ü

Gtk / Gtk+

ü

 Motif

ü

 Qt4 /

Qt3

ü

 Tk

ü

 Ultimate++

ü

 wxWidgets

ü

 XForms

(8)

1. September 2011

8

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Pros and Cons

Pro

Contra

PlotScript +

Instrument specific menus

+

Adapted to scientists’ needs

-

GTK/GTK+ (or wxWidgets) based GUI

-

  Gnuplot graphics (separated)

-

no API

QtiKWS

+

Uses existing QtiPlot framework

+

Adapted to KWS instruments

-

Qt3 based GUI

-

  Qt/Qwt3D graphics

-

no API

GR

+

Standardized graphics (GKS)

+

Embeddable into Qt4 based GUIs

+

High quality graphics output in

various formats

+

Cross language (Fortran, C/C++,

Python, …)

+

Cross-platform

+

Conforms to the “Jülich–Munich

Standard”

+

Web ready

(9)

1. September 2011

9

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

GR from a developer point of view

Fortran"

C / C++"

Fortran"

Objective-C"

Python"

Psh"

..."

C / C++"

GR!

Pascal"

Graphical Kernel System

(GKS)!

Win32"

X11"

GLGr!

OpenGL (ES)!

gksqt"

GKSTerm"

Java"

gkswebapp"

Qt"

Quartz"

PS" PDF"

SVG"

…"

Additional drivers / plugins:!

-

  CGM, GKSM, GIF, RF, UIL"

-

  WMF, Xfig"

(10)

1. September 2011

10

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

GR from user point of view

Physics Computer!

OpenGL enabled Host /

iOS Device!

Socket communication

"

GKS Logical Device Drivers!

Win32"

X11"

C / Objective-C!

C!

Qt GUI"

C / C++!

GKSTerm"

gksqt"

Qt event loop

"

Python!

Java"

gkswebapp"

SVG"

OpenGL!

ES!

GLGr!

GR!

GKS!

Qt"

Quartz"

PS" PDF"

…"

Additional drivers / plugins:!

-

  CGM, GKSM, GIF, RF, UIL"

-

  WMF, Xfig"

(11)

1. September 2011

11

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

% gkswebapp

% export GKS_WSTYPE=410

...

% glgr

% export GKS_WSTYPE=410

...

(12)

1. September 2011

12

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Real-life-examples: KWSlive ...

ü 

Written in C++

ü 

Requires Qt4, TACO and GR / GKS

ü 

Native GUI completely rewritten using Qt SDK (Qt Creator,

Qt Designer)

ü 

Visualization based on GKS Qt logical device driver

ü 

Platform independent graphics output (GrWidget)

ü 

Smooth integration into Qt event mechanism

ü 

Features:

3D surface plots, contour plots, 2D line plots, radial

averages, ROI selection, least-square fitting, sensitivity

masks, TOF channel selection

(13)

1. September 2011

13

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

(14)

1. September 2011

14

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

(15)

1. September 2011

15

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

#!/usr/bin/env python import sys, string, os from PyQt4 import *

from PyQt4 import QtCore, QtGui import sip

import gr

def readData(file, data) :

stream = open(file, "r") num_items = -1

for line in stream.readlines() : if line == "" : break if line[0] == "$" : num_items = 0 else : if num_items >= 0 : line = line[:-1] for s in string.split(line) : data[num_items] = int(s) num_items = num_items + 1 stream.close() class GrWidget(QtGui.QWidget) : def __init__(self, *args) : QtGui.QWidget.__init__(self) self.setupUi(self)

os.environ['GKS_WSTYPE'] = "381" os.environ['GKS_DOUBLE_BUF'] = "True" timer = QtCore.QTimer(self)

self.connect(timer, QtCore.SIGNAL("timeout()"), self.draw) timer.start(1000)

def setupUi(self, Form) :

Form.setWindowTitle("GrWidget")

Form.resize(QtCore.QSize(600, 600).expandedTo( Form.minimumSizeHint()))

def draw(self) : x = y = range(128) z = range(128 * 128) readData('simple.dat', z) z_max = max(z) gr.setviewport(0.1, 0.95, 0.1, 0.95) gr.setwindow(0, 127, 0, 127) gr.setspace(0, z_max, 0, 90) gr.setlinewidth(0.75) gr.setcharheight(18 / 600.) gr.axes(5, 5, 1, 1, 4, 4, -0.0075) gr.surface(128, 128, x, y, z, 5) h = range(0, 1) gr.contour(128, 128, 0, x, y, h, z, -1) self.update()

def paintEvent(self, ev) :

self.painter = QtGui.QPainter() self.painter.begin(self) os.environ['GKS_CONID'] = "%x!%x” % (sip.unwrapinstance(self), sip.unwrapinstance(self.painter)) gr.updatews() self.painter.end() def quit(self) :

gr.emergencyclosegks() self.close() app = QtGui.QApplication(sys.argv) w = GrWidget() w.show() sys.exit(app.exec_())

… a simple

PyQt4/GR script

(16)

1. September 2011

16

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

real x(30), y(30), z(30,30), tbx(4), tby(4) real r1, r2, z1, z2 do 1, i = 1, 30 x(i) = -2.0 + (i - 1) * 0.5 y(i) = -7.0 + (i - 1) * 0.5 1 continue do 2, i = 1, 30 do 3, j = 1, 30 r1 = sqrt((x(i)-5)**2+y(j)**2) r2 = sqrt((x(i)+5)**2+y(j)**2) z1 = exp(cos(r1)) z2 = exp(cos(r2)) z(i,j) = (z1 + z2 - 0.9) * 25 3 continue 2 continue call gr_beginprint('face.pdf') call gr_setcharheight(24.0/500) call gr_settextalign(2, 1)

call gr_textext(0.5, 0.9, 'Surface Example')

call gr_inqtextext(0.5, 0.9, 'Surface Example', tbx, tby) call gr_fillarea(4, tbx, tby)

call gr_setcharheight(14.0/500) call gr_setviewport(0.1, 0.9, 0.1, 0.9) call gr_setwindow(-3.0, 13.0, -8.0, 8.0) call gr_settextfontprec(3, 0) call gr_setspace(-20.0, 200.0, 45, 70) call gr_axes3d(1.0, 0.0, 10.0, -3.0, -8.0, -20.0, 2, 2, 4, -0.01) call gr_axes3d(0.0, 1.0, 0.0, 13.0, -8.0, -20.0, 2, 2, 4, -0.01) call gr_titles3d('X-Axis', 'Y-Axis', 'Z-Axis')

call gr_surface(30, 30, x, y, z, 3) call gr_surface(30, 30, x, y, z, 1) call gr_updatews() call gr_endprint() read(*, *) call gr_emergencyclosegks() end #include <math.h> #include "gr.h" int main(void) {

float x[30], y[30], z[30][30], tbx[4], tby[4]; float r1, r2, z1, z2; int i, j; for (i = 0; i < 30; i++) { x[i] = -2.0 + (i - 1) * 0.5; y[i] = -7.0 + (i - 1) * 0.5; } for (i = 0; i < 30; i++) { for (j = 0; j < 30; j++) { r1 = sqrt((pow(x[i]-5,2))+pow(y[j],2)); r2 = sqrt((pow(x[i]+5,2))+pow(y[j],2)); z1 = exp(cos(r1)); z2 = exp(cos(r2)); z[i][j] = (z1 + z2 - 0.9) * 25; } } gr_beginprint("face.pdf"); gr_setcharheight(24.0/500); gr_settextalign(2, 1);

gr_textext(0.5, 0.9, "Surface Example");

gr_inqtextext(0.5, 0.9, "Surface Example", tbx, tby); gr_fillarea(4, tbx, tby); gr_setcharheight(14.0/500); gr_setviewport(0.1, 0.9, 0.1, 0.9); gr_setwindow(-3.0, 13.0, -8.0, 8.0); gr_settextfontprec(3, 0); gr_setspace(-20.0, 200.0, 45, 70); gr_axes3d(1.0, 0.0, 10.0, -3.0, -8.0, -20.0, 2, 2, 4, -0.01); gr_axes3d(0.0, 1.0, 0.0, 13.0, -8.0, -20.0, 2, 2, 4, -0.01); gr_titles3d("X-Axis", "Y-Axis", "Z-Axis");

gr_surface(30, 30, x, y, (float *)z, 3); gr_surface(30, 30, x, y, (float *)z, 1); gr_updatews(); gr_endprint(); sleep(5); gr_emergencyclosegks(); }

Fortran

C

(17)

1. September 2011

17

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

0

100

200

0

100

200

0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

… Python + NumPy + GR

(18)

1. September 2011

18

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Conclusions

GR is not an all-in-one solution, but it might help to make a lot

of things easier:

Ø 

keeps things as simple as possible and reduces complexity

Ø 

increases maintainability and extensibility

Ø 

makes use of abstraction layers

Ø 

loosely couples system-specific components

Ø 

allows code to be reused in other applications

Ø 

minimizes use of external code

(19)

1. September 2011

19

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Future plans

Ø 

Move GR code into a code management system

(Subversion,

Git, Trac

)

Ø 

Setup a Wiki (documentation)

Ø 

Add more 3D functions (OpenGL)

Ø 

Add a GKS logical device driver for

wxWidgets

Ø 

Migrate SIGHT (

S

imple

I

nteractive

G

raphics

H

andling

T

ool)

to Qt4

(20)

1. September 2011

20

J. Heinen, PGI/JCNS-TA, Scientific IT-Systems

Thanks to …

Dück, Marcel (GKS WebApp)

Bachelor Thesis: “Entwicklung eines GKS-Gerätetreibers als Java-basierte Client/Server

Webanwendung”

Felder, Christian (GLGr OpenGL ES Programming)

Master Thesis: “Implementierung einer Visualisierungsanwendung für Apples iOS”

Goblet, Marvin (GKSTerm)

Bachelor Thesis: “Entwicklung eines GKS Gerätetreibers auf der Basis des Mac OS X Core

Graphics Frameworks”

Neßelrath, Robert (GLGr OpenGL Programming)

Diploma Thesis: “Plattformunabhängige Visualisierung von Neutronenspektren auf der Basis

von OpenGL”

References

Related documents

To sum up, if proposing cohabitation entails an expected cost, then the game be- comes richer and many new equilibria emerge (including signaling with cohabitation) but the main

The ACHN needs to be associated with a login account on the Aqua Connect website to control and/or monitor their pool via the web.. A given ACHN can only be associated with a

Google Migration Implementation Plan/Schedule Page 3 of 6 Develop scheme for data migration TI. Develop scheme for mail architecture &amp; delivery

At the same time, the loss of trust in Russia since the Ukraine crisis opens up the possibility for NATO to cooperate more intensively with those post-Soviet countries that have

Table 3 shows a characterizing profile for each living lab and illustrates that the new added building blocks act as a differentiator. However, it should be noted that these

Compared with families that lost SSI benefits due to normal attrition from the program, the excess benefit loss due to the 1996 childhood disability reforms is associated with

BusinessObjects XI R2 Integration Kit for SAP MUST be installed in order to use SAP BW Server as a data source from Web Intelligence, Crystal Reports, Desktop Intelligence and

David Rizzieri, director of Duke’s hematologic malignancies program, says genomic research has brought liquid tumor treatment to a watershed moment.. “We’ve been getting the