Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
maxLevel3

...

XtcExplorer (GUI interface to pyana)

Note! This package is a new version of the "XtcEventBrowser" which is the old name of the package.

This is a description and documentation of a GUI tool to explore the xtc data. It is written in python, relying on PyQt4 for graphical user interface. The data processing is done via the pyana framework and visualization provided by matplotlib. It can be run on any xtc file, including the file being written during data aquisition (DAQ).

Xtc files contain the raw data (datagrams) streamed from the DAQ online system. The datagrams occur in the order they were flushed from the DAQ system, and thus do not necessarily appear in chronological order. The datagrams are not indexed, so the file must be read sequentially. The pyana and psana frameworks are designed to process these datagrams and present them to you shot by shot (or event by event, in pyana/psana terminology).

The XtcExplorer , therefore they are not indexed and the events don't always line up in the "right" order. Therefore it's not straight-forward to browse (back and fourth) through an xtc file. This tool (XtcEventBrowser) is also not a real browser, but allows a simple-to-run interface to the xtc files. The package name is XtcEventBrowserXtcExplorer, the executables (xtcbrowser xtcexplorer and xtcscanner) are found in the app subdirectory of this package, and all other code is in the src subdirectory.

xtcbrowser

The xtcbrowser is the command to launch the Event Display for xtc files. The package name is XtcEventBrowser. It is written in python, relying on PyQt4 for graphical user interface. The data processing is done via the pyana framework and visualization provided by matplotlib.

Note! This tool is under development... features are being added and new versions available often. This documentation might be slightly outdated, but if you use the tagged version (VXX-XX-XX) mentioned here it should work as advertised.

How to get started

source code is in the src subdirectory.

How to get started

You should always run this code from your own release working directory. It might work from other directories, but be aware that configuration files will be written to your current directory. Look out for files with names xb_pyana_XXXX.cfg, where XXXX is a random four-digit number. You can use them to run pyana directly from the command line. But they accumulate, so you might want to remove these regularly...

This tool is not in a release yet, so to run, you need to set up an offline release in your directory (See the Account Setup section to set up the analysis environment). Do the setup . Set up your release from pslogin:

Code Block
[user@pslogin ~] newrel ana-current myrelease
[user@pslogin ~] cd myrelease
[user@pslogin myrelease] sit_setup

Optional: Add the xtc browser XtcExplorer package to your analysis release and "compile":

Code Block
[user@pslogin myrelease] addpkg XtcEventBrowserXtcExplorer V00-0001-18
[user@pslogin myrelease] scons
01
[user@pslogin myrelease] scons

Note! If you don't check out this local copy, you will run whichever version is in the release. You will not be able to edit any of the source files to tweak your analysis.
Note! You can omit the "tag" (VXX-XX-XX) to get the latest and greatest version in the svn repository, but this may look different from described here.

Run the program with the command 'xtcbrowserxtcexplorer' and optionally give the input xtc files that you want to read as arguments. You can also browse to find files after launching the browser.

...

Code Block
[user@psanaXXX myrelease] sit_setup
[user@psanaXXX myrelease] xtcbrowserxtcexplorer /reg/d/psdm/cxi/cxi80410/xtc/e55-r0581*

If you encounter any problems, ask for help! Don't be stuck. This is supposed to be easy. If it's not, I did something wrong, so let me know! (smile) Send me an email (ofte at slac.stanford.edu)

Description of the GUIs

LCLS Xtc

...

Explorer

xtcexplorer will launch the main GUI. It currently has two sections: xtcbrowser will launch a GUI, the main browser. It allows you to browse for files, and to run a scan to see what's in the file. (Perhaps "scan" is not a good choice of word... it parses the xtc file and investigate what kind of data is there.)

  • File section: Shows a list of currently selected file(s). As you may have guessed, "File Browser" opens a file browser and "Clear File List" clears the current list of files. This section also allows you to add a file name by hand (or paste).
  • Scan section: The two buttons to the left allows you to scan the xtc file to get a summary of what datagrams are stored in it. Note, for most purposes, a "Quick Scan" is sufficient. If you need to scan the whole file, e.g. if you want to know the total number of events, number of calibration cycles, etc, you can enable the "Scan File(s)" button. If the files are big, this will take a lot of time...

...

The GUI as described above prepares a configuration file for you to run pyana. You can either run it from the GUI or you can run it from the command line. The configfile sets input parameters for the pyana modules in this package. Feel free to use one or more of these modules as a starting point for your more elaborate pyana analysis!

Code Block
XtcEventBrowserXtcExplorer/src/pyana_bld.py          # display of Beam-line data
XtcEventBrowserXtcExplorer/src/pyana_cspad.py        # display of CsPad image data
XtcEventBrowserXtcExplorer/src/pyana_image.py        # display of camera image data
XtcEventBrowserXtcExplorer/src/pyana_ipimb.py        # display of diode data from IPIMB and PIM
XtcEventBrowserXtcExplorer/src/pyana_waveform.py     # display of waveform data (not fully functional yet)
XtcEventBrowser
XtcExplorer/src/pyana_epics.py        # display of Epics PV data (not fully functional yet)
XtcEventBrowser
XtcExplorer/src/pyana_scan.py         # display of motor scan data
XtcEventBrowserXtcExplorer/src/pyana_plotter.py      # a plotter module to control the event display

...

  • pyana_cspad: CsPad data is reconstructed in pyana_cspad.py. The image plot value limits are adjusted automatically, but if
    you want to change them, click on the color bar (left-click for low limit, right-click for high limit).
    The successive events will be plotted with the new limits. Revert to the original by middle-clicking.
    To run this module by itself with pyana:
    Code Block
    pyana -m XtcEventBrowserXtcExplorer/src/pyana_cspad.py <xtc files>
    
    Options must be specified in a configuration file, or the default values will be used, e.g.:
    Code Block
    image_source     # string, Address of Detector-Id|Device-ID
    dark_img_file    # filename, Dark image file to be loaded, if any
    output_file      # filename (If collecting: write to this file)
    plot_vrange      # range=vmin-vmax of values for plotting (pixel intensity)
    threshold        # lower threshold for image intensity in threshold area of the plot
    thr_area         # range=xmin,xmax,ymin,ymax defining threshold area
    

    Image display of the CSPad detector, background subtracted. This is currently the only display that has interactive features. A filter allows you to select events within requested intensity range.

...

MatLab

MatPlotLib

Comments

Loglog plot of one array vs. another

Code Block
%
%
%
a1 = subplot(121);
loglog(channels(:,1),channels(:,2),'o')
xlabel('CH0')
ylabel('CH1')
a2 = subplot(122);
loglog(channels(:,3),channels(:,4),'o')
xlabel('CH2')
ylabel('CH3')

Loglog plot of one array vs. another

Code Block
import matplotlib.pyplot as plt
import numpy as np

a1 = plt.subplot(221)
plt.loglog(channels[:,0],channels[:,1], 'o' )
plt.xlabel('CH0')
plt.ylabel('CH1')
a2 = plt.subplot(222)
plt.loglog(channels[:,2],channels[:,3], 'o' )
plt.xlabel('CH2')
plt.ylabel('CH3')

channels is a 4xN array of floats, where N is the number of events. Each column corresponds to one out of four Ipimb channels.

Note that the arrays are indexed with 1,2,3,4 in MatLab and 0,1,2,3 in MatPlotLib/NumPy/Python.

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f58c1f162ca06842-aea17aa3-48044112-88599768-b2ce8d2269af29554ceca7ec"><ac:plain-text-body><![CDATA[Note also the use of paranthesis, array() in MatLab, array[] in MatPlotLib.

]]></ac:plain-text-body></ac:structured-macro>

test

test

Test

array of limits from graphical input

array of limits from graphical input

 

Code Block
axes(a1)
hold on
lims(1:2,:) = ginput(2);

axes(a2)
hold on
lims(3:4,:) = ginput(2);
Code Block
lims = np.zeros((4,2),dtype="float")

plt.axes(a1)
plt.hold(True)
lims[0:2,:] = plt.ginput(2)

plt.axes(a2)
plt.hold(True)
lims[2:4,:] = plt.ginput(2)

In MatLab, lims is an expandable array that holds limits as set by input from mouse click on the plot (ginput).
NumPy arrays cannot be expanded, so I've declared a 4x2 array of zeros to start with, then fill it with ginput().

 

 

 

filter

filter

 

Code Block
fbool1 = (channels(:,1)>min(lims(1:2,1)))&(channels(:,1)<max(lims(1:2,1)))
fbool2 = (channels(:,2)>min(lims(1:2,2)))&(channels(:,2)<max(lims(1:2,2)));
fbool = fbool1&fbool2
loglog(channels(fbool,1),channels(fbool,2),'or')

fbool3 = (channels(:,3)>min(lims(3:4,3)))&(channels(:,3)<max(lims(3:4,3)))
fbool4 = (channels(:,4)>min(lims(3:4,4)))&(channels(:,4)<max(lims(3:4,4)));
fbool = fbool3&fbool4
loglog(channels(fbool,3),channels(fbool,4),'or') 
Code Block
fbools0 = (channels[:,0]>lims[:,0].min())&(channels[:,0]<lims[:,0].max())
fbools1 = (channels[:,1]>lims[:,1].min())&(channels[:,1]<lims[:,1].max())
fbools = fbools0 & fbools1

fbools2 = (channels[:,2]>lims[:,2].min())&(channels[:,2]<lims[:,2].max())
fbools3 = (channels[:,3]>lims[:,3].min())&(channels[:,3]<lims[:,3].max())
fbools = fbools2&fbools3

Comment