Averaging Over Scan Steps With An Integrating Detector
Run with "mpirun -n 5 python myscript.py"
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()): localsum = None for nevt,evt in enumerate(step.events()): if localsum is None: localsum = epix.raw.raw(evt) else: # convert from uint16 to uint32 so we don't overflow the sum localsum += epix.raw.raw(evt).astype(np.uint32) step_sum = smd.sum(localsum) step_count = smd.sum(nevt+1) # plus 1 since python counts from 0 # 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_count if smd.summary: smd.save_summary(step_avgs) # this method accepts either a dictionary or kwargs smd.done()
Overview
Content Tools