Versions Compared

Key

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

...

 common_mode - returns array of the common mode parameters

Compound Detector object creation

There are a few options of the detector object initialization usyng class AreaDetectorCompound directly or through the standard Detector factory.

Detector object

Detector is a standard wrapper for all LCLS detectors including AreaDetectorCompound. Compound detector object can be created usind generic Detector, e.g.

Code Block
import psana
# DataSource object MUST be defined before Detector.
ds = psana.DataSource(dsname) # i.e. dsname='exp=xpptut15:run=460'
det = psana.Detector(<str-or-list-of-derector-names>)

AreaDetectorCompound object

Example of direct AreaDetectorCompound object initialization:

Code Block
from Detector.AreaDetectorCompound import AreaDetectorCompound
det = AreaDetectorCompound(<str-or-list-of-derector-names>, env)

Input parameters

Parammeter <str-or-list-of-derector-names> can be the space separated string of detector names prepended by keyword 'compound', e.g.

Code Block
'compound MecTargetChamber.0:Cspad2x2.1 MecTargetChamber.0:Cspad2x2.2 MecTargetChamber.0:Cspad2x2.3'

or just a list of detector names, e.g.

Code Block
['MecTargetChamber.0:Cspad2x2.1', 'MecTargetChamber.0:Cspad2x2.2', 'MecTargetChamber.0:Cspad2x2.3']

Second parameter, env = ds.env(), is mandatory for AreaDetectorCompound and is optional for Detector (passed from  DataSource initialization).

Code example

Code Block
### Direct usage:
# from Detector.AreaDetectorCompound import AreaDetectorCompound
# det = AreaDetectorCompound(..., env)

import psana
from Detector.GlobalUtils import print_ndarr

ds = psana.DataSource('exp=xpptut15:run=460')

# Make Detector object using:
# space separated string of detector names prepended by 'compound':
det = psana.Detector('compound MecTargetChamber.0:Cspad2x2.1'\
                             ' MecTargetChamber.0:Cspad2x2.2'\
                             ' MecTargetChamber.0:Cspad2x2.3')

# or list of string detector names:
det = psana.Detector(['MecTargetChamber.0:Cspad2x2.1',\
                      'MecTargetChamber.0:Cspad2x2.2',\
                      'MecTargetChamber.0:Cspad2x2.3'])

env = ds.env()
evt = ds.events().next()
rnum = evt.run()

if True :
    print 'rnum     :', rnum
    print 'calibdir :', str(env.calibDir())
    print 'size     :', str(det.list_size(evt))
    print 'shapes   :', str(det.list_shape(evt))
    print 'ndims    :', str(det.list_ndim(evt))

    raws = det.list_raw(evt)
    for nda in raws : print_ndarr(nda, name='-- per det list_raw', first=0, last=5)

    raw = det.raw(evt)
    print_ndarr(raw, name='raw as nda', first=0, last=5)

    calib = det.calib(evt)
    print_ndarr(calib, name='calib', first=0, last=5)

    xy0_offset = (550,550)
    img_raw   = det.image(evt, nda_in=raw, xy0_off_pix=xy0_offset)
    #img_calib = det.image(evt, nda_in=calib, xy0_off_pix=xy0_offset)
    #img_at_z  = det.image_at_z(evt, zplane=500000, nda_in=raw, xy0_off_pix=xy0_offset)

    if True : # True or False for to plot image or not 
        from pyimgalgos.GlobalGraphics import plotImageLarge, show
        img = img_raw
        plotImageLarge(img, title='img as %s' % str(img.shape), amp_range=(0,5000))
        show()

...