if phibins > 0: phibin_fct = np.ceil(nphi / float(phibins)) else: phibin_fct = 1 nphi = int(np.ceil(2 * np.pi * interp_rmax / phibin_fct) * phibin_fct) # number of azimuthal samples per bin rbin_new = (interp_rmax - interp_rmin) / rbin_fct phibin_new = nphi / phibin_fct binned_pol_img_sh = (int(rbin_new), int(phibin_new)) print("polar image dimensions: %d x %d" % (rbin_new, phibin_new)) Interp = InterpSimple(cent[0], cent[1], interp_rmax, interp_rmin, nphi, img_sh) pmask = Interp.nearest(mask).astype(int).astype(float) pmask_bn = bin_ndarray(pmask, binned_pol_img_sh) # print pmask.shape,pmask_bn.shape # if (rbin_fct==1 and phibin_fct==1): # print('not binning polar img') # sys.exit() #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~ data get parameters #load the data events for the given run ds_str = 'exp=cxilr6716:run=%d:smd' % run ds = psana.MPIDataSource(ds_str) events = ds.events() # open the detector obj
nphi = int( 2 * np.pi * interp_rmax ) if phibins>0: phibin_fct = np.ceil( nphi / float( phibins ) ) else: phibin_fct=1 nphi = int( np.ceil( 2 * np.pi * interp_rmax/phibin_fct)*phibin_fct) # number of azimuthal samples per bin rbin_new = (interp_rmax- interp_rmin ) / rbin_fct phibin_new = nphi / phibin_fct binned_pol_img_sh = ( int(rbin_new), int(phibin_new) ) print("polar image dimensions: %d x %d"%(rbin_new, phibin_new)) Interp = InterpSimple( cent[0], cent[1] , interp_rmax, interp_rmin, nphi, img_sh) pmask = Interp.nearest(mask).astype(int).astype(float) pmask_bn = bin_ndarray( pmask, binned_pol_img_sh) # print pmask.shape,pmask_bn.shape # if (rbin_fct==1 and phibin_fct==1): # print('not binning polar img') # sys.exit() #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~ data get parameters #load the data events for the given run ds_str = 'exp=cxilp6715:run=%d:smd' % run ds = psana.MPIDataSource(ds_str) events = ds.events()
# min ring radii # desired dimension of image, these will be approximate rbins =35 phibins = 360 interp_rmin = 100 interp_rmax = 450 rbin_fct = np.floor( (interp_rmax - interp_rmin) / rbins) # adjust so our edge is a multiple of rbin factor interp_rmax = int( interp_rmin + np.ceil( (interp_rmax - interp_rmin) / rbin_fct)*rbin_fct ) nphi = int( 2 * np.pi * interp_rmax ) phibin_fct = np.ceil( nphi / float( phibins ) ) nphi = int( np.ceil( 2 * np.pi * interp_rmax/phibin_fct)*phibin_fct) # number of azimuthal samples per bin rbin_new = (interp_rmax- interp_rmin ) / rbin_fct phibin_new = nphi / phibin_fct binned_pol_img_sh = ( int(rbin_new), int(phibin_new) ) print("polar image dimensions: %d x %d"%(rbin_new, phibin_new)) Interp = InterpSimple( cent[0], cent[1] , interp_rmax, interp_rmin, nphi, img_sh) pmask = Interp.nearest(mask).astype(int).astype(float) pmask_bn = bin_ndarray( pmask, binned_pol_img_sh) pmask_bn = pmask_bn.astype(int) pmask_bn = np.array(pmask_bn==pmask_bn.max(), dtype = int) #np.save('/reg/d/psdm/cxi/cxilp6715/scratch/water_data/binned_pmask_basic.npy', pmask_bn) np.save('/reg/d/psdm/cxi/cxilp6715/results/shared_files/binned_pmask_basic3.npy', pmask_bn)