Creating the Average Image

First, we need to create an image that shows the pattern of interest. The data we will use here (xpptut15, run 321)  is publicly available as described here

anaps_AvImage

snelson@psanaphi103:/reg/d/psdm/xpp/xppo5616/results/littleData$ ./runLittleDataAna -e xpptut15 -r 321

%run xppmodules/scripts/LoadLittleDataAna.py --run 321 --exp xpptut15

make LittleDataAna_psana from dsname:  exp=xpptut15:run=321:smd

try to make littleDataAna using dirname    for exp:  xpptut15  and run  321

setting up littleData ana from anaps 

and now open in dir:  /reg/d/psdm/xpp/xpptut15/ftc  to open file  /reg/d/psdm/xpp/xpptut15/ftc/ldat_xpptut15_Run321.h5

could not find file:  /reg/d/psdm/xpp/xpptut15/ftc/ldat_xpptut15_Run321.h5

we will now try to open the littleData file directly

and now open in dir:  /reg/d/psdm/xpp/xpptut15/ftc  to open file  /reg/d/psdm/xpp/xpptut15/ftc/ldat_xpptut15_Run321.h5

could not find file:  /reg/d/psdm/xpp/xpptut15/ftc/ldat_xpptut15_Run321.h5

 

 

LDana In [1]: anaps.AvImage()
detectors in event: 
cspad
opal_1
opal_1
Select detector to select ROI of?:
cspad
try get detector info to make average image for:  cspad
try to make psana Detector with:  cspad
masking 61008 pixel (status & edge,..) of 2296960
done setting up the geometry
requested  100  used  100  now actually get events
use common mode:  0

 

The result looks like this:

Make a mask selecting one of the rings.

Here we use the beam center as obtained using mouse clicks on one of the rings. We select a circle mask using the beam center and select one of the rings. We do NOT store the mask in the calib directory as we do not want to use it for production, only to use the threshold setting version of the beam center fit.

anaps_powder_MakeMask

 

LDana In [2]: anaps.MakeMask()
plot AvImg_pedSub_cspad using the 5/99.5 percentiles as plot min/max: (1.12247, 46.7645)
rectangle(r), circle(c), polygon(p), dark(d) or noise(n)?:
c
Select center by mouse?
n
center (x y)?
86572.6 -9079
Select outer radius by mouse?
y
/reg/g/psdm/sw/releases/ana-0.19.11/arch/x86_64-rhel7-gcc48-opt/python/matplotlib/backend_bases.py:2399: MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented
  warnings.warn(str, mplDeprecation)
Select inner radius by mouse (for donut-shaped mask)?
y
radii:  125873.390368   109958.642193
mask from circle (shape): (32, 185, 388)
created a mask.... 0
masked in this step:  237890.0
masked up to this step:  237890.0
masked tot:  237890.0
Add this mask?
y
Done?
y
Invert (default/no inversion: masked pixels will get rejected)?
y
Save to calibdir?
n
Save to local?
n
LDana Out[2]: 
array([[False, False,  True, ..., False, False, False],
       [False, False,  True, ..., False, False, False],
       [False, False, False, ..., False, False, False],
       ..., 
       [False, False, False, ..., False, False, False],
       [False, False, False, ..., False, False, False],
       [False, False, False, ..., False, False, False]], dtype=bool)

 

Fit the beam center using this mask

Setting use_mask_local to true, the locally defined mask will be used. use_mask=True will use the mask as defined in the calibdirectory.

anaps_powder_FitCircle

 

LDana In [4]: anaps.FitCircle(use_mask_local=True)
plot AvImg_pedSub_cspad using the 5/99.5 percentiles as plot min/max: (1.12247, 46.7645)
Select Circle Points by Mouse?:
n
Select Circle Points with threshold (y/n):
y
min percentile % of selected points:
98
thresP 10.1181592941
Happy with this threshold (y/n):
n
min percentile % of selected points:
99
thresP 11.3860747719
Happy with this threshold (y/n):
n
min percentile % of selected points:
99.8
thresP 16.0652765617
Happy with this threshold (y/n):
y
x,y:  87393.1655731 -10692.6638104  R  121701.713621
 

Test the azimuthal integration using the beam center & detector distance

Now we can create azInt objects to test the beam center and detector distance:

azimuthal integral

 

LDana In [1]: anaps.AvImage('cspad',numEvts=100)
try get detector info to make average image for:  cspad
try to make psana Detector with:  cspad
masking 61008 pixel (status & edge,..) of 2296960
done setting up the geometry
requested  100  used  100  now actually get events
use common mode:  0
 
LDana In [2]: anaps.addAzInt('cspad',dis_to_sam=60.,center=[87480.8328549, -9033.72940652])
mask 61008 pixel for azimuthal integration
initialize azimuthal binning, mask 61008 pixel for azimuthal integration
qmax:  5.81587256329  qbin  0.01
 
LDana In [3]: anaps.addAzInt('cspad',dis_to_sam=360.,center=[87480.8328549, -9033.72940652],name='azav2')
mask 61008 pixel for azimuthal integration
initialize azimuthal binning, mask 61008 pixel for azimuthal integration
qmax:  2.54820549725  qbin  0.01
 
LDana In [4]: qb=anaps.AzInt(plotIt=True)
we have the following options:  ['azav2', 'azav']
type the name of the Azimuthal integral to use:azav
/reg/data/ana13/xpp/xppo5616/results/newAzInt_littleData/xppmodules/src/azimuthalBinning.py:213: RuntimeWarning: invalid value encountered in divide
  self.sig = 1./np.sqrt(self.ADU_per_photon)*np.sqrt(I)/self.Cake_norm  # ??? where comes this sqrt from? Ah I see...
/reg/data/ana13/xpp/xppo5616/results/newAzInt_littleData/xppmodules/src/azimuthalBinning.py:214: RuntimeWarning: invalid value encountered in divide
  self.Icake = I/self.Cake_norm
(582,) (582,)
 
LDana In [5]: qb2=anaps.AzInt()
we have the following options:  ['azav2', 'azav']
type the name of the Azimuthal integral to use:azav2
 
LDana In [6]: anaps.pl
anaps.plotAvImage  anaps.plotAzInt    anaps.plotScan     anaps.plotVar      
 
LDana In [6]: anaps.plotA
anaps.plotAvImage  anaps.plotAzInt    
 
LDana In [6]: anaps.plotAzInt()
we have the following options:  ['azav2', 'azav']
type the name of the Azimuthal integral to use:azav2
(255,) (255,)
 

 

Done.
  • No labels