Page History
...
See Module CSPadPixCoords::CSPad2x2NDArrProducer
Example for module CSPadPixCoords::CSPad2x2NDArrReshape
Example of configuration file
Code Block |
---|
[psana]
#files = exp=meca1113:run=376
#events = 10
##skip-events = 0
modules = cspad_mod.CsPadCalib \
CSPadPixCoords.CSPad2x2NDArrProducer:clb \
CSPadPixCoords.CSPad2x2NDArrProducer:raw \
CSPadPixCoords.CSPad2x2NDArrReshape \
ImgAlgos.NDArrAverage:clb \
ImgAlgos.NDArrAverage:raw
# EventKeys
[cspad_mod.CsPadCalib]
inputKey =
outputKey = clb_data
doPedestals = yes
doPixelStatus = yes
doCommonMode = yes
[CSPadPixCoords.CSPad2x2NDArrProducer:clb]
source = MecTargetChamber.0:Cspad2x2.1
inkey = clb_data
outkey = cspad2x2.1_clb:as_data
outtype = int16
print_bits = 5
[CSPadPixCoords.CSPad2x2NDArrProducer:raw]
source = MecTargetChamber.0:Cspad2x2.1
inkey =
outkey = cspad2x2.1_raw:as_data
outtype = int16
print_bits = 5
[CSPadPixCoords.CSPad2x2NDArrReshape]
source = MecTargetChamber.0:Cspad2x2.1
keys_in = cspad2x2.1_raw:as_data cspad2x2.1_clb:as_data
print_bits = 255
[ImgAlgos.NDArrAverage:clb]
source = MecTargetChamber.0:Cspad2x2.1
key = cspad2x2.1_clb
avefile = arr-ave-clb
rmsfile = arr-rms-clb
print_bits = 255
[ImgAlgos.NDArrAverage:raw]
source = MecTargetChamber.0:Cspad2x2.1
key = cspad2x2.1_raw
avefile = arr-ave-raw
rmsfile = arr-rms-raw
print_bits = 255 |
This script produces raw and calibrated ndarrays shaped as data (185,388,2), then pass these arrays as
keys_in = cspad2x2.1_raw:as_data cspad2x2.1_clb:as_data
to the CSPadPixCoords.CSPad2x2NDArrReshape module, which produces two reshaped (2,185,388) arrays and saves them in the event store with default keys
cspad2x2.1_raw, cspad2x2.1_clb
(suffixes are dropped)
then both re-shaped arrays are averaged and saved in files on disk.
Example of associated python script:
Code Block |
---|
#!/usr/bin/env python
import sys
import numpy as np
import matplotlib.pyplot as plt
import psana
psana.setConfigFile('psana-meca1113-r0376-cspad2x2-CSPad2x2NDArrReshape.cfg')
dsname = 'exp=meca1113:run=376'
print "Data source: %s" % dsname
ds = psana.DataSource(dsname)
#------------------------------
print "Initializing Matplotlib Plotter"
fig = plt.figure(figsize=(10,5), dpi=80, facecolor='w', edgecolor='w', frameon=True)
plt.ion()
plt.show()
evnum = 0
evnum_max = 50
for evt in ds.events() :
evtid = evt.get(psana.EventId)
evnum += 1
if evnum > evnum_max : break
img_as_data = evt.get(psana.ndarray_int16_3, psana.Source('DetInfo(MecTargetChamber.0:Cspad2x2.1)'), 'cspad2x2.1_clb:as_data')
img_reshpd = evt.get(psana.ndarray_int16_3, psana.Source('DetInfo(MecTargetChamber.0:Cspad2x2.1)'), 'cspad2x2.1_clb')
print 'img_as_data.shape = ', img_as_data.shape
print 'img_reshpd.shape = ', img_reshpd.shape
img_as_data.shape = (2*185,388)
img_reshpd.shape = (2*185,388)
ax1 = fig.add_axes([0.05, 0.06, 0.44, 0.87])
ax2 = fig.add_axes([0.55, 0.06, 0.44, 0.87])
fig.canvas.set_window_title('Image from arrays "as-data" and "reshaped"')
imsh1 = ax1.imshow(img_as_data, interpolation='nearest', aspect='auto', origin='upper') # , extent=img_range)
imsh2 = ax2.imshow(img_reshpd, interpolation='nearest', aspect='auto', origin='upper') # , extent=img_range)
plt.title("Event: %d.%d" % evtid.time())
plt.draw()
plt.clf() |
This script retrieves from the event store calibrated ndarrays shaped as data (185,388,2) and re-shaped (2,185,388), then re-shape both to 2-d arrays (2*185,388) and plot them. Re-shaped array looks as recognizable (without spaces between ASICs) cspad2x2 image. Array shapes "as data" looks as an overlap of two images.
See Module CSPadPixCoords::CSPad2x2NDArrReshape
JIRA issue:
Jira | ||||
---|---|---|---|---|
|
Example for module CSPadPixCoords::CSPad2x2ImageProducer
See Module CSPadPixCoords::CSPad2x2ImageProducer
...