You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

Run dependent parameters: 

First up are functions that will return e.g. the region-of-interest boundaries for each run. During the experiment, this should be kept up-to-date so if the setup changes, the smallData file will get an entry with new boundaries for a just finished range of runs. This way, the smallDataRun script will always use the correct region of interest for each run.

UserData: Roi definition 


def getROIs(run, expname):
    if run<=314:
        sigROI = [[1,2], [85,120], [0,388]]
        sigROI2 = [[1,2], [0,184], [30,315]]
    else:
        sigROI = [[1,2], [83,112], [0,388]]
        sigROI2 = [[1,2], [0,184], [30,315]]
    return sigROI, sigROI2

ROI: 

Below is an entry that show how to add a ROI on a cs140k detector to the littleData. the integral of the ROI and the center-of-mass values for the ROI will always be stored. WriteArea=True will cause the full ROI be written to the event. To get a sum with a theshold, define a projection for the ROI with a threshold using "axis=-1"

User Data: small subarea

have_cs140_0 = checkDet(env, 'cs140_0')
if have_cs140_0:
    cs140_0 = DetObject('cs140_0' ,env, int(run), name='vonHamos')
	for iROI, ROI in enumerate(ROIs):    
		cs140_0.addROI('ROI%d'%iROI,ROI)  #saves sum, center-of-mass, max 
	    #or in real life, not both!
		cs140_0.addROI('ROI%d'%iROI,ROI, writeArea=True)  #also saves the pixel array. Masked pixels will appear as nan.                                               
    dets.append(cs140_0)

 

ROI: projection

For a second cs140 detector, we chose a larger ROI, but only save the projections in "x" and "y". Here the projection is done without any further treatment (first lines) and with a threshold of 25 ADU. A threshold using the noise of the pixel as determined in the pedestal run is also possible (use cutRMS = xx where xx is the number of noise RMS a pixel needs to be higher than). 'axis=-1' will result in a single number and can be used to get a thresholded sum of the ROI.

UserData: projections of ROI

have_cs140_1 = checkDet(env, 'cs140_1')
if have_cs140_1:
    cs140_1 = DetObject('cs140_1' ,env, int(run), name='Rowland')
	for iROI, ROI in enumerate(ROIs):    
		cs140_1.addROI('ROI%d'%iROI,ROI, rms=cs140_1.rms)
    	cs140_1.ROI0.addProj('_x', axis=0)
    	cs140_1.ROI0.addProj('_y', axis=1)
    	cs140_1.ROI0.addProj('_ythres', axis=1, singlePhoton=False, cutADU=25.)
    	cs140_1.ROI0.addProj('_xthres', axis=0, singlePhoton=False, cutADU=25.)
    dets.append(cs140_1)
 

Use of SmallDataAna_psana and extracting information from the average image

For the use of the interactive features of SmallDataAna_psana, we recommend to start it in an ipython session as interactive grabbing of user input is currently not implemented via the notebook. The first step is to create an average image that shows the feature of interest well.
From from smalldata_tools top level directory, run the following command to launch an IPython shell with pre-loaded a data analysis class for the relevant run


./producers/runSmallDataAna -r <#> [-e <expname>]

The average image can be then made by running

SDAna In: anaps.AvImage()

This will by default create an average image of 100 events of an area detector. The method will list and prompt for a detector name if more than one was recorded.
The full command with all its options can be looked via using the "?" feature of python:
SDAna In: anaps.AvImage?
More details can be found in the section Working with Images from camera/areadetectors

ROI

SDAna In: anaps.SelectRegion()
This will by draw the image and let you select a rectangular area of interest with the mouse. At this point, you click on two corners of the ROI. Once you are happy with your selection, it will print the numbers you need to enter in the producer file. Below both what the terminal session looks like (here with an optional selection of different plot limits, by default 5% and 99.5% are used). Figure 2 will come up when you get asked if you are happy with the selection which appears on the right side of that figure. "n" means you can to click again until you are satisfied. "y" will print the ROI as it should be entered in the LittleDataProducer file. Figure 3 shows the ROI again, this time obtained from the raw data rather than the image (a technical detail). The more striking different is that the scaling/limit are now taken from only the ROI rather than the whole image.

Select ROI

The SelectRegion function works after an average image has been created. It expects you to select the two opposite corners of a rectangle. The selected region will then be plotted on the right hand side so that you can decide if this was good enough. If "yes" is selected, the ROI is plotted again using a color scale based on the ROI only and the ROI is printed in a form that can be copy/pasted into the producer python file.

 

SDana In [3]: anaps.SelectRegion(limits=[5,99.8])
plot AvImg_cs140_rob using the 5/99.8 percentiles as plot min/max: (1603.9, 1994.84)
Happy with this selection:
y
ROI: [[1,2], [55,76], [308,335]]

  • No labels