You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Simple 9-line script

from psana import *
ds = DataSource('exp=xppdaq12:run=54:smd')
det = Detector('cspad',ds.env())
for nevent,evt in enumerate(ds.events()):
    # includes pedestal subtraction, common-mode correction
    # bad-pixel suppression, and geometry
    img = det.image(evt)
    break
import matplotlib.pyplot as plt
plt.imshow(img,vmin=-2,vmax=2)
plt.show()

 

Script with advanced graphics

Similar script with elaborated matplotlib graphics working in style of event browser

from psana import *
ds = DataSource('exp=xppdaq12:run=54:smd')
det = Detector('cspad',ds.env())

##-----------------------------
# initialize graphics initialization
import matplotlib.pyplot as plt
fig  = plt.figure(figsize=(13,12), dpi=80, facecolor='w', edgecolor='w', frameon=True)
axim = fig.add_axes((0.05,  0.03, 0.87, 0.93))
axcb = fig.add_axes((0.923, 0.03, 0.02, 0.93))
plt.ion() # do not hold control on show() in the event loop
##-----------------------------

for nevent,evt in enumerate(ds.events()):
    if nevent>10 : break

    img = det.image(evt)

    ##-----------------------------
    # graphics
    ave, rms = img.mean(), img.std()
    amin, amax = ave-1*rms,ave+2*rms
    axim.cla() 
    imsh = axim.imshow(img, interpolation='nearest', aspect='auto', origin='upper') # extent=img_range)
    imsh.set_clim(amin, amax)
    colb = fig.colorbar(imsh, cax=axcb) # , orientation='horizontal')
    fig.canvas.set_window_title('Event %d' % nevent)
    fig.canvas.draw() 
    plt.show()

plt.ioff() # hold control on show() at the end
plt.show()
##-----------------------------

  • No labels