Table of Contents

Package pyimgalgos

Module pyimgalgos.AngularIntegrator

AngularIntegrator - Evaluate radial histogram for angle-integrated 2-d image

Usage:

# IMPORT
from pypsalg.AngularIntegrator import AngularIntegratorM

# Define test parameters
import numpy as np
img = np.ones((1200,1300), dtype=np.float32)  # generate test image as numpy array of ones of size (rows,cols) = (1200,1300)
mask = np.ones_like(img)                      # generate test mask for all good pixels

rows, cols = img.shape                        # define shape parameters rows, cols - number of image rows, columns, respectively
rmin, rmax, nbins =100, 400, 50               # define radial histogram parameters - radial limits and number of equidistant bins

# Initialization of object and its parameters
ai = AngularIntegratorM()
ai.setParameters(rows, cols, xc=cols/2, yc=rows/2, rmin=rmin, rmax=rmax, nbins=nbins, mask=mask, phimin=-180, phimax=180)

# do angular integration for each input image and return array of bin centers and associated normalized intensities
bins, intensity = ai.getRadialHistogramArrays(img)

# test plot example
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5), dpi=80, facecolor='w', edgecolor='w', frameon=True)
plt.hist(bins, bins=nbins, weights=intensity, color='b')
plt.show()

See also: pypsalg.AngularIntegratorM

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

Version: $Id: AngularIntegrator.py 10848 2015-10-14 16:14:43Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.AngularIntegrator.divideArraysSafely

pyimgalgos.AngularIntegrator.divideArraysSafely(num, den)[source]

Per evement divides numpy arrays result = num/den. Protected for 0 values. Arrays should have the same size.

Function pyimgalgos.AngularIntegrator.drawGraph

pyimgalgos.AngularIntegrator.drawGraph(x, y)[source]

Function pyimgalgos.AngularIntegrator.drawImage

pyimgalgos.AngularIntegrator.drawImage(arr, img_range=None, zrange=None, figsize=(10, 10))[source]

Function pyimgalgos.AngularIntegrator.mainTest

pyimgalgos.AngularIntegrator.mainTest()[source]

Function pyimgalgos.AngularIntegrator.MakeImage

pyimgalgos.AngularIntegrator.MakeImage(shape=(1024, 1024))[source]

Function pyimgalgos.AngularIntegrator.valueToIndexProtected

pyimgalgos.AngularIntegrator.valueToIndexProtected(V, VRange)[source]

Returns array of indexes from array of values @param[in] V - numpy array of values, @param[in] VRange - Vmin, Vmax, contains the binning parameters Vmin, Vmax, and Nbins Output: Array of indexes from 0 to Nbins (Nbins+1 index) with shape of V. The last index Nbins is used for overflow and underflow.

Module pyimgalgos.centroid_smoother

Class pyimgalgos.centroid_smoother.CentroidSmoother

class pyimgalgos.centroid_smoother.CentroidSmoother(ds, det, rNum)[source]

With the datasource, detector and run number, this object will fetch the relevant data as saved by the CentroidSmootherCalib object and read it in.

Parameters: ds - datasource as obtained via psana.DataSource()
det - detector used as obtained via psana.Detector() rNum - run number of data
_correctedOffset(offsets)[source]
getSmoothedCentroids(offsets)[source]
Parameters: An array of floats the rows and columns of peak centroids
in the shape (x, 2) for x peaks.
Output: An array of floats of the rows and columns of the smoothed
centroids in the same shape as the input.

Given an array of centroids, this function smooths and returns them.

Class pyimgalgos.centroid_smoother.CentroidSmootherCalib

class pyimgalgos.centroid_smoother.CentroidSmootherCalib(nBins=100)[source]

A calibration object that needs only to run once. Data and constants will be saved to be used by the CentroidSmoother object.

Parameters: nBins - (Optional) The number of bins for the histogramming
of the absolute distance from the center of the pixel for each centroid
add(centroids)[source]
Parameters: An array of floats of the rows and columns of peak
centroids in the shape (x, 2) for x peaks.

Computes, for each centroid, the absolute distance from the center of the pixel that the centroid is in. The values range from 0 to 0.5.

save(ds, det, rNumBegin, rNumEnd=None)[source]
Parameters: ds - datasource as obtained via psana.DataSource()

det - detector used as obtained via psana.Detector() rNumBegin - run number that the saved data begins with rNumEnd - (Optional) run number that the saved data

ends with

From the given parameters, saves the data that has been added by add() along with the bins which are computed from the value for nBins.

Module pyimgalgos.cm_epix

Function pyimgalgos.cm_epix.cm_epix

pyimgalgos.cm_epix.cm_epix(img, rms, maxCorr=30, histoRange=30, colrow=3, minFrac=0.25, normAll=False)[source]

Parameters: img - image on which the common mode is applied rms - array of noise values for each pixel with same shape as img maxCorr - (optional) maximum correction applied. If common mode

correction is larger than this value, no correction will be applied

histoRange - (optional) all pixels above this parameter are masked colrow - (optional) decides what is corrected. If 1, only the columns

are corrected. If 2, only the rows are corrected. And if 3, both are corrected
minFrac - (optional) the minimum fraction of pixels required to be
left in a row or column after applying the mask and rejecting high pixels and their neighbors
normAll - (optional) if true, will subtract the mean from the full
image with the masked applied

Module pyimgalgos.cspad_arr_producer

User analysis module for pyana framework.

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

Version: $Id: cspad_arr_producer.py 12470 2016-08-11 21:23:21Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class pyimgalgos.cspad_arr_producer.cspad_arr_producer

class pyimgalgos.cspad_arr_producer.cspad_arr_producer[source]

Produces from CSPAD data numpy array of shape=(4, 8, 185, 388) or (185, 388, 2) and specified data type.

Class constructor. Parameters are passed from pyana.cfg configuration file. All parameters are passed as strings

  • source - string, address of Detector-Id|Device-ID
  • dtype_type - string, output array data type
  • key_out - string, unique keyword for output array identification
  • val_miss - float, intensity value substituted for missing in data 2x1s
  • print_bits - int, bit-word for verbosity control
begincalibcycle(evt, env)[source]
beginjob(evt, env)[source]

This method is called once at the beginning of the job. It should do a one-time initialization possible extracting values from event data (which is a Configure object) or environment.

  • evt - event data object
  • env - environment object
beginrun(evt, env)[source]

This optional method is called if present at the beginning of the new run.

  • evt - event data object
  • env - environment object
endcalibcycle(evt, env)[source]
endjob(evt, env)[source]
endrun(evt, env)[source]
event(evt, env)[source]

This method is called for every L1Accept transition.

  • evt - event data object
  • env - environment object
print_config_pars_for_cspad(env)[source]
print_config_pars_for_cspad2x2(env)[source]
print_dtypes()[source]
print_input_pars()[source]
print_part_of_output_array()[source]
proc_event_for_cspad(evt, env)[source]
proc_event_for_cspad2x2(evt, env)[source]
set_dtype()[source]
dic_dtypes = {'int32': <type 'numpy.int32'>, 'int16': <type 'numpy.int16'>, 'int': <type 'int'>, 'float': <type 'float'>, 'uint8': <type 'numpy.uint8'>, 'uint': <type 'numpy.uint64'>, 'int8': <type 'numpy.int8'>, 'double': <type 'numpy.float64'>, 'uint16': <type 'numpy.uint16'>, 'uint32': <type 'numpy.uint32'>, 'float32': <type 'numpy.float32'>}

Module pyimgalgos.cspad_gainmap

User analysis module

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

Version: $Id: cspad_gainmap.py 8453 2014-06-20 22:38:14Z cpo@SLAC.STANFORD.EDU $

Author: Christopher O’Grady

Class pyimgalgos.cspad_gainmap.cspad_gainmap

class pyimgalgos.cspad_gainmap.cspad_gainmap[source]

Saves image array in file with specified in the name type.

beginjob(evt, env)[source]
beginrun(evt, env)[source]
endjob(evt, env)[source]
event(evt, env)[source]

Module pyimgalgos.EventViewer

Function pyimgalgos.EventViewer.do_test

pyimgalgos.EventViewer.do_test()[source]

Function pyimgalgos.EventViewer.fig_axes

pyimgalgos.EventViewer.fig_axes(figsize=(13, 12), title='Image', dpi=80, win_axim=(0.05, 0.03, 0.87, 0.93), win_axcb=(0.923, 0.03, 0.02, 0.93))[source]

Creates and returns figure, and axes for image and color bar

Function pyimgalgos.EventViewer.list_of_times_default

pyimgalgos.EventViewer.list_of_times_default(run)[source]

Module pyimgalgos.ex_peaks_nda

User analysis module for pyana and psana frameworks.

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

Version: $Id: ex_peaks_nda.py 8469 2014-06-24 22:55:21Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class pyimgalgos.ex_peaks_nda.ex_peaks_nda

class pyimgalgos.ex_peaks_nda.ex_peaks_nda[source]

Example module: gets peaks_nda produced by ImgAlgos.CSPadArrPeakFinder and prints its content

Class constructor. Parameters are passed from pyana.cfg configuration file. All parameters are passed as strings

@param source string, address of DetInfo(:Cspad.) @param key_in string, keyword for input image 2-d array @param print_bits int, bit-word for verbosity control

begincalibcycle(evt, env)[source]
beginjob(evt, env)[source]
beginrun(evt, env)[source]
endcalibcycle(evt, env)[source]
endjob(evt, env)[source]
endrun(evt, env)[source]
event(evt, env)[source]

This method is called for every L1Accept transition.

@param evt event data object @param env environment object

print_input_pars()[source]
print_nda()[source]

Module pyimgalgos.FastArrayTransformation

A set of methods for the fast array transformation based on NumPy and SciPy

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

@see

Version: $Id: FastArrayTransformation.py 8453 2014-06-20 22:38:14Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.FastArrayTransformation.applyRadialNormalizationToPolarArray

pyimgalgos.FastArrayTransformation.applyRadialNormalizationToPolarArray(arrPolar, RRange)[source]

Apply radial normalization (per bin) to polar array

Function pyimgalgos.FastArrayTransformation.cart2polar

pyimgalgos.FastArrayTransformation.cart2polar(x, y)[source]

For numpy arryys x and y returns the numpy arrays of r and theta

Function pyimgalgos.FastArrayTransformation.coordinateToIndex

pyimgalgos.FastArrayTransformation.coordinateToIndex(V, VRange)[source]

Function pyimgalgos.FastArrayTransformation.coordinateToIndexOpenEnd

pyimgalgos.FastArrayTransformation.coordinateToIndexOpenEnd(V, VRange)[source]

Function pyimgalgos.FastArrayTransformation.coordinateToIndexProtected

pyimgalgos.FastArrayTransformation.coordinateToIndexProtected(V, VRange)[source]

Function pyimgalgos.FastArrayTransformation.draw2DImage

pyimgalgos.FastArrayTransformation.draw2DImage(arr, showTimeSec=None, winTitle='Three images', Range=None)[source]

Graphical presentation for three 2D arrays.

Function pyimgalgos.FastArrayTransformation.drawHistogram

pyimgalgos.FastArrayTransformation.drawHistogram(arr)[source]

Draws histogram with reduced number of ticks for vertical axes for input array (dimension does not matter).

Function pyimgalgos.FastArrayTransformation.drawImage

pyimgalgos.FastArrayTransformation.drawImage(arr2d, title, Range=None)[source]

Draws the image and color bar for a single 2D array.

Function pyimgalgos.FastArrayTransformation.drawImageAndSpectrum

pyimgalgos.FastArrayTransformation.drawImageAndSpectrum(arr, showTimeSec=None, winTitle='Three images')[source]

Graphical presentation for three 2D arrays.

Function pyimgalgos.FastArrayTransformation.drawOrShow

pyimgalgos.FastArrayTransformation.drawOrShow(showTimeSec=None)[source]

Function pyimgalgos.FastArrayTransformation.gaussian

pyimgalgos.FastArrayTransformation.gaussian(r, r0, sigma)[source]

Function pyimgalgos.FastArrayTransformation.getCartesianArray1Ring

pyimgalgos.FastArrayTransformation.getCartesianArray1Ring()[source]

Generates the cortesian 2D array with ring-distributed intensity

Function pyimgalgos.FastArrayTransformation.getCartesianArray3Rings

pyimgalgos.FastArrayTransformation.getCartesianArray3Rings()[source]

Generates the cortesian 2D array with ring-distributed intensity

Function pyimgalgos.FastArrayTransformation.getGainCorrectionArrayFromAverage

pyimgalgos.FastArrayTransformation.getGainCorrectionArrayFromAverage(arr_ave)[source]

Function pyimgalgos.FastArrayTransformation.mainTest1Ring

pyimgalgos.FastArrayTransformation.mainTest1Ring()[source]

Function pyimgalgos.FastArrayTransformation.mainTest3Rings

pyimgalgos.FastArrayTransformation.mainTest3Rings()[source]

Function pyimgalgos.FastArrayTransformation.polar2cart

pyimgalgos.FastArrayTransformation.polar2cart(r, theta)[source]

For numpy arryys r and theta returns the numpy arrays of x and y

Function pyimgalgos.FastArrayTransformation.printArrForTest

pyimgalgos.FastArrayTransformation.printArrForTest(arr)[source]

Function pyimgalgos.FastArrayTransformation.printMeanAndStandardDeviation

pyimgalgos.FastArrayTransformation.printMeanAndStandardDeviation(arr)[source]

Function pyimgalgos.FastArrayTransformation.rebinArray

pyimgalgos.FastArrayTransformation.rebinArray(arr2d, XRange, YRange)[source]

Input 2D array elements are summed together in new 2D array bins

Function pyimgalgos.FastArrayTransformation.transformCartToPolarArray

pyimgalgos.FastArrayTransformation.transformCartToPolarArray(arr, RRange, ThetaRange, Origin, rCorrIsOn=False)[source]

Input Cartesian array elements are summed together in 2D polar array bins

This transformation works fine when the ThetaRange is inside a single sheet [-180,180] degree.

Module pyimgalgos.FiberAngles

A set of methods to evaluate angles in fiber diffraction experiments.

Usage::

# Import from pyimgalgos.FiberAngles import fraser, calc_phi, calc_beta, funcy

# Fraser transformation: s12rot, s3rot, reciparr = fraser(arr, beta_deg, L, center=None, oshape=(1500,1500))

# Evaluation of fiber tilt angles beta phi (in the image plane) (in transverse to image plane). phi = calc_phi (x1, y1, x2, y2, dist) beta = calc_beta(x1, y1, phi, dist)

#Fit functions yarr = funcy(xarr, phi_deg, bet_deg)

yarr = funcy_l1_v0(xarr, phi_deg, bet_deg, DoR=0.4765, sgnrt=-1.) (depric.) yarr = funcy_l1_v1(xarr, phi_deg, bet_deg, DoR=0.4765, sgnrt=-1.)

yarr2 = funcy2(xarr, a, b, c)

# Conversion methods qx, qy, qz = recipnorm(x, y, z) # returns q/fabs(k) components for 3-d point along k^prime.

# Commands to test in the release directory: # python ./pyimgalgos/src/FiberAngles.py <test-id> # where # <test-id> = 1 - test of the Fraser transformation # <test-id> = 2 - test of the phi angle # <test-id> = 3 - test of the beta angle

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

Version: $Id: FiberAngles.py 11999 2016-06-01 21:16:06Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.FiberAngles.calc_beta

pyimgalgos.FiberAngles.calc_beta(xpix, ypix, phi, dist)[source]

Evaluates fiber beta angle [rad] for two peaks in equatorial region - xpix - [in] x coordinate of the point - ypix - [in] y coordinate of the point - phi - [in] fiber tilt angle [rad] if the detector plane - dist - [in] distance from sample to detector

Function pyimgalgos.FiberAngles.calc_phi

pyimgalgos.FiberAngles.calc_phi(x1pix, y1pix, x2pix, y2pix, dist)[source]

Evaluates fiber phi angle [rad] for two peaks in equatorial region - x1pix - [in] x coordinate of the 1st point - y1pix - [in] y coordinate of the 1st point - x1pix - [in] x coordinate of the 2nd point - y1pix - [in] y coordinate of the 2nd point - dist - [in] distance from sample to detector

Function pyimgalgos.FiberAngles.fraser

pyimgalgos.FiberAngles.fraser(arr, beta_deg, L, center=None, oshape=(1500, 1500))[source]

Do fraser correction for an array at angle beta and distance L, given in number of pixels (109.92um), angle is in degrees. Example: fraser(array,10,909); (10 degrees at 100mm distance)

ASSUMPTION: 1. by default 2-d arr image center corresponds to (x,y) origin - arr - [in] 2-d image array - beta_deg - [in] angle beta in degrees - L - [in] distance from sample to detector given in units of pixels (110um) - center - [in] center (row,column) location on image, which will be used as (x,y) origin - oshape - [in] ouitput image shape

Function pyimgalgos.FiberAngles.fraser_xyz

pyimgalgos.FiberAngles.fraser_xyz(x, y, z, beta_deg, k=1.0)[source]

Do fraser transformation for of 3-d points given by x,y,z arrays for angle beta around x and returns horizontal and vertical components of the scattering vector in units of k (eV or 1/A). x,y-arrays representing image point coordinates, z-can be scalar - distance from sample to detector. x, y, and z should be in the same units; ex.: number of pixels (109.92um) or [um], angle is in degrees. Example: fraser_xy(x,y,909,10); (10 degrees at 909 pixel (100mm) distance)

ASSUMPTION: - x,y,z - [in] point coordinate arrays with originn in IP - beta_deg - [in] angle beta in degrees - k - [in] scale factor, ex.: wave number in units of (eV or 1/A).

Function pyimgalgos.FiberAngles.funcy

pyimgalgos.FiberAngles.funcy(x, phi_deg, bet_deg)[source]

DEPRICATED alias for funcy_l0(x, phi, beta)

Function pyimgalgos.FiberAngles.funcy2

pyimgalgos.FiberAngles.funcy2(x, a, b, c)[source]

Quadratic polynomial function to test curve_fit.

Function pyimgalgos.FiberAngles.funcy_l0

pyimgalgos.FiberAngles.funcy_l0(x, phi_deg, bet_deg)[source]

Function for parameterization of y(x, phi, beta) of peaks in mediane plane for fiber diffraction ATTENTION!: curve_fit assumes that x and returned y are numpy arrays.

Function pyimgalgos.FiberAngles.funcy_l1_v0

pyimgalgos.FiberAngles.funcy_l1_v0(x, phi_deg, bet_deg, DoR=0.474, sgnrt=-1.0)[source]

DEPRICATED: D/L - is not a constant as it should be Function for parameterization of y(x, phi, beta). v0: EQUATION FOR D/L=... of peaks in l=1 plane for fiber diffraction DoR = d/R ratio, where d is a distance between l=0 and l=1 on image, DoR = 433/913.27 - default constant R is sample to detector distance ATTENTION!: curve_fit assumes that x and returned y are numpy arrays.

Function pyimgalgos.FiberAngles.funcy_l1_v1

pyimgalgos.FiberAngles.funcy_l1_v1(x, phi_deg, bet_deg, DoR=0.4292, sgnrt=1.0)[source]

v0: EQUATION FOR D/R. Function for parameterization of y(x, phi, beta) of peaks in l=1 plane for fiber diffraction DoR = d/R ratio, where d is a distance between l=0 and l=1 on image, DoR = 392/913.27 - default R is sample to detector distance ATTENTION!: curve_fit assumes that x and returned y are numpy arrays.

Function pyimgalgos.FiberAngles.funcy_v0

pyimgalgos.FiberAngles.funcy_v0(x, phi_deg, bet_deg)[source]

Function for parameterization of y(x, phi, beta) of peaks in mediane plane for fiber diffraction ATTENTION!: curve_fit assumes that x and returned y are numpy arrays.

Function pyimgalgos.FiberAngles.qh_to_xy

pyimgalgos.FiberAngles.qh_to_xy(qh, R)[source]

Returns reciprocal (xe,ye) coordinates of the qh projection on Evald sphere. qh - (numpy array) horizontal component of q values (1/A) R - (float scalar) Evald sphere radius (1/A) Assuming that center of the Evald sphere is in (-R,0); qh is oriented along y. NOTE: qh, L, sina, cosa, xe, ye - are the numpy arrays of the same shape as qh

Function pyimgalgos.FiberAngles.recipnorm

pyimgalgos.FiberAngles.recipnorm(x, y, z)[source]

Returns normalizd reciprocal space coordinates (qx,qy,qz) of the scattering vector q = (k^prime- k)/abs(k), and assuming that - scattering point is a 3-d space origin, also center of the Ewalds sphere - k points from 3-d space origin to the point with coordinates x, y, z (pixel coordinates relative to IP) - scattering is elastic, no energy lost or gained, abs(k^prime)=abs(k) - reciprocal space origin is in the intersection point of axes z and Ewald’s sphere.

Function pyimgalgos.FiberAngles.rotation

pyimgalgos.FiberAngles.rotation(X, Y, angle_deg)[source]

For numpy arrays X and Y returns the numpy arrays of Xrot and Yrot rotated by angle_deg

Function pyimgalgos.FiberAngles.rotation_cs

pyimgalgos.FiberAngles.rotation_cs(X, Y, C, S)[source]

For numpy arrays X and Y returns the numpy arrays of Xrot and Yrot

Function pyimgalgos.FiberAngles.rotation_phi_beta

pyimgalgos.FiberAngles.rotation_phi_beta(x, y, L, phi_deg, beta_deg, scale)[source]

Returns horizontal and vertical components of the scattering vector in units of scale (k) x, y can be arrays, L-scalar in the same units, ex. scale = k[1/A] or in number of pixels etc.

Function pyimgalgos.FiberAngles.test_fraser

pyimgalgos.FiberAngles.test_fraser()[source]

Function pyimgalgos.FiberAngles.test_plot_beta

pyimgalgos.FiberAngles.test_plot_beta()[source]

Function pyimgalgos.FiberAngles.test_plot_beta_l0

pyimgalgos.FiberAngles.test_plot_beta_l0()[source]

Function pyimgalgos.FiberAngles.test_plot_beta_l1

pyimgalgos.FiberAngles.test_plot_beta_l1(DoR=0.4292, sgnrt=1.0)[source]

Function pyimgalgos.FiberAngles.test_plot_beta_l1_zoom

pyimgalgos.FiberAngles.test_plot_beta_l1_zoom(DoR=0.4292, sgnrt=1.0)[source]

Function pyimgalgos.FiberAngles.test_plot_phi

pyimgalgos.FiberAngles.test_plot_phi()[source]

Module pyimgalgos.FiberIndexing

Created on Oct 7, 2015

@author: Mikhail

Function pyimgalgos.FiberIndexing.fill_row

pyimgalgos.FiberIndexing.fill_row(dr, qv, qh, h, k, l, sigma_ql, sigma_qt, bpq)[source]

Returns histogram array (row) for horizontal q component filled by probability to see the peak, modulated by the Gaussian function of dr, where dr is a radial distance between the lattice node and Evald’s sphere.

Function pyimgalgos.FiberIndexing.lattice

pyimgalgos.FiberIndexing.lattice(b1=(1.0, 0.0, 0.0), b2=(0.0, 1.0, 0.0), b3=(0.0, 0.0, 1.0), hmax=3, kmax=2, lmax=1, cdtype=<type 'numpy.float32'>)[source]

returns n-d arrays of 3d coordinates or 2d(if lmax=0) for 3d lattice and Miller hkl indices

Function pyimgalgos.FiberIndexing.lattice_node_radius

pyimgalgos.FiberIndexing.lattice_node_radius(b1=(1.0, 0.0, 0.0), b2=(0.0, 1.0, 0.0), b3=(0.0, 0.0, 1.0), hmax=3, kmax=2, lmax=1, cdtype=<type 'numpy.float32'>, fmt='%10.6f')[source]

Function pyimgalgos.FiberIndexing.make_index_table

pyimgalgos.FiberIndexing.make_index_table(prefix='./v01-')[source]

Function pyimgalgos.FiberIndexing.make_lookup_table

pyimgalgos.FiberIndexing.make_lookup_table(b1=(1.0, 0.0, 0.0), b2=(0.0, 1.0, 0.0), b3=(0.0, 0.0, 1.0), hmax=3, kmax=2, lmax=1, cdtype=<type 'numpy.float32'>, evald_rad=3, sigma_q=0.001, fout=None, bpq=None, bpomega=None, bpbeta=None)[source]

Depricated, see make_lookup_table_v2 with sigma_ql, sigma_qt in stead of sigma_q

Function pyimgalgos.FiberIndexing.make_lookup_table_v2

pyimgalgos.FiberIndexing.make_lookup_table_v2(b1=(1.0, 0.0, 0.0), b2=(0.0, 1.0, 0.0), b3=(0.0, 0.0, 1.0), hmax=3, kmax=2, lmax=1, cdtype=<type 'numpy.float32'>, evald_rad=3, sigma_ql=0.001, sigma_qt=0.001, fout=None, bpq=None, bpomega=None, bpbeta=None)[source]

Makes lookup table - crystal lattice nodes information as a function of angle beta and omega, where beta [deg] - fiber axis tilt, omega [deg] - fiber rotation around axis, For each crysal orientation (beta, gamma) lookup table contains info about lattice nodes closest to the Evald’s sphere:

# beta 20.00  omega 178.50 degree
# index   beta     omega   h  k  l     dr [1/A]   R(h,k,l)   qv [1/A]   qh [1/A]   P(omega)
  1078    20.00   178.50   1 -5  0     0.000262   0.211944  -0.016779   0.211221   0.964192
  1078    20.00   178.50   0 -1  0     0.002470   0.038484   0.000343   0.038306   0.038686
  1078    20.00   178.50   0  1  0     0.000582   0.038484  -0.000344  -0.038455   0.834544

where: index - orientation index (just an unique integer number) beta, omega [deg] - crystal orientation angles, h, k, l - Miller indeces dr [1/A] - distance between lattice node and Evald’s sphere R(h,k,l) [1/A] - distance between nodes (h,k,l) and (0,0,0) qv, qh [1/A] - vertical and horizontal components of scattering vector q P(omega) - un-normalized probability (<1) evaluated for dr(omega) using sigma_ql.

File name is generated automatically with current time stamp like lut-cxif5315-r0169-2015-10-23T14:58:36.txt

Input parameters: b1, b2, b3 - reciprocal lattice primitive vectors, hmax, kmax, lmax - lattice node indeces cdtype - data type for lattice node coordinates, evald_rad - Evald’s sphere radius, sigma_ql - expected q resolution along k (due to crystal rotation), sigma_qt - expected qt resolution (in detector plane), fout - open output file object, bpq, bpomega, bpbeta - binning parameters for q, omega, and beta NOTE: Units of b1, b2, b3, evald_rad, and sigma_q should be the same, for example [1/A].

Returns 2-d numpy array for image; summed for all beta probobility(omega vs. q_horizontal).

Function pyimgalgos.FiberIndexing.plot_lattice

pyimgalgos.FiberIndexing.plot_lattice(b1=(1.0, 0.0, 0.0), b2=(0.0, 1.0, 0.0), b3=(0.0, 0.0, 1.0), hmax=3, kmax=2, lmax=1, cdtype=<type 'numpy.float32'>, evald_rad=0.5, qtol=0.01, prefix='', do_movie=False, delay=400)[source]

Plots 2-d reciprocal space lattice, evald sphere, generates series of plots for rotated lattice and movie from these plots.

  • do_movie = True/False - on/off production of movie
  • delay - is a time in msec between movie frames.

Function pyimgalgos.FiberIndexing.print_nda

pyimgalgos.FiberIndexing.print_nda(nda, cmt, fmt=' %8.4f')[source]

Prints ndarray and its shape with preceded comment.

Function pyimgalgos.FiberIndexing.print_omega_dr

pyimgalgos.FiberIndexing.print_omega_dr(omega_deg, dr, drmax=1)[source]

Depricated, see str_omega_drhkl.

Function pyimgalgos.FiberIndexing.radial_distance

pyimgalgos.FiberIndexing.radial_distance(X, Y, Z, evald_rad=0.5)[source]

For all defined nodes of the lattice returns dr - distance from evald sphere to the reciprocal lattice node, qv, qh - vertical, horizontal components of the momentum transfer vector. NOTE: X, Y, Z, DX, L, dr, qv, qh, ql are the numpy arrays with shape=(2*hmax+1, 2*kmax+1, 2*lmax+1), evald_rad is a scalar

Function pyimgalgos.FiberIndexing.reciprocal_from_bravias

pyimgalgos.FiberIndexing.reciprocal_from_bravias(a1, a2, a3)[source]

Returns reciprocal primitive vectors from 3-d Bravias primitive vectors using crystallographer’s definition for conversion as 1/d (2*pi/d - comes from natural physics definition).

Function pyimgalgos.FiberIndexing.rotation

pyimgalgos.FiberIndexing.rotation(X, Y, angle_deg)[source]

For numpy arrays X and Y returns the numpy arrays of Xrot and Yrot rotated by angle_deg

Function pyimgalgos.FiberIndexing.rotation_cs

pyimgalgos.FiberIndexing.rotation_cs(X, Y, c, s)[source]

For numpy arrays X and Y returns the numpy arrays of Xrot and Yrot for specified rotation angle cosine and sine values.

Function pyimgalgos.FiberIndexing.round_vzeros

pyimgalgos.FiberIndexing.round_vzeros(v, d=10)[source]

Returns input vector with rounded to zero components which precision less than requested number of digits.

Function pyimgalgos.FiberIndexing.str_omega_drhkl

pyimgalgos.FiberIndexing.str_omega_drhkl(ind, beta_deg, omega_deg, dr, r, qv, qh, h, k, l, sigma_ql)[source]

Returns the record to save in look-up table or print.

Function pyimgalgos.FiberIndexing.test_lattice

pyimgalgos.FiberIndexing.test_lattice(b1=(1.0, 0.0, 0.0), b2=(0.0, 1.0, 0.0), b3=(0.0, 0.0, 1.0), hmax=3, kmax=2, lmax=1, cdtype=<type 'numpy.float32'>)[source]

Function pyimgalgos.FiberIndexing.triclinic_primitive_vectors

pyimgalgos.FiberIndexing.triclinic_primitive_vectors(a=18.36, b=26.65, c=4.81, alpha=90, beta=90, gamma=102.83)[source]

Returns 3-d (Bravias) primitive vectors directed along crystal axes (edges) from lattice cell edge lengths [Angstrom or other prefered units] and angles [degree] for triclinic crystal cell parametes:

       *----------* 
      / \        / \ 
     /   \      /   \ 
    /     \ gamma    \ 
   /       *----------* 
  /       /  /       / 
 /alpha  /  /       / 
*-------/--*       c 
 \     /    \ beta/ 
  a   /      \   / 
   \ /        \ / 
    *-----b----* 

where a, b, c - crystal cell edge lengths, alpha, beta, gamma - interaxial angles around a, b, c edges, respectively’ By design, a1 vector for edge a is directed along x, a2 vector for edge b is in x-y plane, has (x,y,0) components only, a3 vector for edge c has (x,y,z) components.

Function pyimgalgos.FiberIndexing.wavelength_nm_from_energy_ev

pyimgalgos.FiberIndexing.wavelength_nm_from_energy_ev(E_eV=6000)[source]

Returns wavelength in nm, evaluated from photon energy in eV (1Angstroms = 10**-10m) E=h*v = h*c/lambda 6keV approx. = 2A

Function pyimgalgos.FiberIndexing.wave_vector_value

pyimgalgos.FiberIndexing.wave_vector_value(E_eV=6000)[source]

Returns wave vector/number value k = 1/lambda [1/A] - crystalographer’s definition k = 2*pi/lambda [1/A] - physics definition

Module pyimgalgos.GlobalGraphics

Collection of global graphical methods.

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

Version: $Id: GlobalGraphics.py 12839 2016-11-07 01:27:55Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.GlobalGraphics.drawCenter

pyimgalgos.GlobalGraphics.drawCenter(axes, xy0, s=10, linewidth=1, color='w')[source]

Function pyimgalgos.GlobalGraphics.drawCircle

pyimgalgos.GlobalGraphics.drawCircle(axes, xy0, radius, linewidth=1, color='w', fill=False)[source]

Function pyimgalgos.GlobalGraphics.drawLine

pyimgalgos.GlobalGraphics.drawLine(axes, xarr, yarr, s=10, linewidth=1, color='w')[source]

Function pyimgalgos.GlobalGraphics.drawRectangle

pyimgalgos.GlobalGraphics.drawRectangle(axes, xy, width, height, linewidth=1, color='w')[source]

Function pyimgalgos.GlobalGraphics.fig_axes

pyimgalgos.GlobalGraphics.fig_axes(figsize=(13, 12), title='Image', dpi=80, win_axim=(0.05, 0.03, 0.87, 0.93), win_axcb=(0.923, 0.03, 0.02, 0.93))[source]

Creates and returns figure, and axes for image and color bar

Function pyimgalgos.GlobalGraphics.fig_axim_axcb_imsh

pyimgalgos.GlobalGraphics.fig_axim_axcb_imsh(figsize=(13, 12), title='Image', dpi=80, win_axim=(0.05, 0.03, 0.87, 0.93), win_axcb=(0.923, 0.03, 0.02, 0.93), arr2d=array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), origin='upper')[source]

Creates and returns figure, axes for image and color bar, imshow object

Function pyimgalgos.GlobalGraphics.getArrangedImage

pyimgalgos.GlobalGraphics.getArrangedImage(shape=(40, 60))[source]

Function pyimgalgos.GlobalGraphics.getImageAs2DHist

pyimgalgos.GlobalGraphics.getImageAs2DHist(iX, iY, W=None)[source]

Makes image from iX, iY coordinate index arrays and associated weights, using np.histogram2d(...).

Function pyimgalgos.GlobalGraphics.getImageFromIndexArrays

pyimgalgos.GlobalGraphics.getImageFromIndexArrays(iX, iY, W=None)[source]

Makes image from iX, iY coordinate index arrays and associated weights, using indexed array.

Function pyimgalgos.GlobalGraphics.getRandomImage

pyimgalgos.GlobalGraphics.getRandomImage(mu=200, sigma=25, shape=(40, 60))[source]

Function pyimgalgos.GlobalGraphics.hist1d

pyimgalgos.GlobalGraphics.hist1d(arr, bins=None, amp_range=None, weights=None, color=None, show_stat=True, log=False, figsize=(6, 5), axwin=(0.15, 0.12, 0.78, 0.8), title=None, xlabel=None, ylabel=None, titwin=None)[source]

Makes historgam from input array of values (arr), which are sorted in number of bins (bins) in the range (amp_range=(amin,amax))

Function pyimgalgos.GlobalGraphics.main

pyimgalgos.GlobalGraphics.main()[source]

Function pyimgalgos.GlobalGraphics.move

pyimgalgos.GlobalGraphics.move(x0=200, y0=100)[source]

Function pyimgalgos.GlobalGraphics.move_fig

pyimgalgos.GlobalGraphics.move_fig(fig, x0=200, y0=100)[source]

Function pyimgalgos.GlobalGraphics.plotGraph

pyimgalgos.GlobalGraphics.plotGraph(x, y, figsize=(5, 10), window=(0.15, 0.1, 0.78, 0.86), pfmt='b-', lw=1)[source]

Function pyimgalgos.GlobalGraphics.plotHistogram

pyimgalgos.GlobalGraphics.plotHistogram(arr, amp_range=None, figsize=(6, 6), bins=None, title='', window=(0.15, 0.1, 0.78, 0.82))[source]

Makes historgam from input array of values (arr), which are sorted in number of bins (bins) in the range (amp_range=(amin,amax))

Function pyimgalgos.GlobalGraphics.plotImage

pyimgalgos.GlobalGraphics.plotImage(arr, img_range=None, amp_range=None, figsize=(12, 5), title='Image', origin='upper', window=(0.05, 0.05, 0.95, 0.92), cmap='jet')[source]

Function pyimgalgos.GlobalGraphics.plotImageAndSpectrum

pyimgalgos.GlobalGraphics.plotImageAndSpectrum(arr, amp_range=None)[source]

Function pyimgalgos.GlobalGraphics.plotImageLarge

pyimgalgos.GlobalGraphics.plotImageLarge(arr, img_range=None, amp_range=None, figsize=(12, 10), title='Image', origin='upper', window=(0.05, 0.03, 0.94, 0.94), cmap='jet')[source]

Function pyimgalgos.GlobalGraphics.plot_img

pyimgalgos.GlobalGraphics.plot_img(img, mode=None, amin=None, amax=None)[source]

Function pyimgalgos.GlobalGraphics.plot_imgcb

pyimgalgos.GlobalGraphics.plot_imgcb(fig, axim, axcb, imsh, arr2d, amin=None, amax=None, origin='upper', title=None)[source]

Function pyimgalgos.GlobalGraphics.plot_peaks_on_img

pyimgalgos.GlobalGraphics.plot_peaks_on_img(peaks, axim, iX, iY, color='w', pbits=0, lw=2)[source]

Draws peaks on the top of image axes (axim) Plots peaks from array as circles in coordinates of image.

@param peaks - 2-d list/tuple of peaks; first 6 values in each peak record should be (s, r, c, amax, atot, npix) @param axim - image axes @param iX - array of x-coordinate indexes for all pixels addressed as [s, r, c] - segment, row, column @param iX - array of y-coordinate indexes for all pixels addressed as [s, r, c] - segment, row, column @param color - peak-ring color @param pbits - verbosity; print 0 - nothing, +1 - peak parameters, +2 - x, y peak coordinate indexes

Function pyimgalgos.GlobalGraphics.plotSpectrum

pyimgalgos.GlobalGraphics.plotSpectrum(arr, amp_range=None, figsize=(6, 6))[source]

Function pyimgalgos.GlobalGraphics.save

pyimgalgos.GlobalGraphics.save(fname='img.png', do_save=True, pbits=255)[source]

Function pyimgalgos.GlobalGraphics.savefig

pyimgalgos.GlobalGraphics.savefig(fname='img.png', do_print=True)[source]

Function pyimgalgos.GlobalGraphics.save_fig

pyimgalgos.GlobalGraphics.save_fig(fig, fname='img.png', do_save=True, pbits=255)[source]

Function pyimgalgos.GlobalGraphics.show

pyimgalgos.GlobalGraphics.show(mode=None)[source]

Function pyimgalgos.GlobalGraphics.size_of_shape

pyimgalgos.GlobalGraphics.size_of_shape(shape=(2, 3, 8))[source]

Module pyimgalgos.GlobalUtils

GlobalUtils.py contains collection of global utilities with a single call algorithms.

Usage:

# Import
# ==============
from pyimgalgos.GlobalUtils import subtract_bkgd, mask_from_windows #, ...
from pyimgalgos.NDArrGenerators import random_standard_array

# Background subtraction
# ======================
# Example for cspad, assuming all nda_*.shape = (32,185,388)
winds_bkgd = [ (s, 10, 100, 270, 370) for s in (4,12,20,28)] # use part of segments 4,12,20, and 28 to subtract bkgd
nda = subtract_bkgd(nda_data, nda_bkgd, mask=nda_mask, winds=winds_bkgd, pbits=0)

# Operations with numpy array shape
# =================================
shape = (32,185,388)
size = size_from_shape(shape) # returns 32*185*388   
shape_2d = shape_as_2d(shape) # returns (32*185,388)
arr_2d = reshape_to_2d(nda)   # returns re-shaped ndarray

shape = (4,8,185,388)
shape_3d = shape_as_3d(shape) # returns (32,185,388)
arr_3d = reshape_to_3d(nda)   # returns re-shaped ndarray

# Make mask n-d numpy array using shape and windows
# =================================================
shape = (2,185,388)
w = 1
winds = [(s, w, 185-w, w, 388-w) for s in (0,1)]
mask = mask_from_windows(shape, winds)

# Make mask as 2,3-d numpy array for a few(width) rows/cols of pixels 
# ===================================================================
mask2d = mask_2darr_edges(shape=(185,388), width=2)
mask3d = mask_3darr_edges(shape=(32,185,388), width=5)

# Make mask of local maximal intensity pixels in x-y (ignoring diagonals)
# ===================================================================
# works for 2-d and 3-d arrays only - reshape if needed.

data = random_standard_array(shape=(32,185,388), mu=0, sigma=10)

mask_xy_max = locxymax(data, order=1, mode='clip')

# Get string with time stamp, ex: 2016-01-26T10:40:53
# ===================================================================
ts = str_tstamp(fmt='%Y-%m-%dT%H:%M:%S', time_sec=None)

# Converters for Cheetah
# ======================
runnum, tstamp, tsec, fid = convertCheetahEventName('LCLS_2015_Feb22_r0169_022047_197f7', fmtts='%Y-%m-%dT%H:%M:%S')

table8x8 = table_from_cspad_ndarr(nda_cspad) 
nda_cspad = cspad_ndarr_from_table(table8x8)

# Save math
# =========
res = divide_protected(num, den, vsub_zero=0)

# Single line printed for np.array
# ================================
print_ndarr(nda, name='', first=0, last=5)

# Save image in file
# ==================
image = random_standard()
save_image_tiff(image, fname='image.tiff', verb=True) # 16-bit tiff
save_image_file(image, fname='image.png', verb=True) # gif, pdf, eps, png, jpg, jpeg, tiff (8-bit only)

# Create directory
# ==================
create_directory('work-dir')

# Test
# ======================
# is implemented for test numbers from 1 to 9. Command example
# python pyimgalgos/src/GlobalUtils.py 1

See also: pyimgalgos.GlobalUtils

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

Version: $Id: GlobalUtils.py 11969 2016-05-21 01:30:48Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.GlobalUtils.convertCheetahEventName

pyimgalgos.GlobalUtils.convertCheetahEventName(evname, fmtts='%Y-%m-%dT%H:%M:%S')[source]

Converts Cheetah event name like ‘LCLS_2015_Feb22_r0169_022047_197f7’ and returns runnum, tstamp, tsec, fid = 169, ‘2015-02-22T02:20:47’, <tsec>, 197f7

Function pyimgalgos.GlobalUtils.create_directory

pyimgalgos.GlobalUtils.create_directory(dir)[source]

Function pyimgalgos.GlobalUtils.cspad_ndarr_from_table

pyimgalgos.GlobalUtils.cspad_ndarr_from_table(table8x8)[source]

returns cspad array with shape=(32,185,388) generated from table of 2x1s shaped as (8*185, 4*388) in style of Cheetah

Function pyimgalgos.GlobalUtils.cspad_ndarr_from_table8x8

pyimgalgos.GlobalUtils.cspad_ndarr_from_table8x8(table8x8)

returns cspad array with shape=(32,185,388) generated from table of 2x1s shaped as (8*185, 4*388) in style of Cheetah

Function pyimgalgos.GlobalUtils.divide_protected

pyimgalgos.GlobalUtils.divide_protected(num, den, vsub_zero=0)[source]

Returns result of devision of numpy arrays num/den with substitution of value vsub_zero for zero den elements.

Function pyimgalgos.GlobalUtils.list_of_windarr

pyimgalgos.GlobalUtils.list_of_windarr(nda, winds=None)[source]

Converts 2-d or 3-d numpy array in the list of 2-d numpy arrays for windows @param nda - input 2-d or 3-d numpy array

Function pyimgalgos.GlobalUtils.locxymax

pyimgalgos.GlobalUtils.locxymax(nda, order=1, mode='clip')[source]

For 2-d or 3-d numpy array finds mask of local maxima in x and y axes (diagonals are ignored) using scipy.signal.argrelmax and return their product.

@param nda - input ndarray @param order - range to search for local maxima along each dimension @param mode - parameter of scipy.signal.argrelmax of how to treat the boarder

Function pyimgalgos.GlobalUtils.main

pyimgalgos.GlobalUtils.main()[source]

Function pyimgalgos.GlobalUtils.mask_2darr_edges

pyimgalgos.GlobalUtils.mask_2darr_edges(shape=(185, 388), width=2)[source]

Returns mask with masked width rows/colunms of edge pixels for 2-d numpy array.

Function pyimgalgos.GlobalUtils.mask_3darr_edges

pyimgalgos.GlobalUtils.mask_3darr_edges(shape=(32, 185, 388), width=2)[source]

Returns mask with masked width rows/colunms of edge pixels for 3-d numpy array.

Function pyimgalgos.GlobalUtils.mask_from_windows

pyimgalgos.GlobalUtils.mask_from_windows(ashape=(32, 185, 388), winds=None)[source]

Makes mask as 2-d or 3-d numpy array defined by the shape with ones in windows. N-d shape for N>3 is converted to 3-d. @param shape - shape of the output numpy array with mask. @param winds - list of windows, each window is a sequence of 5 parameters (segment, rowmin, rowmax, colmin, colmax)

Function pyimgalgos.GlobalUtils.mean_of_listwarr

pyimgalgos.GlobalUtils.mean_of_listwarr(lst_warr)[source]

Evaluates the mean value of the list of 2-d arrays. @lst_warr - list of numpy arrays to evaluate per pixel mean intensity value.

Function pyimgalgos.GlobalUtils.print_ndarr

pyimgalgos.GlobalUtils.print_ndarr(nda, name='', first=0, last=5)[source]

Function pyimgalgos.GlobalUtils.reshape_to_2d

pyimgalgos.GlobalUtils.reshape_to_2d(arr)[source]

Returns n-d re-shaped to 2-d

Function pyimgalgos.GlobalUtils.reshape_to_3d

pyimgalgos.GlobalUtils.reshape_to_3d(arr)[source]

Returns n-d re-shaped to 3-d

Function pyimgalgos.GlobalUtils.save_image_file

pyimgalgos.GlobalUtils.save_image_file(image, fname='image.png', verb=False)[source]

Saves files with type by extension gif, pdf, eps, png, jpg, jpeg, tiff (8-bit only), or txt for any other type

Function pyimgalgos.GlobalUtils.save_image_tiff

pyimgalgos.GlobalUtils.save_image_tiff(image, fname='image.tiff', verb=False)[source]

Saves image in 16-bit tiff file

Function pyimgalgos.GlobalUtils.shape_as_2d

pyimgalgos.GlobalUtils.shape_as_2d(sh)[source]

Returns 2-d shape for n-d shape if n>2, otherwise returns unchanged shape.

Function pyimgalgos.GlobalUtils.shape_as_3d

pyimgalgos.GlobalUtils.shape_as_3d(sh)[source]

Returns 3-d shape for n-d shape if n>3, otherwise returns unchanged shape.

Function pyimgalgos.GlobalUtils.size_from_shape

pyimgalgos.GlobalUtils.size_from_shape(shape)[source]

Returns size from the shape sequence

Function pyimgalgos.GlobalUtils.src_from_rc8x8

pyimgalgos.GlobalUtils.src_from_rc8x8(row, col)[source]

Converts Cheetah 8x8 ASICs table row and column to seg, row, col coordinates

Function pyimgalgos.GlobalUtils.str_tstamp

pyimgalgos.GlobalUtils.str_tstamp(fmt='%Y-%m-%dT%H:%M:%S', time_sec=None)[source]

Returns string timestamp for specified format and time in sec or current time by default

Function pyimgalgos.GlobalUtils.subtract_bkgd

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

Subtracts numpy array of bkgd from data using normalization in windows for good pixels in mask. Shapes of data, bkgd, and mask numpy arrays should be the same. Each window is specified by 5 parameters: (segment, rowmin, rowmax, colmin, colmax) For 2-d arrays segment index is not used, but still 5 parameters needs to be specified. @param data - numpy array for data. @param bkgd - numpy array for background. @param mask - numpy array for mask. @param winds - list of windows, each window is a sequence of 5 parameters. @param pbits - print control bits; =0 - print nothing, !=0 - normalization factor.

Function pyimgalgos.GlobalUtils.table8x8_from_cspad_ndarr

pyimgalgos.GlobalUtils.table8x8_from_cspad_ndarr(nda_cspad)

returns table of 2x1s shaped as (8*185, 4*388) in style of Cheetah generated from cspad array with size=(32*185*388) ordered as in data, shape does not matter.

Function pyimgalgos.GlobalUtils.table_from_cspad_ndarr

pyimgalgos.GlobalUtils.table_from_cspad_ndarr(nda_cspad)[source]

returns table of 2x1s shaped as (8*185, 4*388) in style of Cheetah generated from cspad array with size=(32*185*388) ordered as in data, shape does not matter.

Function pyimgalgos.GlobalUtils.test_01

pyimgalgos.GlobalUtils.test_01()[source]

Function pyimgalgos.GlobalUtils.test_02

pyimgalgos.GlobalUtils.test_02()[source]

Function pyimgalgos.GlobalUtils.test_03

pyimgalgos.GlobalUtils.test_03()[source]

Function pyimgalgos.GlobalUtils.test_04

pyimgalgos.GlobalUtils.test_04()[source]

Function pyimgalgos.GlobalUtils.test_05

pyimgalgos.GlobalUtils.test_05()[source]

Function pyimgalgos.GlobalUtils.test_06

pyimgalgos.GlobalUtils.test_06()[source]

Function pyimgalgos.GlobalUtils.test_07

pyimgalgos.GlobalUtils.test_07()[source]

Function pyimgalgos.GlobalUtils.test_08

pyimgalgos.GlobalUtils.test_08()[source]

Function pyimgalgos.GlobalUtils.test_09

pyimgalgos.GlobalUtils.test_09()[source]

Function pyimgalgos.GlobalUtils.test_10

pyimgalgos.GlobalUtils.test_10()[source]

Function pyimgalgos.GlobalUtils.test_11

pyimgalgos.GlobalUtils.test_11()[source]

Function pyimgalgos.GlobalUtils.usage

pyimgalgos.GlobalUtils.usage()[source]

Module pyimgalgos.Graphics

Function pyimgalgos.Graphics.add_axes

pyimgalgos.Graphics.add_axes(fig, axwin=(0.05, 0.03, 0.87, 0.93))[source]

Add axes to figure from input list of windows.

Function pyimgalgos.Graphics.add_title_labels_to_axes

pyimgalgos.Graphics.add_title_labels_to_axes(axes, title=None, xlabel=None, ylabel=None, fslab=14, fstit=20, color='k')[source]

Function pyimgalgos.Graphics.colorbar

pyimgalgos.Graphics.colorbar(fig, imsh, axcb, orientation='vertical', amp_range=None)[source]

orientation = ‘horizontal’ amp_range = (-10,50)

Function pyimgalgos.Graphics.draw

pyimgalgos.Graphics.draw(fig)[source]

Function pyimgalgos.Graphics.draw_fig

pyimgalgos.Graphics.draw_fig(fig)[source]

Function pyimgalgos.Graphics.figure

pyimgalgos.Graphics.figure(figsize=(13, 12), title='Image', dpi=80, facecolor='w', edgecolor='w', frameon=True, move=None)[source]

Creates and returns figure

Function pyimgalgos.Graphics.hist

pyimgalgos.Graphics.hist(axhi, arr, bins=None, amp_range=None, weights=None, color=None, log=False)[source]

Makes historgam from input array of values (arr), which are sorted in number of bins (bins) in the range (amp_range=(amin,amax))

Function pyimgalgos.Graphics.imshow

pyimgalgos.Graphics.imshow(axim, img, amp_range=None, extent=None, interpolation='nearest', aspect='auto', origin='upper', orientation='horizontal', cmap='jet')[source]

extent - list of four image physical limits for labeling, cmap: ‘gray_r’ #axim.cla()

Function pyimgalgos.Graphics.imshow_cbar

pyimgalgos.Graphics.imshow_cbar(fig, axim, axcb, img, amin=None, amax=None, extent=None, interpolation='nearest', aspect='auto', origin='upper', orientation='horizontal', cmap='jet')[source]

extent - list of four image physical limits for labeling, cmap: ‘gray_r’ #axim.cla()

Function pyimgalgos.Graphics.move

pyimgalgos.Graphics.move(x0=200, y0=100)[source]

Function pyimgalgos.Graphics.move_fig

pyimgalgos.Graphics.move_fig(fig, x0=200, y0=100)[source]

Function pyimgalgos.Graphics.save_fig

pyimgalgos.Graphics.save_fig(fig, fname='img.png', verb=True)[source]

Function pyimgalgos.Graphics.save_plt

pyimgalgos.Graphics.save_plt(fname='img.png', verb=True)[source]

Function pyimgalgos.Graphics.set_win_title

pyimgalgos.Graphics.set_win_title(fig, titwin='Image')[source]

Function pyimgalgos.Graphics.show

pyimgalgos.Graphics.show(mode=None)[source]

Function pyimgalgos.Graphics.test01

pyimgalgos.Graphics.test01()[source]

imshow

Function pyimgalgos.Graphics.test02

pyimgalgos.Graphics.test02()[source]

hist

Function pyimgalgos.Graphics.test03

pyimgalgos.Graphics.test03()[source]

Update image in the event loop

Function pyimgalgos.Graphics.test04

pyimgalgos.Graphics.test04()[source]

Update histogram in the event loop

Function pyimgalgos.Graphics.test_all

pyimgalgos.Graphics.test_all()[source]

Function pyimgalgos.Graphics.test_selected

pyimgalgos.Graphics.test_selected()[source]

Module pyimgalgos.HBins

HBins.py histogram-style bin parameters holder

Usage:

from pyimgalgos.HBins import HBins

# Equal bins constructor
hb = HBins((1,6), nbins=5)

# Variable bins constructor
hb = HBins((1,2,4,6,10))

# Access methods
nbins         = hb.nbins()         # returns int input parameter - number of bins
edges         = hb.edges()         # returns np.array input list of bin edges
vmin          = hb.vmin()          # returns vtype minimal value of bin edges
vmax          = hb.vmax()          # returns vtype maximal value of bin edges
vtype         = hb.vtype()         # returns np.dtype - type of bin edge values 
equalbins     = hb.equalbins()     # returns bool True/False for equal/variable size bins 

limits        = hb.limits()        # returns np.array of limits (vmin, vmax)
binedges      = hb.binedges()      # returns np.array with bin edges of size nbins+1 
binedgesleft  = hb.binedgesleft()  # returns np.array with bin left edges of size nbins
binedgesright = hb.binedgesright() # returns np.array with bin rignt edges of size nbins
bincenters    = hb.bincenters()    # returns np.array with bin centers of size nbins
binwidth      = hb.binwidth()      # returns np.array with bin widths of size nbins or scalar bin width for equal bins
halfbinw      = hb.halfbinw()      # returns np.array with half-bin widths of size nbins or scalar bin half-width for equal bins
strrange      = hb.strrange(fmt)   # returns str of formatted vmin, vmax, nbins ex: 1-6-5

ind     = hb.bin_index(value, edgemode=0)      # returns bin index [0,nbins) for value. 
indarr  = hb.bin_indexes(valarr, edgemode=0)   # returns array of bin index [0,nbins) for array of values
# edgemode - defines what to do with underflow overflow indexes;
#          = 0 - use indexes  0 and nbins-1 for underflow overflow, respectively
#          = 1 - use extended indexes -1 and nbins for underflow overflow, respectively

# Print methods
hb.print_attrs_defined()
hb.print_attrs()
hb.print_attrs_and_methods()

See also: pyimgalgos.HPolar, pyimgalgos.HSpectrum, pyimgalgos.NDArrSpectrum, pyimgalgos.RadialBkgd, Radial background.

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

Version: $Id: HBins.py 11999 2016-06-01 21:16:06Z dubrovin@SLAC.STANFORD.EDU $

Created on 2016-01-15

Author: Mikhail S. Dubrovin

Function pyimgalgos.HBins.test

pyimgalgos.HBins.test(o, cmt='')[source]

Function pyimgalgos.HBins.test_bin_indexes

pyimgalgos.HBins.test_bin_indexes(o, vals, edgemode=0, cmt='')[source]

Module pyimgalgos.HPolar

HPolar - makes 2-d histogram in polar (r-phi) coordinates for imaging detector n-d array data

Usage:

# Import
# ------
from pyimgalgos.HPolar import HPolar

# Initialization
# --------------
hp = HPolar(xarr, yarr, mask=None, radedges=None, nradbins=100, phiedges=(0,360), nphibins=32)

# Access methods
# --------------
orb   = hp.obj_radbins() # returns HBins object for radial bins
opb   = hp.obj_phibins() # returns HBins object for angular bins
rad   = hp.pixel_rad()
irad  = hp.pixel_irad()
phi0  = hp.pixel_phi0()
phi   = hp.pixel_phi()
iphi  = hp.pixel_iphi()
iseq  = hp.pixel_iseq()
npix  = hp.bin_number_of_pixels()
int   = hp.bin_intensity(nda)
arr1d = hp.bin_avrg(nda)
arr2d = hp.bin_avrg_rad_phi(nda, do_transp=True)
pixav = hp.pixel_avrg(nda)
pixav = hp.pixel_avrg_interpol(nda, method='linear') # method='nearest' 'cubic'

# Print attributes and n-d arrays
# -------------------------------
hp.print_attrs()
hp.print_ndarrs()

# Global methods
# --------------
from pyimgalgos.HPolar import polarization_factor, divide_protected, cart2polar, polar2cart, bincount

polf = polarization_factor(rad, phi, z)
result = divide_protected(num, den, vsub_zero=0)
r, theta = cart2polar(x, y)
x, y = polar2cart(r, theta)
bin_values = bincount(map_bins, map_weights=None, length=None)

See also: pyimgalgos.HBins, pyimgalgos.RadialBkgd Radial background. pyimgalgos.HSpectrum (pyimgalgos.NDArrSpectrum),

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

Revision: $Revision: 12490 $

Version: $Id: HPolar.py 12490 2016-08-16 17:26:28Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.HPolar.bincount

pyimgalgos.HPolar.bincount(map_bins, map_weights=None, length=None)[source]

Wrapper for numpy.bincount with protection of weights and alattening numpy arrays

Function pyimgalgos.HPolar.cart2polar

pyimgalgos.HPolar.cart2polar(x, y)[source]

For numpy arrays x and y returns the numpy arrays of r and theta

Function pyimgalgos.HPolar.data_geo

pyimgalgos.HPolar.data_geo(ntest)[source]

Method for tests: returns test data numpy array and geometry object

Function pyimgalgos.HPolar.divide_protected

pyimgalgos.HPolar.divide_protected(num, den, vsub_zero=0)[source]

Returns result of devision of numpy arrays num/den with substitution of value vsub_zero for zero den elements.

Function pyimgalgos.HPolar.polar2cart

pyimgalgos.HPolar.polar2cart(r, theta)[source]

For numpy arryys r and theta returns the numpy arrays of x and y

Function pyimgalgos.HPolar.polarization_factor

pyimgalgos.HPolar.polarization_factor(rad, phi_deg, z)[source]

Returns per-pixel polarization factors, assuming that detector is perpendicular to Z.

Function pyimgalgos.HPolar.test01

pyimgalgos.HPolar.test01(ntest, prefix='fig-v01')[source]

Test for radial 1-d binning of entire image.

Function pyimgalgos.HPolar.test02

pyimgalgos.HPolar.test02(ntest, prefix='fig-v01')[source]

Test for 2-d (default) binning of the rad-phi range of entire image

Function pyimgalgos.HPolar.test03

pyimgalgos.HPolar.test03(ntest, prefix='fig-v01')[source]

Test for 2-d binning of the restricted rad-phi range of entire image

Module pyimgalgos.HSpectrum

HSpectrum - support creation of spectral histogram for arbitrary shaped numpy array.

Usage:

# Import
# ==============
from pyimgalgos.HSpectrum import HSpectrum


# Initialization
# ==============
# 1) for bins of equal size:
range = (vmin, vmax)
nbins = 100
spec = HSpectrum(range, nbins)

# 2) for variable size bins:
bins = (v0, v1, v2, v4, v5, vN) # any number of bin edges
spec = HSpectrum(bins)


# Fill spectrum
# ==============
# nda = ... (get it for each event somehow)
spec.fill(nda)


# Get spectrum
# ==============
histarr, edges, nbins = spec.spectrum()


# Optional
# ==============
spec.print_attrs()

See also: pyimgalgos.HBins, pyimgalgos.HPolar

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

Revision: $Revision: 11999 $

Version: $Id: HSpectrum.py 11999 2016-06-01 21:16:06Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.HSpectrum.example_equidistant

pyimgalgos.HSpectrum.example_equidistant()[source]

Function pyimgalgos.HSpectrum.example_varsize

pyimgalgos.HSpectrum.example_varsize()[source]

Function pyimgalgos.HSpectrum.random_standard_array

pyimgalgos.HSpectrum.random_standard_array(shape=(185, 388), mu=50, sigma=10)[source]

Returns n-d array of specified shape with random intensities generated for Gaussian parameters.

Module pyimgalgos.image_crop

User analysis module for pyana and psana frameworks.

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

Version: $Id: image_crop.py 8453 2014-06-20 22:38:14Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class pyimgalgos.image_crop.image_crop

class pyimgalgos.image_crop.image_crop[source]

Get image from the evt store crop it and put it back in the evt store

Class constructor. Parameters are passed from pyana.cfg configuration file. All parameters are passed as strings

@param source string, address of Detector.Id:Device.ID @param key_in string, keyword for input image 2-d array @param key_out string, unique keyword for output image array @param rowmin int, row minimal to crop image (dafault = 0 - for full size) @param rowmax int, row maximal to crop image (dafault = -1 - for full size) @param colmin int, column minimal to crop image (dafault = 0 - for full size) @param colmax int, column maximal to crop image (dafault = -1 - for full size) @param print_bits int, bit-word for verbosity control

begincalibcycle(evt, env)[source]
beginjob(evt, env)[source]
beginrun(evt, env)[source]
endcalibcycle(evt, env)[source]
endjob(evt, env)[source]
endrun(evt, env)[source]
event(evt, env)[source]

This method is called for every L1Accept transition.

@param evt event data object @param env environment object

print_image_parameters()[source]
print_input_pars()[source]

Module pyimgalgos.image_save_in_file

User analysis module

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

Version: $Id: image_save_in_file.py 11271 2016-01-30 00:02:41Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class pyimgalgos.image_save_in_file.image_save_in_file

class pyimgalgos.image_save_in_file.image_save_in_file[source]

Saves image array in file with specified in the name type.

Class constructor. Parameters are passed from pyana.cfg configuration file.

  • source - string, address of Detector.Id:Device.ID
  • key_in - string, keyword for input image array of variable shape
  • ofname - string, output file name (type is selected by extention) supported formats: txt, tiff, gif, pdf, eps, png, jpg, jpeg, npy (default), npz
  • mode - int, 0-save one event per event, >0-length of the ring buffer (or round robin) for event browser
  • delay_sec - int, additional sleep time in sec between events for event browser
  • print_bits - int, bit-word for verbosity control
beginjob(evt, env)[source]
beginrun(evt, env)[source]
endjob(evt, env)[source]
event(evt, env)[source]

This method is called for every L1Accept transition.

  • evt - event data object
  • env - environment object
print_input_pars()[source]
print_part_of_image_array(r1=50, r2=60, c1=100, c2=110)[source]

Module pyimgalgos.MedianFilter

pyimgalgos.MedianFilter.py - contains method median_filter_ndarr and associated code for self test.

Usage:

# Import
# ======
from pyimgalgos.MedianFilter import median_filter_ndarr

#nda = ... should be defined somehow, for example nda = det.calib(evt)
rank=3
nda_med = median_filter_ndarr(nda, rank)

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

Command to test python pyimgalgos/src/MedianFilter.py 3

Also see for details: http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.ndimage.filters.median_filter.html#scipy.ndimage.filters.median_filter

Revision: $Revision: 12470 $

Version: $Id: MedianFilter.py 12470 2016-08-11 21:23:21Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.MedianFilter.example01

pyimgalgos.MedianFilter.example01()[source]

Function pyimgalgos.MedianFilter.example02

pyimgalgos.MedianFilter.example02()[source]

Function pyimgalgos.MedianFilter.example03

pyimgalgos.MedianFilter.example03()[source]

Function pyimgalgos.MedianFilter.footprint_ring

pyimgalgos.MedianFilter.footprint_ring(rank=3)[source]

Ring footprint for scipy.ndimage.filters.median_filter rank : int - radial parameter, pixels within radius less or equal rank will be used to evaluate the median.

Function pyimgalgos.MedianFilter.main

pyimgalgos.MedianFilter.main()[source]

Function pyimgalgos.MedianFilter.median_filter_ndarr

pyimgalgos.MedianFilter.median_filter_ndarr(nda_in, rank=3)[source]

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

Parameters - nda_in : numpy.array - n-dimensional numpy array - rank : int - radial parameter, pixels within radius less or equal rank will be used to evaluate the median.

use scipy.ndimage.filters.median_filter(input, size=None, footprint=None, output=None, mode=’reflect’, cval=0.0, origin=0) http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.ndimage.filters.median_filter.html#scipy.ndimage.filters.median_filter

Function pyimgalgos.MedianFilter.random_standard_ndarr

pyimgalgos.MedianFilter.random_standard_ndarr(shape=(185, 388), mu=50, sigma=10, dtype=<type 'float'>)[source]

Returns n-d array of specified shape with random intensities generated for Gaussian parameters.

Function pyimgalgos.MedianFilter.reshape_nda_to_3d

pyimgalgos.MedianFilter.reshape_nda_to_3d(arr)[source]

Reshape np.array to 3-d

Function pyimgalgos.MedianFilter.slope_2darr

pyimgalgos.MedianFilter.slope_2darr(shape=(185, 388), axis=0, dtype=<type 'float'>)[source]

Returns n-d array monotonicly raising along axis=0 or 1

Function pyimgalgos.MedianFilter.usage

pyimgalgos.MedianFilter.usage()[source]

Module pyimgalgos.NDArrGenerators

Created on Nov 23, 2015

@author: Mikhail

Function pyimgalgos.NDArrGenerators.add_random_peaks

pyimgalgos.NDArrGenerators.add_random_peaks(arr2d, npeaks=10, amean=100, arms=50, wmean=2, wrms=0.1)[source]

Returns 2-d array with peaks.

Function pyimgalgos.NDArrGenerators.add_ring

pyimgalgos.NDArrGenerators.add_ring(arr2d, amp=100, row=4.3, col=5.8, rad=100, sigma=3)[source]

Adds peak Gaussian-shaped peak intensity to numpy array arr2d Parameters ———- arr2d : np.array - 2-d numpy array amp : float - ring intensity row : float - ring center row col : float - ring center col rad : float - ring mean radius sigma : float - width of the peak

Function pyimgalgos.NDArrGenerators.aranged_array

pyimgalgos.NDArrGenerators.aranged_array(shape=(40, 60), dtype=<type 'numpy.uint32'>)[source]

Returns numpy array of requested shape and type filling with ascending integer numbers.

Function pyimgalgos.NDArrGenerators.print_ndarr

pyimgalgos.NDArrGenerators.print_ndarr(nda, name='', first=0, last=5)[source]

Prints array attributes, title, and a few elements in a single line.

Function pyimgalgos.NDArrGenerators.prod_of_elements

pyimgalgos.NDArrGenerators.prod_of_elements(arr, dtype=<type 'int'>)[source]

Returns product of sequence elements

Function pyimgalgos.NDArrGenerators.random_1

pyimgalgos.NDArrGenerators.random_1(shape=(40, 60), dtype=<type 'float'>)

Returns numpy array of requested shape and type filled with random numbers in the range [0,255].

Function pyimgalgos.NDArrGenerators.random_256

pyimgalgos.NDArrGenerators.random_256(shape=(40, 60), dtype=<type 'numpy.uint8'>)[source]

Returns numpy array of requested shape and type filled with random numbers in the range [0,255].

Function pyimgalgos.NDArrGenerators.random_exponential

pyimgalgos.NDArrGenerators.random_exponential(shape=(40, 60), a0=100, dtype=<type 'float'>)[source]

Returns numpy array of requested shape and type filled with exponential distribution for width a0.

Function pyimgalgos.NDArrGenerators.random_one

pyimgalgos.NDArrGenerators.random_one(shape=(40, 60), dtype=<type 'float'>)[source]

Returns numpy array of requested shape and type filled with random numbers in the range [0,255].

Function pyimgalgos.NDArrGenerators.random_standard

pyimgalgos.NDArrGenerators.random_standard(shape=(40, 60), mu=200, sigma=25, dtype=<type 'float'>)[source]

Returns numpy array of requested shape and type filled with normal distribution for mu and sigma.

Function pyimgalgos.NDArrGenerators.random_xffffffff

pyimgalgos.NDArrGenerators.random_xffffffff(shape=(40, 60), dtype=<type 'numpy.uint32'>, add=4278190080)[source]

Returns numpy array of requested shape and type filled with random numbers in the range [0,0xffffff] with bits 0xff000000 for alpha mask.

Function pyimgalgos.NDArrGenerators.reshape_to_2d

pyimgalgos.NDArrGenerators.reshape_to_2d(arr)[source]

Returns n-d re-shaped to 2-d

Function pyimgalgos.NDArrGenerators.reshape_to_3d

pyimgalgos.NDArrGenerators.reshape_to_3d(arr)[source]

Returns n-d re-shaped to 3-d

Function pyimgalgos.NDArrGenerators.ring_intensity

pyimgalgos.NDArrGenerators.ring_intensity(r, r0, sigma)[source]

returns numpy array with ring intensity distribution modulated by Gaussian(r-r0,sigma). Parameters ———- r : np.array - numpy array of radius (i.e. radios for each pixel) r0 : float - radius of the ring sigma : float - width of the ring

Function pyimgalgos.NDArrGenerators.shape_as_2d

pyimgalgos.NDArrGenerators.shape_as_2d(sh)[source]

Returns 2-d shape for n-d shape if n>2, otherwise returns unchanged shape.

Function pyimgalgos.NDArrGenerators.shape_as_3d

pyimgalgos.NDArrGenerators.shape_as_3d(sh)[source]

Returns 3-d shape for n-d shape if n>3, otherwise returns unchanged shape.

Function pyimgalgos.NDArrGenerators.size_from_shape

pyimgalgos.NDArrGenerators.size_from_shape(shape)[source]

Returns size from the shape sequence

Module pyimgalgos.NDArrSpectrum

NDArrSpectrum - ALIAS FOR HSpectrum - support creation of spectral histogram for arbitrary shaped numpy array.

Usage:

# Import
# ==============
from pyimgalgos.NDArrSpectrum import NDArrSpectrum


# Initialization
# ==============
# 1) for bins of equal size:
range = (vmin, vmax)
nbins = 100
spec = NDArrSpectrum(range, nbins)

# 2) for variable size bins:
bins = (v0, v1, v2, v4, v5, vN) # any number of bin edges
spec = NDArrSpectrum(bins)


# Fill spectrum
# ==============
# nda = ... (get it for each event somehow)
spec.fill(nda)


# Get spectrum
# ==============
histarr, edges, nbins = spec.spectrum()


# Optional
# ==============
spec.print_attrs()

See also: pyimgalgos.HSpectrum, pyimgalgos.HBins pyimgalgos.HPolar

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

Revision: $Revision: 11999 $

Version: $Id: NDArrSpectrum.py 11999 2016-06-01 21:16:06Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module pyimgalgos.NDArrSpectrumV0

NDArrSpectrum - support creation of spectral histogram for arbitrary shaped numpy array.

Usage:

# Import
# ==============
from pyimgalgos.NDArrSpectrum import NDArrSpectrum


# Initialization
# ==============
# 1) for bins of equal size:
     range = (vmin, vmax)
     nbins = 100
     spec = NDArrSpectrum(range, nbins)
# 2) for variable size bins:
     bins = (v0, v1, v2, ..., v<n-1>, n<n>) 
     spec = NDArrSpectrum(bins)


# Fill spectrum
# ==============
nda = ... (get it for each event somehow)
spec.fill(nda)


# Get spectrum
# ==============
histarr, edges, nbins = spec.spectrum()


# Optional
# ==============
spec.print_attrs()

See also: pyimgalgos.NDArrSpectrum

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

Revision: $Revision: 11959 $

Version: $Id: NDArrSpectrumV0.py 11959 2016-05-19 23:45:39Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.NDArrSpectrumV0.arr_bin_indexes

pyimgalgos.NDArrSpectrumV0.arr_bin_indexes(arr, vmin, vmax, nbins)[source]

Evaluates pixel intensity indexes for spectral histogram in case of equidistant nbins in the range [vmin, vmax].

Function pyimgalgos.NDArrSpectrumV0.arr_varbin_indexes

pyimgalgos.NDArrSpectrumV0.arr_varbin_indexes(arr, edges)[source]

Evaluates pixel intensity indexes for spectral histogram in case of variable size bins. For histogram with N bins: number of boarders is N+1, and indexes are in range [0,N-1].

Function pyimgalgos.NDArrSpectrumV0.example_equidistant

pyimgalgos.NDArrSpectrumV0.example_equidistant()[source]

Function pyimgalgos.NDArrSpectrumV0.example_varsize

pyimgalgos.NDArrSpectrumV0.example_varsize()[source]

Function pyimgalgos.NDArrSpectrumV0.main

pyimgalgos.NDArrSpectrumV0.main()[source]

Function pyimgalgos.NDArrSpectrumV0.random_standard_array

pyimgalgos.NDArrSpectrumV0.random_standard_array(shape=(185, 388), mu=50, sigma=10)[source]

Returns n-d array of specified shape with random intensities generated for Gaussian parameters.

Function pyimgalgos.NDArrSpectrumV0.usage

pyimgalgos.NDArrSpectrumV0.usage()[source]

Module pyimgalgos.NDArrSpectrumV1

NDArrSpectrum - support creation of spectral histogram for arbitrary shaped numpy array.

Usage:

# Import
# ==============
from pyimgalgos.NDArrSpectrum import NDArrSpectrum


# Initialization
# ==============
# 1) for bins of equal size:
range = (vmin, vmax)
nbins = 100
spec = NDArrSpectrum(range, nbins)

# 2) for variable size bins:
bins = (v0, v1, v2, v4, v5, vN) # any number of bin edges
spec = NDArrSpectrum(bins)


# Fill spectrum
# ==============
# nda = ... (get it for each event somehow)
spec.fill(nda)


# Get spectrum
# ==============
histarr, edges, nbins = spec.spectrum()


# Optional
# ==============
spec.print_attrs()

See also: pyimgalgos.HBins, pyimgalgos.HPolar

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

Revision: $Revision: 11999 $

Version: $Id: NDArrSpectrumV1.py 11999 2016-06-01 21:16:06Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.NDArrSpectrumV1.example_equidistant

pyimgalgos.NDArrSpectrumV1.example_equidistant()[source]

Function pyimgalgos.NDArrSpectrumV1.example_varsize

pyimgalgos.NDArrSpectrumV1.example_varsize()[source]

Function pyimgalgos.NDArrSpectrumV1.main

pyimgalgos.NDArrSpectrumV1.main()[source]

Function pyimgalgos.NDArrSpectrumV1.random_standard_array

pyimgalgos.NDArrSpectrumV1.random_standard_array(shape=(185, 388), mu=50, sigma=10)[source]

Returns n-d array of specified shape with random intensities generated for Gaussian parameters.

Function pyimgalgos.NDArrSpectrumV1.usage

pyimgalgos.NDArrSpectrumV1.usage()[source]

Module pyimgalgos.PeakStore

Class helps to save text file with information about peaks found in peak-finders.

Usage:

# Imports
from pyimgalgos.PeakStore import PeakStore

# Usage with psana types env and evt

pstore = PeakStore(env, 5, prefix='xxx', add_header='TitV1 TitV2 TitV3 ...', pbits=255)
for peak in peaks :
    rec = '%s %d %f ...' % (peak[0], peak[5], peak[7],...)
    pstore.save_peak(evt, rec)
pstore.close() # is done by default in destructor


# Usage without psana types

pstore = PeakStore('expNNNNN', 5, prefix='xxx', add_header='TitV1 TitV2 TitV3 ...', pbits=255)
for peak in peaks :
    rec = '%s %d %f ...' % (peak[0], peak[5], peak[7],...)
    pstore.save_peak(peak_rec=rec)

# Print methods
pstore.print_attrs()

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

Version: $Id: PeakStore.py 10975 2015-11-14 01:29:46Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.PeakStore.test_PeakStore

pyimgalgos.PeakStore.test_PeakStore()[source]

Module pyimgalgos.RadialBkgd

RadialBkgd - radial background subtraction for imaging detector n-d array data,
extension of the base class HPolar for methods subtract_bkgd and subtract_bkgd_interpol.

Usage:

# Import
# ------
from pyimgalgos.RadialBkgd import RadialBkgd

# Initialization
# --------------
rb = RadialBkgd(xarr, yarr, mask=None, radedges=None, nradbins=100, phiedges=(0,360), nphibins=32)

# Access methods
# --------------
orb   = rb.obj_radbins() # returns HBins object for radial bins
opb   = rb.obj_phibins() # returns HBins object for angular bins
rad   = rb.pixel_rad()
irad  = rb.pixel_irad()
phi0  = rb.pixel_phi0()
phi   = rb.pixel_phi()
iphi  = rb.pixel_iphi()
iseq  = rb.pixel_iseq()
npix  = rb.bin_number_of_pixels()
int   = rb.bin_intensity(nda)
arr1d = rb.bin_avrg(nda)
arr2d = rb.bin_avrg_rad_phi(nda, do_transp=True)
pixav = rb.pixel_avrg(nda)
pixav = rb.pixel_avrg_interpol(nda, method='linear') # method='nearest' 'cubic'
cdata = rb.subtract_bkgd(nda)
cdata = rb.subtract_bkgd_interpol(nda, method='linear')

# Print attributes and n-d arrays
# -------------------------------
rb.print_attrs()
rb.print_ndarrs()

# Global methods
# --------------
from pyimgalgos.RadialBkgd import polarization_factor, divide_protected, cart2polar, polar2cart, bincount

polf = polarization_factor(rad, phi, z)
result = divide_protected(num, den, vsub_zero=0)
r, theta = cart2polar(x, y)
x, y = polar2cart(r, theta)
bin_values = bincount(map_bins, map_weights=None, length=None)

See also: pyimgalgos.HPolar pyimgalgos.HBins See Radial background. pyimgalgos.HSpectrum

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

Revision: $Revision: 12490 $

Version: $Id: RadialBkgd.py 12490 2016-08-16 17:26:28Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.RadialBkgd.data_geo

pyimgalgos.RadialBkgd.data_geo(ntest)[source]

Returns test data numpy array and geometry object

Function pyimgalgos.RadialBkgd.test01

pyimgalgos.RadialBkgd.test01(ntest, prefix='fig-v01')[source]

Test for radial 1-d binning of entire image.

Function pyimgalgos.RadialBkgd.test02

pyimgalgos.RadialBkgd.test02(ntest, prefix='fig-v01')[source]

Test for 2-d (default) binning of the rad-phi range of entire image

Function pyimgalgos.RadialBkgd.test03

pyimgalgos.RadialBkgd.test03(ntest, prefix='fig-v01')[source]

Test for 2-d binning of the restricted rad-phi range of entire image

Module pyimgalgos.RadialBkgdV0

RadialBkgd - radial background subtraction for imaging detector n-d array data

Usage:

# Import
# ------
from pyimgalgos.RadialBkgd import RadialBkgd

# Initialization
# --------------
rb = RadialBkgd(xarr, yarr, mask=None, radedges=None, nradbins=100, phiedges=(0,360), nphibins=32)

# Access methods
# --------------
orb   = rb.obj_radbins() # returns HBins object for radial bins
opb   = rb.obj_phibins() # returns HBins object for angular bins
rad   = rb.pixel_rad()
irad  = rb.pixel_irad()
phi0  = rb.pixel_phi0()
phi   = rb.pixel_phi()
iphi  = rb.pixel_iphi()
iseq  = rb.pixel_iseq()
npix  = rb.npixels_per_bin()
int   = rb.intensity_per_bin(nda)
arr   = rb.average_per_bin(nda)
arr   = rb.average_rad_phi(nda, do_transp=True)
bkgd  = rb.bkgd_nda(nda)
bkgd  = rb.bkgd_nda_interpol(nda, method='linear') # method='nearest' 'cubic'
cdata = rb.subtract_bkgd(nda)
cdata = rb.subtract_bkgd_interpol(nda, method='linear')


# Print attributes and n-d arrays
# -------------------------------
rb.print_attrs()
rb.print_ndarrs()

# Global methods
# --------------
from pyimgalgos.RadialBkgd import polarization_factor

polf = polarization_factor(rad, phi, z)
result = divide_protected(num, den, vsub_zero=0)
r, theta = cart2polar(x, y)
x, y = polar2cart(r, theta)
bin_values = bincount(map_bins, map_weights=None, length=None)

See also: pyimgalgos.RadialBkgd See Radial background.

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

Revision: $Revision: 11999 $

Version: $Id: RadialBkgdV0.py 11999 2016-06-01 21:16:06Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.RadialBkgdV0.bincount

pyimgalgos.RadialBkgdV0.bincount(map_bins, map_weights=None, length=None)[source]

Wrapper for numpy.bincount with protection of weights and alattening numpy arrays

Function pyimgalgos.RadialBkgdV0.cart2polar

pyimgalgos.RadialBkgdV0.cart2polar(x, y)[source]

For numpy arrays x and y returns the numpy arrays of r and theta

Function pyimgalgos.RadialBkgdV0.data_geo

pyimgalgos.RadialBkgdV0.data_geo(ntest)[source]

Returns test data numpy array and geometry object

Function pyimgalgos.RadialBkgdV0.divide_protected

pyimgalgos.RadialBkgdV0.divide_protected(num, den, vsub_zero=0)[source]

Returns result of devision of numpy arrays num/den with substitution of value vsub_zero for zero den elements.

Function pyimgalgos.RadialBkgdV0.polar2cart

pyimgalgos.RadialBkgdV0.polar2cart(r, theta)[source]

For numpy arryys r and theta returns the numpy arrays of x and y

Function pyimgalgos.RadialBkgdV0.polarization_factor

pyimgalgos.RadialBkgdV0.polarization_factor(rad, phi_deg, z)[source]

Returns per-pixel polarization factors, assuming that detector is perpendicular to Z.

Function pyimgalgos.RadialBkgdV0.test01

pyimgalgos.RadialBkgdV0.test01(ntest)[source]

Test for radial 1-d binning of entire image.

Function pyimgalgos.RadialBkgdV0.test02

pyimgalgos.RadialBkgdV0.test02(ntest)[source]

Test for 2-d (default) binning of the rad-phi range of entire image

Function pyimgalgos.RadialBkgdV0.test03

pyimgalgos.RadialBkgdV0.test03(ntest)[source]

Test for 2-d binning of the restricted rad-phi range of entire image

Module pyimgalgos.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 8453 2014-06-20 22:38:14Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhai S. Dubrovin

Module pyimgalgos.tahometer

User analysis module

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

Version: $Id: tahometer.py 8453 2014-06-20 22:38:14Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class pyimgalgos.tahometer.tahometer

class pyimgalgos.tahometer.tahometer[source]

Saves image array in file with specified in the name type.

Class constructor. Parameters are passed from pyana.cfg configuration file.

@param dn int, interval in number of events to print current statistics @param print_bits int, bit-word for verbosity control

beginjob(evt, env)[source]
beginrun(evt, env)[source]
endjob(evt, env)[source]
event(evt, env)[source]

This method is called for every L1Accept transition.

@param evt event data object @param env environment object

print_event_record()[source]
print_input_pars()[source]

Module pyimgalgos.TDCheetahPeakRecord

Class helps to retreive and use peak data in processing

Usage:

# Imports
from pyimgalgos.TDCheetahPeakRecord import TDCheetahPeakRecord

# Usage

# make object
rec = TDCheetahPeakRecord(line)

# access peak attributes
rec.line
rec.fields        

rec.frameNumber
rec.runnum
rec.tstamp
rec.fid
rec.photonEnergyEv
rec.wavelengthA
rec.GMD
rec.peak_index
rec.peak_x_raw
rec.peak_y_raw
rec.peak_r_assembled
rec.peak_q
rec.peak_resA
rec.nPixels
rec.totalIntensity
rec.maxIntensity
rec.sigmaBG
rec.SNR
rec.tsec

# print attributes
rec.print_peak_data()
rec.print_peak_data_short()
rec.print_attrs()

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

Version: $Id: TDCheetahPeakRecord.py 11634 2016-04-05 18:47:50Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module pyimgalgos.TDFileContainer

TDFileContainer - text/table data file container - load/hold/provide access to data from text file.

It is assumed that text data file contains records of the same format and occasionally record-header beginning with character # (hash in [0] position). Example of the file content:

# Exp     Run  Date       Time      time(sec)   time(nsec) fiduc  Evnum  Reg  Seg  Row  Col  ...
cxif5315  169  2015-02-22 02:20:47  1424600447  486382070  104421     0  EQU   17  153   48  ...
cxif5315  169  2015-02-22 02:20:47  1424600447  494719789  104424     1  EQU    1  161   32  ...
cxif5315  169  2015-02-22 02:20:47  1424600447  494719789  104424     1  EQU   17  170   51  ...
cxif5315  169  2015-02-22 02:20:47  1424600447  503058551  104427     2  EQU   25  170  310  ...
cxif5315  169  2015-02-22 02:20:47  1424600447  503058551  104427     2  EQU   25  180  292  ...
cxif5315  169  2015-02-22 02:20:47  1424600447  511393301  104430     3  EQU    1  162   27  ...
cxif5315  169  2015-02-22 02:20:47  1424600447  536405573  104439     6  ARC    8   11   41  ...
cxif5315  169  2015-02-22 02:20:47  1424600447  536405573  104439     6  ARC    8   10   20  ...
...

Header (without #) should have the same as data number of literal fields separated by spaces. Records in the file should be grupped by unique group-id parameter, for example a group of records may have the same group number or some unique index.

Originaly it is designed to work with text file containing record data generated by peak-finder. It is adopted to work with any other object type beside peak data.

Usage:

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

# Import
from pyimgalgos.TDFileContainer     import TDFileContainer
from pyimgalgos.TDPeakRecord        import TDPeakRecord # use it by default in TDFileContainer
from pyimgalgos.TDNodeRecord        import TDNodeRecord
from pyimgalgos.TDCheetahPeakRecord import TDCheetahPeakRecord

# Initialization
# for peakfinder records
fname = '/reg/neh/home1/dubrovin/LCLS/rel-mengning/work/pfv2-cxif5315-r0169-2015-09-14T14:28:04.txt'
fc = TDFileContainer(fname, indhdr='Evnum', objtype=TDPeakRecord, pbits=0)

# for index table:
fc = TDFileContainer(fname, indhdr='index', objtype=TDNodeRecord)

# for Cheetah file with peaks:
fc = TDFileContainer(fname, indhdr='frameNumber', objtype=TDCheetahPeakRecord)

gr_nums = fc.group_numbers()
ngrps   = fc.number_of_groups()
grnum   = fc.current_group_number()

gr_curr = fc.group(grpnum) # returns current or specified group
gr_next = fc.next()        # returns next group
gr_prev = fc.previous()    # returns previous group
hdr     = fc.header()        

# Print
fc.print_attrs()
fc.print_content(nlines=None) # prints nline (or all by default) lines from file conteiner

# ____________________________________

# Example of iterations over groups
for grnum in fc.group_num_iterator() :
    group = fc.next()
    group.print_attrs()
    peaks = group.get_objs()

    for pk in peaks :
        pk.print_short()

        # Information available through the TDPeakRecord object pk
        # ________________________________________________________
        # pk.exp, pk.run, pk.evnum, pk.reg
        # pk.date, pk.time, pk.tsec, pk.tnsec, pk.fid
        # pk.seg, pk.row, pk.col, pk.amax, pk.atot, pk.npix
        # pk.rcent, pk.ccent, pk.rsigma, pk.csigma
        # pk.rmin, pk.rmax, pk.cmin, pk.cmax
        # pk.bkgd, pk.rms, pk.son
        # pk.imrow, pk.imcol
        # pk.x, pk.y, pk.r, pk.phi
        # pk.sonc
        # pk.dphi000
        # pk.dphi180
        # pk.line

# Example of direct access to group by its number
grpnum = 8 # but grpnum is not necessaraly conecutive number, it should be in fc.group_num_iterator() ...
group = fc.group(grpnum) # returns current or specified group
group.print_attrs()

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

See also: classes

pyimgalgos.TDFileContainer - file records container.

pyimgalgos.TDGroup - holds a list of records associated with a single group.

pyimgalgos.TDPeakRecord - provides access to the peak record.

pyimgalgos.TDNodeRecord - provides access to the look-up table with crystal orientation record.

pyimgalgos.TDCheetahPeakRecord - provides access to the Cheetah peak record.

Version: $Id: TDFileContainer.py 11634 2016-04-05 18:47:50Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.TDFileContainer.do_work

pyimgalgos.TDFileContainer.do_work()[source]

Test

Module pyimgalgos.TDGroup

TDGroup - text data event information holder/accessor class.

Works together with TDFileContainer and TDPeakRecord classes.

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

See also: TDFileContainer - loads/holds text data from class and provides per-event-indexed access. See also: TDPeakRecord - holds a list of records associated with a single event.

Version: $Id: TDGroup.py 11634 2016-04-05 18:47:50Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module pyimgalgos.TDMatchRecord

Class helps to retreive and use peak data in processing

Usage:

# import
from pyimgalgos.TDMatchRecord import TDMatchRecord

# make object
rec = TDMatchRecord(line)

# access record attributes
index, beta, omega, h, k, l, dr, R, qv, qh, P =    rec.index, rec.beta, rec.omega, rec.h, rec.k, rec.l, rec.dr, rec.R, rec.qv, rec.qh, rec.P
line = rec.line

# print attributes
rec.print_short()

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

Version: $Id: TDMatchRecord.py 11902 2016-05-13 22:37:49Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module pyimgalgos.TDNodeRecord

Class helps to retreive and use peak data in processing

Usage:

# Import
from pyimgalgos.TDNodeRecord import TDNodeRecord

# make object
rec = TDNodeRecord(line)

# access record attributes
index, beta, omega, h, k, l, dr, R, qv, qh, P =    rec.index, rec.beta, rec.omega, rec.h, rec.k, rec.l, rec.dr, rec.R, rec.qv, rec.qh, rec.P
line = rec.line

# print attributes
rec.print_short()

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

Version: $Id: TDNodeRecord.py 11902 2016-05-13 22:37:49Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module pyimgalgos.TDPeakRecord

Class helps to retreive and use peak data in processing

Usage:

# Imports
from pyimgalgos.TDPeakRecord import TDPeakRecord

# Usage

# make object
pk = TDPeakRecord(line)

# access peak attributes
exp  = pk.exp  # (str)   experiment name
run  = pk.run  # (int)   run number
son  = pk.son  # (float) S/N for pixel with maximal intensity 
sonc = pk.sonc # (float) S/N for all pixels included in the peak
line = pk.line # (str)   entire record with peak data
...

# Information available through the TDPeakRecord object pk
# ____________________________________________________
# pk.exp, pk.run, pk.evnum, pk.reg
# pk.date, pk.time, pk.tsec, pk.tnsec, pk.fid
# pk.seg, pk.row, pk.col, pk.amax, pk.atot, pk.npix
# pk.rcent, pk.ccent, pk.rsigma, pk.csigma
# pk.rmin, pk.rmax, pk.cmin, pk.cmax
# pk.bkgd, pk.rms, pk.son
# pk.imrow, pk.imcol
# pk.x, pk.y, pk.r, pk.phi
# pk.sonc
# pk.dphi000
# pk.dphi180
# pk.line

# get evaluated parameters
# pk.peak_signal()
# pk.peak_noise()
# pk.peak_son()

# for peak records with fit information:
# pk.fit_phi, pk.fit_beta
# pk.fit_phi_err, pk.fit_beta_err
# pk.fit_chi2, pk.fit_ndof, pk.fit_prob
        
# print attributes
pk.print_peak_data()
pk.print_peak_data_short()
pk.print_attrs()

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

Version: $Id: TDPeakRecord.py 11902 2016-05-13 22:37:49Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module pyimgalgos.TestImageGenerator

TestImageGenerator - a set of methods to generate test images as numpy arrays

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

Version: $Id: TestImageGenerator.py 8800 2014-08-19 06:12:58Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function pyimgalgos.TestImageGenerator.cspad2x1_arr

pyimgalgos.TestImageGenerator.cspad2x1_arr()[source]

returns test np.array for cspad 2x1

Function pyimgalgos.TestImageGenerator.cspad_nparr

pyimgalgos.TestImageGenerator.cspad_nparr(n2x1=32, pbits=255)[source]

returns test np.array for cspad

Function pyimgalgos.TestImageGenerator.gaussian

pyimgalgos.TestImageGenerator.gaussian(r, r0, sigma)[source]

Function pyimgalgos.TestImageGenerator.main

pyimgalgos.TestImageGenerator.main()[source]

Function pyimgalgos.TestImageGenerator.monotonicly_rising

pyimgalgos.TestImageGenerator.monotonicly_rising(shape=(10, 10), dtype=<type 'numpy.float32'>)[source]

Returns monotonicly rising image intensity along the diagonal

Function pyimgalgos.TestImageGenerator.peaks_on_ring

pyimgalgos.TestImageGenerator.peaks_on_ring(shape=(1300, 1340), npeaks=3)[source]

Generates the cortesian 2D array with ring-distributed intensity

Function pyimgalgos.TestImageGenerator.random_exponential

pyimgalgos.TestImageGenerator.random_exponential(shape=(1300, 1340), a0=100, pbits=255)[source]

Function pyimgalgos.TestImageGenerator.random_normal

pyimgalgos.TestImageGenerator.random_normal(shape=(1300, 1340), mu=200, sigma=25, pbits=255)[source]

Function pyimgalgos.TestImageGenerator.rings_sinc

pyimgalgos.TestImageGenerator.rings_sinc(shape=(1024, 1024), pbits=255)[source]

Function pyimgalgos.TestImageGenerator.ring_xy_random

pyimgalgos.TestImageGenerator.ring_xy_random(shape=(1300, 1340))[source]

Generates the cortesian 2D array with ring-distributed intensity