Versions Compared

Key

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

...

Code Block
languagepy
from psana import DataSource
import os
import numpy as np
os.environ['PS_SMD_N_EVENTS'] = '50'
os.environ['PS_SRV_NODES']='1'

ds = DataSource(exp='rixx1003721', run=161, intg_det='epixhr')
smd = ds.smalldata(filename='phil.h5')
myrun = next(ds.runs())
epix = myrun.Detector('epixhr')
nevt=0
step_avgs = {}
for nstep,step in enumerate(myrun.steps()):
    print('step',nstep)
    localsum = None
    nsum = 0
    for nevt,evt in enumerate(step.events()):
        # convert from uint16 ifto localsumuint32 isso None:
    we don't overflow the sum
        localsumraw = epix.raw.raw(evt).astype(np.uint32)
        if raw is not None:
            nsum+=1
            if localsum is elseNone:
            # convert from uint16 to uint32 so we don't overflow the sum
    localsum = raw
            else:
                localsum += epix.raw.raw(evt).astype(np.uint32)
    step_sum = smd.sum(localsum)
    step_countnsum = smd.sum(nevt+1) # plus 1 since python counts from 0nsum)
    # check if we are the one mpi rank that sees the sums
    if step_sum is not None:
        step_avgs[str(nstep)] = step_sum/step_countnsum
if smd.summary:
    smd.save_summary(step_avgs)
smd.done()

Accessing Detector Calibration Constants

Code Block
languagepy
from psana import DataSource
ds = DataSource(exp='uedcom103',run=796)
myrun = next(ds.runs())
epix = myrun.Detector('epixquad')
print(epix.calibconst)