Table of Contents

Package ImgAlgos

Module ImgAlgos.CorAnaPars

Project: Evaluation of the Image Auto-Correlation Function CorAnaPars work as a part of the python file managing script in the process of evaluation of the Image Auto-Correlation Function.

CorAnaPars is a singleton class object to hold common parameters.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

See also: RelatedModule: CorAnaSubmit.py CorAnaPars.py CorAna*.cpp

Version: $Id: 2012-09-26 15:00:00Z dubrovin$

Author: Mikhail Dubrovin

Module ImgAlgos.CorAnaSubmit

Project: Evaluation of the Image Auto-Correlation Function CorAnaSubmit work as a part of the python file managing script in the process of evaluation of the Image Auto-Correlation Function.

CorAnaSubmit.py contains global methods for file management.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

See also: RelatedModule: CorAnaSubmit.py CorAnaPars.py CorAna*.cpp

Version: $Id: 2012-09-26 15:00:00Z dubrovin$

Author: Mikhail Dubrovin

Function ImgAlgos.CorAnaSubmit.batch_job_status

ImgAlgos.CorAnaSubmit.batch_job_status(job_id_str)[source]

Function ImgAlgos.CorAnaSubmit.batch_job_status_and_nodename

ImgAlgos.CorAnaSubmit.batch_job_status_and_nodename(job_id_str)[source]

Function ImgAlgos.CorAnaSubmit.batch_job_submit

ImgAlgos.CorAnaSubmit.batch_job_submit(command_seq)[source]

Function ImgAlgos.CorAnaSubmit.check_list_of_files

ImgAlgos.CorAnaSubmit.check_list_of_files(trailer)[source]

Function ImgAlgos.CorAnaSubmit.check_the_file

ImgAlgos.CorAnaSubmit.check_the_file(trailer)[source]

Function ImgAlgos.CorAnaSubmit.do_main

ImgAlgos.CorAnaSubmit.do_main()[source]

Function ImgAlgos.CorAnaSubmit.get_array_from_file

ImgAlgos.CorAnaSubmit.get_array_from_file(fname)[source]

Function ImgAlgos.CorAnaSubmit.get_dirname_from_path

ImgAlgos.CorAnaSubmit.get_dirname_from_path(path)[source]

Function ImgAlgos.CorAnaSubmit.get_list_of_files_in_dir

ImgAlgos.CorAnaSubmit.get_list_of_files_in_dir(dirname)[source]

Function ImgAlgos.CorAnaSubmit.get_parameter_from_cfg_file

ImgAlgos.CorAnaSubmit.get_parameter_from_cfg_file(fname, parname)[source]

Function ImgAlgos.CorAnaSubmit.get_parameter_from_cfg_file_line

ImgAlgos.CorAnaSubmit.get_parameter_from_cfg_file_line(line, parname)[source]

Function ImgAlgos.CorAnaSubmit.get_xtc_fname_from_cfg_file

ImgAlgos.CorAnaSubmit.get_xtc_fname_from_cfg_file(cfgname)[source]

Function ImgAlgos.CorAnaSubmit.init_pars

ImgAlgos.CorAnaSubmit.init_pars()[source]

Function ImgAlgos.CorAnaSubmit.input_option_parser

ImgAlgos.CorAnaSubmit.input_option_parser()[source]

Function ImgAlgos.CorAnaSubmit.one_batch_job_submit_and_wait

ImgAlgos.CorAnaSubmit.one_batch_job_submit_and_wait(command_seq)[source]

Function ImgAlgos.CorAnaSubmit.parse_path

ImgAlgos.CorAnaSubmit.parse_path(path)[source]

Function ImgAlgos.CorAnaSubmit.parse_xtc_fname

ImgAlgos.CorAnaSubmit.parse_xtc_fname(fname)[source]

Function ImgAlgos.CorAnaSubmit.print_all_files_in_dir

ImgAlgos.CorAnaSubmit.print_all_files_in_dir(dirname)[source]

Function ImgAlgos.CorAnaSubmit.print_list_of_files_in_dir

ImgAlgos.CorAnaSubmit.print_list_of_files_in_dir(dirname, path_or_fname)[source]

Function ImgAlgos.CorAnaSubmit.print_parsed_path

ImgAlgos.CorAnaSubmit.print_parsed_path(path)[source]

Function ImgAlgos.CorAnaSubmit.print_subproc_attributes

ImgAlgos.CorAnaSubmit.print_subproc_attributes(proc)[source]

Use it after command like: proc = subprocess.Popen(bcmd, stdout=subprocess.PIPE)

Function ImgAlgos.CorAnaSubmit.remove_file

ImgAlgos.CorAnaSubmit.remove_file(path)[source]

Function ImgAlgos.CorAnaSubmit.remove_file_for_tail

ImgAlgos.CorAnaSubmit.remove_file_for_tail(list_of_tails)[source]

Function ImgAlgos.CorAnaSubmit.remove_split_files

ImgAlgos.CorAnaSubmit.remove_split_files()[source]

Function ImgAlgos.CorAnaSubmit.split_string

ImgAlgos.CorAnaSubmit.split_string(str, separator='-s')[source]

Function ImgAlgos.CorAnaSubmit.submit_job_for_merging

ImgAlgos.CorAnaSubmit.submit_job_for_merging()[source]

Function ImgAlgos.CorAnaSubmit.submit_job_for_merging_interactive

ImgAlgos.CorAnaSubmit.submit_job_for_merging_interactive()[source]

Function ImgAlgos.CorAnaSubmit.submit_job_for_proc_results

ImgAlgos.CorAnaSubmit.submit_job_for_proc_results()[source]

Function ImgAlgos.CorAnaSubmit.submit_job_for_proc_results_interactive

ImgAlgos.CorAnaSubmit.submit_job_for_proc_results_interactive()[source]

Function ImgAlgos.CorAnaSubmit.submit_job_for_splitter

ImgAlgos.CorAnaSubmit.submit_job_for_splitter()[source]

Function ImgAlgos.CorAnaSubmit.submit_job_for_splitter_interactive

ImgAlgos.CorAnaSubmit.submit_job_for_splitter_interactive()[source]

Function ImgAlgos.CorAnaSubmit.submit_jobs_for_cor_proc

ImgAlgos.CorAnaSubmit.submit_jobs_for_cor_proc()[source]

Function ImgAlgos.CorAnaSubmit.submit_jobs_for_cor_proc_interactive

ImgAlgos.CorAnaSubmit.submit_jobs_for_cor_proc_interactive()[source]

Module ImgAlgos.PyAlgos

Class provides access to C++ algorithms from python.

Usage:

# !!! None is returned whenever requested information is missing.

# IMPORT
# ======
import psana
from ImgAlgos.PyAlgos import PyAlgos    


# INPUT PARAMETERS
# ================
# List of windows
winds = None # entire size of all segments will be used for peak finding
winds = (( 0, 0, 185, 0, 388), ( 1, 20, 160, 30, 300), ( 7, 0, 185, 0, 388))

# Mask
mask = None                   # (default) all pixels in windows will be used for peak finding
mask = det.mask()             # see class Detector.PyDetector
mask = np.loadtxt(fname_mask) # 
mask.shape = (32,185,388)     # should be the same as shape of data n-d array

# Data n-d array
nda = det.calib() # see class Detector.PyDetector


# INITIALIZATION
# ==============
# create object:
alg = PyAlgos(windows=winds, mask=mask, pbits=0)
# where pbits - is a print info control bit-word:
# pbits = 0   - print nothing
#       + 1   - main results, list of peaks
#       + 2   - input parameters, index matrix of pixels for S/N algorithm
#       + 128 - tracking and all details in class PyAlgos.py
#       + 256 - tracking and all details in class AlgArrProc
#       + 512 - tracking and all details in class AlgImgProc

# set peak-selector parameters:
alg.set_peak_selection_pars(npix_min=5, npix_max=5000, amax_thr=0, atot_thr=0, son_min=10)


# HIT FINDERS
# ===========
# Hit finders return simple values for decision on event selection.

# get number of pixels above threshold
npix = alg.number_of_pix_above_thr(data, thr=10)

# get total intensity of pixels above threshold
intensity = alg.intensity_of_pix_above_thr(data, thr=12)


# PEAK FINDERS
# ============
# Peak finders return list (numpy.array) of records with found peak parameters.

# v1 - aka Droplet Finder - two-threshold peak-finding algorithm in restricted region
#                           around pixel with maximal intensity.
peaks = alg.peak_finder_v1(nda, thr_low=10, thr_high=150, radius=5, dr=0.05)

# v2 - define peaks for regoins of connected pixels above threshold
peaks = alg.peak_finder_v2(nda, thr=10, r0=7.0, dr=2.0)

# v3 - define peaks in local maximums of specified rank (radius),
#      for example rank=2 means 5x5 pixel region around central pixel.
#      nsigm - optional threshold (number of noise rms) for pixel selection 
peaks = alg.peak_finder_v3(nda, rank=2, r0=7.0, dr=2.0, nsigm=0)
peaks = alg.peak_finder_v3r2(nda, rank=2, r0=7.0, dr=2.0, nsigm=0) # test version for connected pixels

# v4 - aka Droplet Finder - the same as v1, but uses rank and r0 parameters in stead of common radius.
peaks = alg.peak_finder_v4(nda, thr_low=10, thr_high=150, rank=4, r0=7.0, dr=2.0)
peaks = alg.peak_finder_v4r2(nda, thr_low=10, thr_high=150, rank=5, r0=7.0, dr=2.0) # test version for connected pixels


# OPTIONAL METHODS
# ================
# print info
alg.print_attributes()   # attributes of the PyAlgos object 
alg.print_input_pars()   # member data of C++ objects

# set parameters for S/N evaluation algorithm
alg.set_son_pars(r0=5, dr=0.05)

# set mask
alg.set_mask(mask)

# set windows in segments to search for peaks
alg.set_windows(winds)

# Call after alg.peak_finder_v2, v4r2 ONLY! Returns n-d array with 2-d maps of pixel status 
maps = alg.maps_of_pixel_status()

# Call after alg.peak_finder_v2 ONLY! Returns n-d array with 2-d maps of connected pixels 
maps = alg.maps_of_connected_pixels()

# Call after alg.peak_finder_v3 ONLY! Returns n-d array with 2-d maps of local maximums
maps = alg.maps_of_local_maximums()

# GLOBAL METHODS
# ==============
#   Subtracts numpy array of bkgd from data using normalization in windows.
#   Each window is specified by 5 parameters: (segment, rowmin, rowmax, colmin, colmax)
#   For 2-d arrays segment is not used, but still 5 parameters needs to be specified.
cdata = subtract_bkgd(data, bkgd, mask=None, winds=None, pbits=0)

# Merges photons split among pixels and returns n-d array with integer number of photons per pixel.
nphotons_nda = photons(fphotons_nda, mask)

See also: classes

Detector.AreaDetector - acess to detector data

This software was developed for the LCLS project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: PyAlgos.py 12917 2016-11-29 20:14:54Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function ImgAlgos.PyAlgos.photons

ImgAlgos.PyAlgos.photons(data, mask)[source]

returns 2-d or 3-d array with number of merged photons per pixel

Function ImgAlgos.PyAlgos.photons_2d

ImgAlgos.PyAlgos.photons_2d(data, mask=None)[source]

returns 2-d array with number of merged photons per pixel

Function ImgAlgos.PyAlgos.print_arr

ImgAlgos.PyAlgos.print_arr(arr, cmt='')[source]

Function ImgAlgos.PyAlgos.print_arr_attr

ImgAlgos.PyAlgos.print_arr_attr(arr, cmt='')[source]

Function ImgAlgos.PyAlgos.reshape_nda_to_2d

ImgAlgos.PyAlgos.reshape_nda_to_2d(arr)[source]

Reshape np.array to 2-d

Function ImgAlgos.PyAlgos.reshape_nda_to_3d

ImgAlgos.PyAlgos.reshape_nda_to_3d(arr)[source]

Reshape np.array to 3-d

Function ImgAlgos.PyAlgos.subtract_bkgd

ImgAlgos.PyAlgos.subtract_bkgd(data, bkgd, mask=None, winds=None, pbits=0)[source]

Subtracts numpy array of bkgd from data using normalization in windows. Each window is specified by 5 parameters: (segment, rowmin, rowmax, colmin, colmax) For 2-d arrays segment is not used, but still 5 parameters needs to be specified.

Function ImgAlgos.PyAlgos.test_photons_2d

ImgAlgos.PyAlgos.test_photons_2d()[source]

Function ImgAlgos.PyAlgos.test_photons_3d

ImgAlgos.PyAlgos.test_photons_3d()[source]

Function ImgAlgos.PyAlgos.test_pyalgos

ImgAlgos.PyAlgos.test_pyalgos()[source]

Module ImgAlgos.SvnProps

Class SvnProps stores updated by svn properties.

NOTE: To update revision number in this file when revision changes, use command: psvn mktxtprop src/SvnProps.py or svn propset svn:keywords “Revision” src/SvnProps.py Also see: ~/.subversion/config

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: SvnProps.py 9224 2014-11-10 18:41:00Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhai S. Dubrovin