Versions Compared

Key

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

...

Code Block
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
    # includes pedestal subtraction, common-mode correction
    # bad-pixel suppression, and geometry
    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()
##-----------------------------