# Presentation: 156350

## 	Data Visualization

*	**EPICS Extensions IDL Tools*

- Ben-chin K. Cha
- Beamline Control & Data Acquisition

## Introduction

**Written in IDL/ezcaIDL to view real-time  / post scan data**
**Packaged data browsers with complete mouse driven user interface**
**IDL interactive graphics and analysis tools**
**High quality interactive graphic Itools (IDL 6.X)**
**Packaged tools support license free IDLVM 6.0 **
**Platforms: Unix , Win2000/XP, Linux**
**Object methods for easy post scan data array extraction and manipulation**

## Outline

**Overview **
**System and setup requirement**
**ScanSee program user interface**
**Sharable visualization subprograms**
**Scan object methods and examples**
**EzcaIDL setup and examples **

**Notes:**
Tools are implemented:
- User friendly and complete mouse driven
- Based on perceived functions desired in display and analysis of multi-lines and images 
- Added new features requested by users
- User interface further improved by feedback from users

## Scan Visualization Architecture

- ScanSee:
- Packaged IDL
- Scan Visualization
- Analysis Tools

- ezcaIDL

- EzcaScan/ezca

- EPICS
- CA

- IOC
- Controller
- sscan
- with
- saveData

- Save
- MDA Data

- MEDM
- Scan Controls

## Overview

**Scan Visualization Tools**
*scanSee  – 85 detectors,1D/2D/3D scan (read MDA)*
*catcher  – 15 detectors,1D/2D scan (save/read 1D/2D files)*
**HDF Visualization Tools**
*hdfb – HDF4 1D/2D/3D browser*
*h5b – HDF5 1D/2D/3D browser*
**Common/sharable Visual/Analysis Tools    **_**[http://](http://www.aps.anl.gov/~cha/idl_html/list.html)**__**[www.aps.anl.gov/~cha/idl_html/list.html](http://www.aps.anl.gov/~cha/idl_html/list.html)**_
*plot1d, ez _fit, overlay_1d*
*plot2d_image, plot2d, image2d, view3D_2D*
*calibration_factor, scan2d_roi, multiroi_pick*
*panimage, scan2d_overlay, wd_readascii*

**Notes:**
Image dim up to 400x400 garantee Good performance for scanSee

## Input Forms

**XDR catcher 1D/2D file**
**MDA 1D/2D/3D scan data**
**Nexus/HDF release 4 1D/2D/3D data**
**Nexus/HDF release 5 1D/2D/3D data**
**Arrays data**
**Fix format ASCII data**

## Output Forms

**1D/2D graphic output**
**1D/2D ASCII report data**
**Graphic output: TIFF / PNG / PICT / PS **
**1D/2D ROI statistics reports**
**Flexible 3D to 2D, 2D to 1D sliced output**

## System Requirement

**EPICS extensions built: ezca, EzcaScan, ezcaIDL, idl **
*Scripts and executables installed under **/usr/local/epics/extensions/bin/solaris-sparc for 3.14.X*
*IDL programs installed under        *
*    **/usr/local/epics/extensions/idllib for 3.14.X*
**IDL 6.0 and IDLVM 6.0 installed**
**IOC sscan record properly configured by medm**

## Unix Setup Requirement

- Set EPICS_EXTENSIONS
-    setenv EPICS_EXTENSION  /usr/local/epics/extensions
- Access EPICS 3.14.X
**  **setenv EPICS_HOST_ARCH solaris-sparc
-    set path=( /usr/local/epics/extensions/bin/solaris-sparc $path)

## Packaged Unix Scripts for IDL Visualization Tools

**scanSee – ****MDA viewer with  real-time scanning**
**sscan – ****post scan viewer for MDA files**
**catcher – ****real-time scanning with data saving**
**viewer – ****post scan viewer for data catcher**** **
**hdfb – ****data browser for HDF4/Nexus files**
**h5b – ****data browser for HDF5/Nexus files**
**img – ****Tiff/Jpeg/Png/Ascii/Xdr image processor**
**idlvm – ****run IDLVM 6.0 with any IDL 6.0 saved programs**

## IDLVM 6.0

**No license required for IDL 6.0 saved program**
**Document:  **_**[http://www.aps.anl.gov/~cha/idlvm60.html](http://www.aps.anl.gov/~cha/idlvm60.html)**_
**IDL 6.0 *.sav files: **
*catcher.sav – for catcher*
*viewer.sav – for viewer without CA*
*sscan.sav – for scanSee R3.4 and later*
*SB2.sav – for MDA reader without CA*
*hdfb.sav – for HDF version 4*
*h5b.sav – for HDF version 5*
*Img.sav – image processor*
**Unix script methods:**
***idlvm  <pname>***
-     where  <pname> can be any of the above name without ‘.sav’
**Itools & data calibration not available in IDLVM 6.0**

## Unix Access Methods

**IDLVM version ****(recommend unless calibration is desired)**
*idlvm sscan**	** **	**(scanSee.R3.4 and later)*
*idlvm catcher**	**	*
**Runtime version **
*scanSee **	**	**	*
*catcher **	**	**	*
**Developer Version ****(ITOOLS available)**
*scanSee –D**	**	*
*catcher –D**	**	*

## scanSee Flow Diagram

- IOC (save scan MDA)

- Updating CA
- Real-time Data

- Visualization
- Display/Analysis
- Sub-Programs

- scanSee/Setup

- Scan

- F

- Updating
- Pan Images

- T

- T

- 1D

- F

- Save Scan
- MDA Files

- MEDM

- Read MDA

- F

- T

- Get CA Arrays

## Files Used by scanSee

**MDA scan files automatically saved by IOC**
**Restart Configuration file: ****DC.config**
**Saved output files:**
- ASCII/*.txt  - 1D/2D data files
- TIFF/*.tiff   - TIFF image files
- PNG/*.png  - PNG image files
- PICT/*.pict - MAC image files
- ROI/*.roi, *.rpt - various ROI files
- idl.ps,plot2d.ps ... -  saved various PS plot, report files

## Features Access Restriction

**ITOOLS **
- Developer version only
- License free ITOOLS
*‘**readascii.sav’ (IDLVM 6.1)*
-    			Idlvm readascii
**1D/2D Calibration features**
- Developer and Runtime versions

## Invocation Problem

**Problem of startup scanSee**
*Due to MDA file not found in configuration file*
*Wrong type or bad file picked*
**Resolve Invocation Problem**
*Method 1*
- Use File->Open to pick a new file
*Method 2*
- Remove the ‘DC.config’ before run **scanSee**

## General Widget Interfaces

**Click LMB - ****selection of menu/button/cursor/slider/list **
**Text field  - ****text entry must be ended with CR**
**Button...  - ****a pop up window/subprogram associated with it**
**Multiple list selection**
*Cntl+LMB – add/delete item to selection list*
*Shift+LMB – select all items between current and last click*
**ROI Mouse buttons**
*LMB – pick/drag ROI*
*MMB – resize ROI*
*RMB – accept ROI*

## Open...

- Printer...
- Exit

- Acquisition->
- Realtime->
- TexWin->
- Debug->
- Scan...
- Color...

- Colors->
- Lines->
- Symbols->
- Grid->
- Err Bars->
- Yscale->
- Ranges...
- Labels...

- 1D/2D...
- IMAGE2D...
- 1D Overlay...
- 1D Calibra...
- 1D/2D/3D/4D sscan...

- Plot
- Report...

- Zoom in Box
- Zoom Pan
- Zoom In/Out
- Calc Slopes
- Zoom Off(AutoScale)
- User Scale...

- None
- Peak/Centroid/FWHM on plot
- PeakCentroid/FWHM...
- FWHM on Y
- FWHM on DY/DX
- Average/Deviation...

- Ez_fit...
- Binary

- Version...
- Release Note...
- Help...

- CA
- MDA

- 85/70
- Detectors

## ScanSee Features

**Use file DC.config for easy restart**
**Flexible MDA file selection dialog**
**User settable monitor of 1D/2D scan record**
**Display near real-time 1D and 2D scanning data**
**Flexible 1D display in detectors, line texture, plot ranges and labels, zoom, FWHM, easy fitting, etc**
**Image data analysis, ROI statistics, calibrations**
**Easy access 1D/2D/3D post scan data and pass to appropriate  subprograms**
**Easy ASCII/TIFF/PNG/PICT/ROI/PS output**

## ViewData->1D/2D...

## ViewData->

- Save Private Color Table
- Load Private Color Table
- Image Color Scaheme...
- Change Color Table...
- Color Bar Config...

- TV
- Eq TV AspRt
- LIGHT_SHADE_SURF
- CONTOUR
- SHOW3
- PLOT2D...
- SHADE_SURF

- Save Image for AIM
- Save as PNG
- Save as TIFF
- Save as XDR
- Printer...
- Print
- PS_close
- Quit

- IMAGE2D...

## PanImage_sel Features

***PanImage_sel Features***

**Panimage Select sub-list: D01-D10,D11-D20,...**
**Multiple detectors selection list, default All**
**Grid factor, default 1 (60x60)**
**Show/Hide detector names**
**Detectors per row, default 10**
**Accept, All, Color table dialog**
**Easy TIFF, PNG, PICT, ASCII panimage generation**

## PanImage_sel Output

## 2D Calibration_factor Features

**Calibration_factor table freely modifiable**
**File menu allows save/load factor file**
**User settable # of terms, math operations, detectors, resultant calibration function displayed**
**Accept & ReCalc, ASCII, ROI2D, Pick1D sub-programs**

## 2D Calibra Result

***Plot2d Features***

**Support TV, Surface, Contour, Shade_Surface**
**Access of ROI, Pick1D, ASCII data sub-programs**
**TV image mouse query and sub-region query**
**Dialog for various plot area configurations**
**Dialog for various TV manipulation features: sharp, smooth, hist_equal, **

## Plot2d_TV Options	

**TV-log, TV, TVSCL**
**Image query mode**
**Hist_Equl**
**Max/min filter  value**
**Smooth/Unsharp Mask**
**Roberts/Sobel Sharpping**
**Threshold **

## Scan2d_roi

***ROI Features***

**Rect/Filter/Polygon/Multi mode of ROI**
**Various controls of different ROI mode**
**Mouse query / modify ROI**
**Display statistic summary results**
**User Settable ROI define and report filename **
**Dialogs save, display, manage ROI reports**

## MultiROI_pick subprogram

## Multi_ROI Features

**Flexible Add/delete/modify ROIs**
**Free hand drawing of polygon ROIs**
**Display one/all statistic of ROIs**
**Save/load multi ROIs to/from a file**
**Manipulate/generate multi ROIs statistic report**
**Save ROIs as a TIFF/PNG/PICT file**
**Image query**

## ViewData->SSCAN (1D/2D/3D/4D)...

**More efficient than scanSee (without CA)**
**Use restart scanSee.config or MDA file selection dialog or file field**
**Extract 1D/2D/3D/4D data arrays to call plot1d, image2d, view3d_2d, view4d sub-programs**
**Query scan Info, scan header structure info**
**Report->Report... generation**
**First,Next,Prev,Last easy MDA file access**

## View3d_2d Slicer

**Plot2d/Ascii2d/ROI2d/Pick1d subprogram selection**
**Flexible axial rank selection for 2D slicer**
**Flexible 2D image animator or preview slider**
**2D image slice # selection**
**View3d_2d Sum ROI subprogram**

***Features***

## Slider controls for I,J, axial range K1,K2
Spectrum plot at I,J with K1,K2 marked as blue lines
Option of PLOT1D, PLOT1D_ALL_I, PLOT1D_ALL_J specturm
Image of sum of 2D values bound by K1,K2
Plot of cross image line values at I,J
Option of Plot2d/Ascii2d/Roi2d/Pick1d/Data/PS plot

**Slider controls for I,J, axial range K1,K2**
**Spectrum plot at I,J with K1,K2 marked as blue lines**
**Option of PLOT1D, PLOT1D_ALL_I, PLOT1D_ALL_J specturm**
**Image of sum of 2D values bound by K1,K2**
**Plot of cross image line values at I,J**
**Option of Plot2d/Ascii2d/Roi2d/Pick1d/Data/PS plot**

## Pick1D Features

***Pick1D Features***

**Table display of 2D image value with format control**
**Column/Row selection pops up plot1d grogram**
**Plot all columns/rows with plot1d subprogram**
**Access ez_fit subprogram with image array**

- Calibra_pick1d
- Dialog

## Plot All I-spectrum

**Plot region resize with window size**
**Export ASCII, TIFF, PNG, PICT, PS file generation**
**Access of IPLOT of IDL 6.0  Itools (developer version)**
**Multiple lines plot program support scattering data**
**Options... Dialog for various line plot configurations, legend, statistic, fitting, FWHM,etc**

***  ******Plot1d Features***

## EZ_FIT Dialog

- Open 1D...
- Open 2D...
- Open ASCII...
- Printer...
- Quit

- Vector X
- Vector Y
- Vector Zy
- Vector Zx
- 2DImage

- COMFIT->
- CURVEFIT
- ERRORFIT
- GAUSSFIT
- LADFIT
- LINFIT
- POLYFITW
- PLOYFIT
- LORENTZIAN
- SVDFIT

- REGRESS
- LORENTIAN

- COMFIT
- CURVEFIT
- ERRORFIT
- GAUSSFIT
- LADFIT
- LINFIT
- POLYFITW
- PLOYFIT
- LORENTZIAN
- SVDFIT

## Options...->FITTING...

- 	Muti Fit->LORENTZIAN

- Click First Peak
- Click Add Btn
- Click Next Peak
- Click Show ROIs
- Click Calc Fits...

## Calc Fits...

## idlvm readascii

## Use Sharable Programs

**IDL Developer License Required **
**Common Visualization Tools Sharable by Any Other IDL Program**
*Plot1d, plot2d, image2d,view3d_2d, panimage,...** *
**IDL Startup Setup**** **
- setenv IDL_STARTUP /usr/local/epics/extensions/idllib/viewer_startup.pro
**Example**
**idl **
- IDL> loadct, 39
- IDL> da = dist(100)
- IDL> plot2d,da
- IDL> plot1d,da

## Scan Object Files

**Scan Object files with methods:**
- sscan__define.pro   (access MDA data)
- scan2d__define.pro (access catcher 2D image file)
- scan1d__define.pro (access catcher 1D file)
**Object Access Setup :**
- setenv IDL_STARTUP /usr/local/epics/extensions/idllib/viewer_startup.pro

## Sscan Object Examples

**Referring**
- _[http://www.aps.anl.gov/~cha/idl_html/sscan_ObjectRef.html](http://www.aps.anl.gov/~cha/idl_html/sscan_ObjectRef.html)_
**Examples:**
**idl**
- IDL> file=‘/home/beams/CHA/Yorick/data/2ixm_0020.mda’
- IDL> V = obj_new(‘**sscan**’,file=file)
- IDL> V->image2d		; use object method
- IDL> V->view3d_2d		; use object method
- IDL> V->read,da1d=da1d,da2d=da2d,da3d=da3d,...
- IDL> view3d_2d,da3d	; call sharable program
- IDL> image2d,da2d		; call sharable program

## Catcher: Scan1d Object Examples

**Referring:**
- _[http://www.aps.anl.gov/~cha/idl_html/scan1d_ObjectRef.html](http://www.aps.anl.gov/~cha/idl_html/scan1d_ObjectRef.html)_
**Examples:**
**idl**
- IDL> file=‘/home/beams/CHA/Yorick/data/junk2’)
- IDL> .run scan1d__define
- IDL> V = obj_new(‘**scan1d**’,file=file)
- IDL> V->read,10,pa=pa,da=da,/plot	; read scan #10 in pa and 					;   da  array also plot da
- IDL> V->plot,10,iy=‘4,5’		; read  scan # 10 and plot 					;   detector 4 & 5 only
- IDL> plot1d,da			; call sharable program

## Catcher: Scan2d Object Examples

**Referring:**
- _[http://www.aps.anl.gov/~cha/idl_html/scan2d_ObjectRef.html](http://www.aps.anl.gov/~cha/idl_html/scan2d_ObjectRef.html)_
**Examples:**
**idl**
- IDL> file=‘/home/beams/CHA/Yorick/data/junk2.image’)
- IDL> V = obj_new(‘**scan2d**’,file=file)
- IDL> V->print		; summary of image file
- IDL> v->panimage,2	; access the 2nd scan
- IDL> v->images,2,im,def	; extract all images in 2nd scan
- IDL> image2d,im,id_def=def	; use image2d to view 2nd scan 					;  images

## HDF4: NX Object Examples

**Referring:**
- _[http://www.aps.anl.gov/~cha/idl_html/NX_ObjectRef.html](http://www.aps.anl.gov/~cha/idl_html/NX_ObjectRef.html)_
**Examples:**
**idl**
- IDL> file=‘/home/beams/CHA/Yorick/data/2xfm_0020.nexus’)
- IDL> .run NX__define
- IDL> v = obj_new(‘**NX**’,file=file)
- IDL> v->print		;  dialog show file info, find num SDS
- IDL> for i=0,309 do begin v->sds,i,da,name=na & help,da,out=t & print,na,i,t & end			;  get all SDS data name and array info
- IDL> retall
- IDL> v->sds,131,da,name=na	; read the 131th  set of SDS
- IDL> view3d_2d,da		; pass 3D array to view3d_2d program
- IDL> v->sds,96,da,name=na	; read the 96th  set of SDS
- IDL> plot2d,da			; pass 2D array to plot2d program
- IDL> hdfb			; call hdfb  program

## Access ezcaIDL functions

**Reference Documents:**
- _[http://www.aps.anl.gov/~cha/catcher/ezcaIDLRef.html](http://www.aps.anl.gov/~cha/catcher/ezcaIDLRef.html)_
**Unix Setup Requirement:**
*source /usr/local/epics/extensions/bin/solsris-sparc/ezcaidl_setup*
- ( LD_LIBRARY_PATH, EZCA_IDL_SHARE, IDL_STARTUP)
**Examples:**
**Idl -32**
- IDL> r = caGetArray(‘cha:scan1.D1DA’,data,max=11)
- 							; get 11 data points
- IDL> plot1D,data				; plot data array
- IDL> x = [‘chademoai1’,’chademoai2’]		; set x to two PVs
- IDL> r = caGetArray(x, y)  & print,y		; get &print values
- IDL> newy = y+1. & r = caPutArray(x, newy)	; add & put values

## Where to Get More Information

_**[http://www.aps.anl.gov/aod/bcda/dataVis/index.php](http://www.aps.anl.gov/aod/bcda/dataVis/index.php)**_