Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Now you have a local version of the XtcExplorer package in your directory. That allows you to edit the
source code and customize the analysis modules in the XtcExplorer/src directory.

  • hit 'Scan File(s)' again
  • Checkmark the IPM3 checkbox ('XppSb3Ipm=1|Ipimb-0')
  • hit the 'Write configuration to file' button,
  • hit the 'Run pyana' button
  • hit 'OK' and wait till a plot pops up... Close the window and wait again...
  • hit the 'Quit pyana' button
  • go to the 'General Settings' tab and switch Display mode to 'SlideShow'
  • go back to 'General Settings'
    • again and change the number of events to accumulate to 240
    • hit the 'Write configuration to file'
    and '
    • hit the 'Edit configuration file' button. Edit the line with 'quantities = ': remove 'fex:channels' and add 'fex:ch1' and 'fex:ch0' instead
    • hit 'Run pyana'
    buttons
    • button again (as well as 'OK' when that pops up). Stare at the plot for a while...
Panel
titleTry:
Code Block
none
none
xtcexplorer /reg/d/psdm/xpp/xppi0310/xtc/e81-r0098-s0*
  • Then hit the "Scan File(s)" button (can you find it?!?)
    • What do you see? Compare the GUI that pops up, with the output in the terminal window.
Panel
titleTry something else:
  • Checkmark the IPM3 checkbox ('XppSb3Ipm=1|Ipimb-0')
    • hit the 'Write configuration to file' button,
    • hit the 'Run pyana' button
    • hit 'OK' and wait till a plot pops up... Close the window and wait again...
    • hit the 'Quit pyana' button
    • go to the 'General Settings' tab and switch Display mode to 'SlideShow'
    • go back to 'General Settings'
Code Block
nonenone

addpkg XtcExplorer
scons
xtcexplorer /reg/d/psdm/xpp/xppi0310/xtc/e81-r0098-s0*

The xtcexplorer has several shortcomings. It tries to be very generic, and thus is sometimes slower than it would have to be. It is also currently only capable of plotting from a single device in each plot, so many correlation plots will need to be added by hand. However, it is a simple tool to just look at the data contents, and provides many examples through its pyana modules.

For some more useful analysis examples, in the following we'll stick to writing customized pyana modules and running pyana from the command line.

Extracting the data with pyana, some examples

Outline of a pyana module

Like the other frameworks, pyana is an executable that loops through the XTC file and calls all
requested user modules at certain transitions. All the analysts need to do is to fill in the
relevant functions in their user analysis module:

Toggle Cloak
idkappe
code

...

idkappe
Panel
titleTry something else:
Code Block
none
none

addpkg XtcExplorer
scons
xtcexplorer /reg/d/psdm/xpp/xppi0310/xtc/e81-r0098-s0*

Now you have a local version of the XtcExplorer package in your directory. That allows you to edit the
source code and customize the analysis modules in the XtcExplorer/src directory.

Exercise:
Edit XtcExplorer/src/pyana_ipimb.py to make a loglog plot of channel1 vs channel0.

The xtcexplorer has several shortcomings. It tries to be very generic, and thus is sometimes slower than it would have to be. It is also currently only capable of plotting from a single device in each plot, so many correlation plots will need to be added by hand. However, it is a simple tool to just look at the data contents, and provides many examples through its pyana modules.

For some more useful analysis examples, in the following we'll stick to writing customized pyana modules and running pyana from the command line.

Extracting the data with pyana, some examples

Outline of a pyana module

Like the other frameworks, pyana is an executable that loops through the XTC file and calls all
requested user modules at certain transitions. All the analysts need to do is to fill in the
relevant functions in their user analysis module:

Toggle Cloak
idkappe
code

Cloak
idkappe

Point detector delay scan

  • Fetching the ControlPV information:
    ControlPV is available from the env object, and since it only changes at the beginning
    of each calibration cycle, the begincalibcycle function is the appropriate place to get it:
    Code Block
    none
    none
    
        def begincalibcycle( self, evt, env ) :
    

    The ControlConfig object may contain several pvControl and pvMonitor objects. In this case
    there's only one, but make sure the name matches anyway:
    Code Block
    none
    none
    
            ctrl_config = env.getConfig(TypeId.Type.Id_ControlConfig)
    
            for ic in range (0, ctrl_config.npvControls() ):
                cpv = ctrl_config.pvControl(ic)
                if cpv.name()=="fs2:ramp_angsft_target":
    
                    # store the value in a class variable (visible in every class method)
                    self.current_pv_value = cpv.value() )
    
  • Fetching the IPIMB and PhaseCavity information:
    All the other information that we need, is available through the evt object, and
    event member function is the place to get it:
    Code Block
    none
    none
    
        def event( self, evt, env ) :
    

    Use "XppSb3Ipm-1|Ipimb-0" (a.k.a. IPM3) sum of all channels for normalization and filtering
    Code Block
    none
    none
    
            ipmN_raw = evt.get(TypeId.Type.Id_IpimbData, "XppSb3Ipm-1|Ipimb-0")
            ipmN_fex = evt.get(TypeId.Type.Id_IpmFex, "XppSb3Ipm-1|Ipimb-0")
    
            ipmN_norm = ipmN_fex.sum
    

    Use "XppSb3Pim-1|Ipimb-0" (a.k.a. PIM3) channel 1 as signal

Point detector delay scan

  • Fetching the ControlPV information:
    ControlPV is available from the env object, and since it only changes at the beginning
    of each calibration cycle, the begincalibcycle function is the appropriate place to get it:
    Code Blocknonenone
    
        def begincalibcycle( self, evt, env ) :
    
    The ControlConfig object may contain several pvControl and pvMonitor objects. In this case
    there's only one, but make sure the name matches anyway:
    Code Block
    none
    none
            ctrlipmS_configraw = envevt.getConfigget(TypeId.Type.Id_ControlConfig)
    IpimbData, "XppSb3Pim-1|Ipimb-0" )
            for ic in range (0, ctrl_config.npvControls() ):ipmS_fex = evt.get(TypeId.Type.Id_IpmFex, "XppSb3Pim-1|Ipimb-0" )
    
                cpv ipm_sig = ctrlipmS_fex.channel[1]
    

    Get the phase cavity:
    Code Block
    none
    none
    config.pvControl(ic)
            pc =   if cpv.name()=="fs2:ramp_angsft_target":
    
    evt.getPhaseCavity()
            phasecav1 = pc.fFitTime1
          # store thephasecav2 value in a class variable (visible in every class method)
    = pc.fFitTime2
            charge1 = pc.fCharge1
            self.current_pv_valuecharge2 = cpv.value() )
    
    Fetching the IPIMB and PhaseCavity information:
    All the other information that we need, is available through the evt object, and
    event member function is the place to get it:
    pc.fCharge2
    

    Compute delay time and fill histograms
    Code Block
    none
    none
        def event( self, evt, envdelaytime ) :
    
    Use "XppSb3Ipm-1|Ipimb-0" (a.k.a. IPM3) sum of all channels for normalization and filtering
    Code Block
    nonenone
    
    = self.current_pv_value + phasecav1*1e3    
    
            # The  ipmN_raw = evt.get(TypeId.Type.Id_IpimbData, "XppSb3Ipm-1|Ipimb-0")
            ipmN_fex = evt.get(TypeId.Type.Id_IpmFex, "XppSb3Ipm-1|Ipimb-0")
    
            ipmN_norm = ipmN_fex.sum
    
    Use "XppSb3Pim-1|Ipimb-0" (a.k.a. PIM3) channel 1 as signal
    Code Block
    nonenone
    "histograms" are nothing but python lists. Append to them, and turn them into arrays at the end. 
            self.h_ipm_rsig.append( ipm_sig )
            ipmS_raw = evt.get(TypeId.Type.Id_IpimbData, "XppSb3Pim-1|Ipimb-0"self.h_ipm_nsig.append( ipm_sig/ipm_norm )
            ipmS_fex = evt.get(TypeId.Type.Id_IpmFex, "XppSb3Pim-1|Ipimb-0" )
    
            ipm_sig = ipmS_fex.channel[1]
    
    Get the phase cavity:
    Code Blocknonenone
    
            pc = evt.getPhaseCavity()
            phasecav1 = pc.fFitTime1
            phasecav2 = pc.fFitTime2
            charge1 = pc.fCharge1
            charge2 = pc.fCharge2
    
    Compute delay time and fill histograms
    Code Blocknonenone
    self.h_delaytime.append( delaytime )
    

Image peak finding

CSPad images and tile arangements

Saving data arrays

Interactive analysis with IPython

The version available in our offline release system is
IPython 0.9.1 – An enhanced Interactive Python.
so this is the one I've been using in these examples.
Not a whole lot more than a python shell.

However, the latest IPython has loads of new and interesting features...

http://ipython.org/Image Added

Panel
titleLoading your arrays into (I)Python and plotting interactively:
Code Block

[ofte@psana0106 xpptutorial]$ ipython
Python 2.4.3 (#1, Nov  3 2010, 12:52:40)
Type "copyright", "credits" or "license" for more information.

IPython 0.9.1 -- An enhanced Interactive Python.
?        

...

 -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's 

...

own 

...

Image peak finding

CSPad images and tile arangements

Saving data arrays

Interactive analysis with IPython

The version available in our offline release system is
IPython 0.9.1 – An enhanced Interactive Python.
so this is the one I've been using in these examples.
Not a whole lot more than a python shell.

However, the latest IPython has loads of new and interesting features...

...

help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from numpy import *

In [2]: from matplotlib.pyplot import *

In [3]: ipm3 = load('point_scan_delay.npy')

In [4]: ipm3.shape
Out[4]: (200, 3)

In [5]: ion()

In [6]: delay = ipm3[:,0]

In [7]: ipmraw = ipm3[:,1]

In [8]: ipmnorm = ipm3[:,2]

n [9]: plot(delay,ipmnorm,'ro')
Out[9]: [<matplotlib.lines.Line2D object at 0x59c4c10>]

In [10]: draw()

In [11]:

Plotting with MatPlotLib

  • The plotting can be done directly in the pyana module, but be aware that you need to disable plotting for the
    module to run successfully in a batch job.
    Code Block
    import matplotlib.pyplot as plt 
    
    plt.plot(array)
    plt.show()
    

...

Code Block
import matplotlib.pyplot as plt

plt.ion()
plt.plot(array)
plt.draw()

Non-interactive batch analysis