smd_producer.py

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.


def getROIs(run):
    """ Set parameter for ROI analysis. Set writeArea to True to write the full ROI in the h5 file.
    See roi_rebin.py for more info
    """
    if isinstance(run,str):
        run=int(run)
    ret_dict = {}
    if run<21:
        roi_dict = {}
        roi_dict['ROIs'] = [ [[1,2], [127,394], [655,923]]] # can define more than one ROI
        roi_dict['writeArea'] = True
        roi_dict['thresADU'] = None
        ret_dict['jungfrau1M'] = roi_dict
    elif run>20 and run<43:
        roi_dict = {}
        roi_dict['ROIs'] = [chip22] # can define more than one ROI
        roi_dict['writeArea'] = True
        roi_dict['thresADU'] = None
        ret_dict['jungfrau1M'] = roi_dict
    elif run>42:
        roi_dict = {}
        roi_dict['ROIs'] = [chip22] # can define more than one ROI
        roi_dict['writeArea'] = True
        roi_dict['thresADU'] = None
        ret_dict['jungfrau1M'] = roi_dict
    return ret_dict


Besides, the ROI definition, the parameters are the following:

writeArea: whether to write the full ROI to file or only the statistics (intensity sum, and other statistics)

thresADU: pixel intensity threshold. Any pixel below that value are set to 0.

Use of SmallDataAna_psana to set up the producer's parameters

See the following link to learn how to start an interactive iPython session and make an average image for a given detector:

1.2 Area Detector treatment with DetObject#1.2AreaDetectortreatmentwithDetObject-InteractiveSmallDataAnasession

Once an average image has been created, a ROI can be selected by running:


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.
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 Smalldata producer file. A third figure will then show 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.

 

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