Versions Compared

Key

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

...

Cloak
iddelayscan
  • Fetching the ControlPV information:
    ControlPV is available from the env object, and since it only changes at the beginning
    of each calibration cycle, the begincalibcycle function is the appropriate place to get it:
    none
    The ControlConfig object may contain several pvControl and pvMonitor objects. In this case
    there's only one, but make sure the name matches anyway: none
  • Fetching the IPIMB and PhaseCavity information:
    All the other information that we need, is available through the evt object, and
    event member function is the place to get it:
    none
    Use "XppSb3Ipm-1|Ipimb-0" (a.k.a. IPM3) sum of all channels for normalization and filtering
    none
    Use "XppSb3Pim-1|Ipimb-0" (a.k.a. PIM3) channel 1 as signal
    none
    Get the phase cavity:
    none
    Compute delay time and fill histograms
    none

Image peak finding

Here are a collection of useful algorithms for image analysis: http://docs.scipy.org/doc/scipy/reference/ndimage.html

...

  • For each Quadrant (cspad_layout.txt):
    Code Block
    none
    none
        def get_quad_image( self, data3d, qn) :
            """get_quad_image
            Get an image for this quad (qn)
    
            @param data3d           3d data array (row vs. col vs. section)
            @param qn               quad number
            """    
            pairs = []
            for i in range (8) :
            
                # 1) insert gap between asics in the 2x1
                asics = np.hsplit( data3d[i], 2)
                gap = np.zeros( (185,3), dtype=data3d.dtype )
                #
                # gap should be 3 pixels wide
                pair = np.hstack( (asics[0], gap, asics[1]) )
    
                # all sections are originally 185 (rows) x 388 (columns) 
                # Re-orient each section in the quad
    
                if i==0 or i==1 :
                    pair = pair[:,::-1].T   # reverse columns, switch columns to rows. 
                if i==4 or i==5 :
                    pair = pair[::-1,:].T   # reverse rows, switch rows to columns
                pairs.append( pair )
    
                if self.small_angle_tilt :
                    pair = scipy.ndimage.interpolation.rotate(pair,self.tilt_array[qn][i])
    
            # make the array for this quadrant
            quadrant = np.zeros( (self.npix_quad850, self.npix_quad850), dtype=data3d.dtype )
    
            # insert the 2x1 sections according to
            for sec in range (8):
                nrows, ncols = pairs[sec].shape
    
                # colp,rowp are where the top-left corner of a section should be placed
                rowp = self.npix_quad850 - self.sec_offset[0] - (self.section_centers[0][qn][sec] + nrows/2)
                colp = self.npix_quad850 - self.sec_offset[1] - (self.section_centers[1][qn][sec] + ncols/2)
                
                quadrant[rowp:rowp+nrows, colp:colp+ncols] = pairs[sec][0:nrows,0:ncols]
                if (rowp+nrows > self.npix_quad) or (colp+ncols > self.npix_quad) :
        )
                print "ERROR"
                    print rowp, ":", quadrant[rowp:rowp+nrows, ", ", colp, ":",colp+ncolscolp:colp+ncols] = pairs[sec][0:nrows,0:ncols]
    
            return quadrant
    

Then combine all four quadrant images into the full detector image:

Code Block
none
none
        self.image = np.zeros((2*self.npix_quad850+100, 2*self.npix_quad850+100 ), dtype="float64")
        for quad in xrange (4):

            quad_image = self.get_quad_image( self.pixels[quad], quad )
            self.qimages[quad] = quad_image

            if quad>0:
                # reorient the quad_image as needed
                quad_image = np.rot90( quad_image, 4-quad)

            qoff_x = self.quad_offset[0,quad]
            qoff_y = self.quad_offset[1,quad]
            self.image[qoff_x:qoff_x+self.npix_quad850, qoff_y:qoff_y+self.npix_quad850]=quad_image

        return self.image

...

Notice that the code snippets above make use of some predefined quantities which it reads in from "calibration files". The files contains calibrated numerical values for individual sections' and quads' rotations and shifts. All of these files are located in the experiment's 'calib' folder, but is not generated automatically. The XtcExplorer currently has a local version which is not correct but which is close enough to display a reasonable image. For how the files have been read in, you can take a look at XtcExplorer/src/cspad.py's read_alignment function.

For how to find the correct constants for each experiment, look at the CSPad alignment page.

Saving data arrays

saving numpy arrays to numpy file

...