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

...

Code Block
none
none
pixels = pixel_array.reshape(1480,388)
np.save("pixel_pedestal_file.npy", pixels )

CSPad tile arrangement

To get a rough picture of the full detector, here's an example of how XtcExplorer/src/cspad.py does it:

  • For each Quadrant:
    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
            """
            # Construct one image for each quadrant, each with 8 sections
            # from a data3d = 3 x 2*194 x 185 data array
            #   +---+---+-------+
            #   |   |   |   6   |
            #   + 5 | 4 +-------+
            #   |   |   |   7   |
            #   +---+---+---+---+
            #   |   2   |   |   |
            #   +-------+ 0 | 1 |
            #   |   3   |   |   |
            #   +-------+---+---+
            #
            # each section read from the event has "landscape" orientation
            # with 185 rows (first index) and 2*194 columns (2nd index)
            #   - Sections 0,1: "portrait" orientation / tilted 90 degrees counter clockwise:
            #                    first index increases from left to right, 2nd index increases from bottom to top, 
            #   - Sections 2,3: "landscape" orientation / as is:
            #                    first index increases from top to bottom, 2nd index increases from left to right
            #   - Sections 4,5: "portrait" orientation / tilted 90 degrees clockwise:
            #                    first index increases from right to left, 2nd index increases from top to bottom, 
            #   - Sections 6,7: "landscape" orientation / as is:
            #                    first index increases from top to bottom, 2nd index increases from left to right
            #   Again, the orientations of the Sections for quadrant 1 are rotated 90 degrees clockwise
        
            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_quad, self.npix_quad), 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_quad - self.sec_offset[0] - (self.section_centers[0][qn][sec] + nrows/2)
                colp = self.npix_quad - 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, ":", rowp+nrows, ", ", colp, ":",colp+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_quad+100, 2*self.npix_quad+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_quad, qoff_y:qoff_y+self.npix_quad]=quad_image

        return self.image

Fine tuning

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.

CSPad alignment

Saving data arrays

...