Page History
...
Code Block | ||
---|---|---|
| ||
import psana # note the "idx" input source at the end of this line: indicates that events will be accessed randomly. ds = psana.DataSource('exp=cxib7913XCS/xcstut13:run=3415:idx') for run in ds.runs(): # get array of timestamps of events times = run.times() for i in range(3,-1,-1): #request a particular timestamp in a run evt=run.event(times[i]) if evt is None: print '*** event fetch failed' continue id = evt.get(psana.EventId) print 'Fiducials:',id.fiducials() |
...
Code Block | ||
---|---|---|
| ||
import psana import numpy as np import sys from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() size = comm.Get_size() ds = psana.DataSource('exp=cxib7913:run=34:idx') src = psana.Source('DetInfo(CxiDg2.0:Tm6740.0)') for run in ds.runs(): times = run.times() mylength = len(times)/size mytimes= times[rank*mylength:(rank+1)*mylength] for i in range(mylength): evt = run.event(mytimes[i]) if evt is None: print '*** event fetch failed' continue pulnix = evt.get(psana.Camera.FrameV1,src) if pulnix is None: print '*** failed to get pulnix' continue if 'sum' in locals(): sum+=pulnix.data16() else: sum=pulnix.data16() id = evt.get(psana.EventId) print 'rank',rank,'analyzed event with fiducials',id.fiducials() print 'image:\n',pulnix.data16() sumall = np.empty_like(sum) #sum the images across mpi cores comm.Reduce(sum,sumall) if rank==0: print 'sum is:\n',sumall |
This can be run interactively parallelizing over 2 cores with a command similar to the followingthese commands:
Code Block |
---|
setenv PATH /reg/nehcommon/home1package/cpoopenmpi/junk/openmpi-1.8/install/bin/:${PATH} mpirun -n 2 python mpi.py |
or run in a batch job:
Code Block |
---|
setenv PATH /reg/common/package/openmpi/openmpi-1.8/install/bin/:${PATH}
bsub -a mympi -n 2 -o mpi.log -q psfehmpiq python mpi.py |
...
Overview
Content Tools