Page History
...
For some more useful analysis examples, in the following we'll stick to writing customized pyana modules and running pyana from the command line.
But before getting to the pyana modules, I'll briefly touch on a few items general to python that may be useful: saving files, matplotlib for plotting, and IPython for interactive work.
NumPy, SciPy and MatPlotLib
These are packages that you may want to look into. Pretty much all our examples here are using them:
- http://numpy.scipy.org/
- Numerical package for python (arrays etc)
- http://www.scipy.org/
- Scientific tools
- http://matplotlib.sourceforge.net/
- plotting package
Other useful links:
- http://www.scipy.org/NumPy_for_Matlab_Users
- http://www.scipy.org/
- http://www.sagemath.org/
- http://code.google.com/p/spyderlib/
Saving data arrays
Here are a few examples of how you can save data arrays in python.
Panel | ||
---|---|---|
| ||
|
...
|
Panel | ||||
---|---|---|---|---|
| ||||
|
Panel | |||||||
---|---|---|---|---|---|---|---|
| |||||||
For more examples, see How to access HDF5 data from Python and http://code.google.com/p/h5py/ |
Plotting with MatPlotLib
One of the most commonly used tools for plotting in python: matplotlib. Other alternatives exist too.
...
- Or you can load arrays from a file and interactively plot them in iPython. The same ('recommended') syntax as above can be used, or if you use 'import *' you don't need to prepend the commands with the package name, which is handy when plotting interactively:
Code Block from matplotlib.pyplot import * ion() plot(array) draw()
Interactive analysis with IPython
The LCLS offline analysis group does have plans for a real interactive pyana, but currently this is not available.
2011-11-04 iPsana Interactive Analysis Framework.pdf
...
Panel | ||
---|---|---|
| ||
This example reads in a file produced by the "point detector delay scan" example below.
|
Links
...
Sometimes you need to issue the draw() command twice, for some reason. After drawing you can keep working on the arrays and plot more... |
Extracting the data with pyana, some examples
...
Cloak | ||
---|---|---|
| ||
|
Image peak finding
Here are a collection of useful algorithms for image analysis: http://docs.scipy.org/doc/scipy/reference/ndimage.html
...