Welcome to BunchAnalyzer’s documentation!

Contents:

Bunch Analyzer v0.6.0

BunchAnalyzer is a data analyzer for particle simulations. It gives access to efficient analytic tools written in python implementing libraries such as Numpy and Scipy Some of the tools contain the ability to redefine axes, however this is not fully supported yet, localMax and localMin return new axes, which are so far only supported by some primitive plotting functions

To use main functions: “import BunchAnalyzer.Bunches” or “from BunchAnalyzer import *” then use Bunches.<function>

There are known bugs on linux with segmentFFT, this is still alpha.

Bunches – functions

BunchAnalyzer.Bunches.Bunches.convertTo2DArray(genArray)

Converts generator array to array of python arrays

BunchAnalyzer.Bunches.Bunches.convertToNumpyArray(genArray)

Converts generator array to array of numpy arrays

BunchAnalyzer.Bunches.Bunches.getFFTSegmentPeaks(dataArray, segments=1, segmentEnds=, []normalizeFFTAxis=True, peaks=1)

Returns an array of peaks for each segmented fft entry in the dataset

BunchAnalyzer.Bunches.Bunches.getFFTSegmentShiftInBunchBySegment(dataArray, segments=1, segmentEnds=, []normalizeFFTAxis=True, peaks=1)

Returns difference between peak values between bunches by segment

BunchAnalyzer.Bunches.Bunches.getFFTSegmentShiftInSegmentByBunch(dataArray, segments=1, segmentEnds=, []normalizeFFTAxis=True, peaks=1)

Returns difference between peak values between segments by bunch

BunchAnalyzer.Bunches.Bunches.highestValues(dataset, axes=None, maxes=1)

Returns the x highest values in each item in the dataset returns dictionary {value:xpos}

BunchAnalyzer.Bunches.Bunches.highestValuesInDataArray(dataArrays, axes=None, maxes=1)

Makes new data set with only values wherein each adjacent value is greater than or equal to the value returns new data set and appropriate axes

BunchAnalyzer.Bunches.Bunches.localMax(parsedDataArray, resolution=1)

Makes new data set with only values wherein each adjacent value is less than or equal to the value returns new data set and appropriate axes

BunchAnalyzer.Bunches.Bunches.localMin(parsedDataArray, resolution=1)

Makes new data set with only values wherein each adjacent value is less than or equal to the value returns new data set and appropriate axes

BunchAnalyzer.Bunches.Bunches.parse(fileName, startColumn=0, endLine=None, headerLine=0, dataStartLine=1, omit=, []onlyUse=None)

Parses a bunch.dat file, returns a generator array. WARNING: Generators can only be read once, for repeated use convert to another format - See convertToNumpyArray and convertTo2DArray

BunchAnalyzer.Bunches.Bunches.parseBunchDataByTurn(fileName, startColumn=0, endLine=None, headerLine=0, dataStartLine=1, omit=, []onlyUse=None)

Parses a bunch.dat file, returns a generator array. WARNING: Generators can only be read once, for repeated use convert to another format - See convertToNumpyArray and convertTo2DArray

BunchAnalyzer.Bunches.Bunches.parseBunchDataByTurn_Array(fileName, startColumn=0, endLine=None, headerLine=0, dataStartLine=1, omit=, []onlyUse=None)

Parses data using parseBunchDataByTurn and converts generators to Numpy/2D arrays

BunchAnalyzer.Bunches.Bunches.plotAll(parsedDataArray, axes=None)

Plot all types of plots for all data: Normal, Log, FFT

BunchAnalyzer.Bunches.Bunches.plotFFTSegments(dataArray, segments=1, segmentEnds=, []axes=None, normalizeFFTAxis=False, absFFT=False, segPlots=True)

Plots FFT Segments. booleans: absFFT = abs(FFT)? normalizeFFTAxis = 0-1.0? segPlots = fft for same segment (in dataset) on same plot?

BunchAnalyzer.Bunches.Bunches.plotParsed(parsedDataArray, axes=None)

Plot all items, use pyplot.show() to display

BunchAnalyzer.Bunches.Bunches.plotParsed_FFT(parsedDataArray, axes=None)

Plot fast fourier transform of all items, use pyplot.show() to display

BunchAnalyzer.Bunches.Bunches.plotParsed_FFT_imag(parsedDataArray, axes=None)

Plot fast fourier transform of all items, use pyplot.show() to display

BunchAnalyzer.Bunches.Bunches.plotParsed_Log(parsedDataArray, axes=None)

Plot all items on a log scale, use pyplot.show() to display

BunchAnalyzer.Bunches.Bunches.plotSideFFT(parsedDataArray, axes=None)

Plots the normal plot, FFT real and FFT imaginary

BunchAnalyzer.Bunches.Bunches.segmentData(dataArray, dataaxes=None, segments=1, segmentEnds=[])

Cuts data array into segments, returns array of array of (axis,data) tuples for each segment for each dataset example return: two datasets segmented in 2 pieces: [ [(x,y),(x,y)], [(x,y),(x,y)] ] segmentEnds overrides segments

BunchAnalyzer.Bunches.Bunches.segmentFFT(parsedDataArray, segments=1, segmentEnds=, []normalizeFFTAxis=True)

Breaks data into defined segments and applies seperate FFT to each

The single bunch module is used for analyzing files containing information about a single bunch of particles. The output files from bin/multibunch are often of the form bunchXXX.dat

BunchAnalyzer.Bunches.SingleBunch.convertFileToColumns(filename, headerLine=0, numpyArrays=True)

Reads a bunch’s file and converts each of the columns to an array, creates an array of Column objects filename: path and name of file to be read headerLine: line to start reading files, contain unique names of column information separated by whitespace (start at 0) numpyArrays: convert python arrays to numpy

BunchAnalyzer.Bunches.SingleBunch.fftPlotAllColumns(filename)

Plots the fft for eah column in a bunch file as a separate subplot

BunchAnalyzer.Bunches.SingleBunch.plotAllColumns(filename)

Plots and displays each column of a bunch file as a separate subplot

BunchAnalyzer.Bunches.SingleBunch.plotEachColumnAndFFT(filename, showImag=False)

Plots each column for the bunch but does not show all the figures

BunchAnalyzer.Bunches.SingleBunch.savePlotAndFFTofallBunchFiles(bunchdirectory, plotdirectory, figureNames=None, showImage=False, verbose=False)

Creates png plots for each /bunchXXX.dat file

Decomposition – functions

This is a Dynamic Modal Decomposition Library made to extract modes from functions and datasets The primary functions for this are “decomposeFunction” for a lambda and “decompose” for a dataset Currently the implementation will decompose the modes and find the amplitude, damping coefficient, and frequency of each mode, however cannot yet determine the phase shift. This library is for use on modes of the form A * e^(-Bt) * sin(Ct + d)

BunchAnalyzer.Decompositions.ModalDecomposition.decompose(parsedData, delta_t, modeIndices=[0, 1], vectorLength=None)

Decomposes parsedData into tables of mode data for each dataset. Requires parsedData: [ [dataset],[dataset],[dataset] ]; delta_t: time between readings; modeIndices: indices for modes returns array of [amplitudes, frequencies, dampings] of each mode for each dataset.

BunchAnalyzer.Decompositions.ModalDecomposition.getModeValues(mode_norms, ritz_values, delta_t)

Returns Amplitudes, Frequencies, and Damping coefficients for all modes in provided data

BunchAnalyzer.Decompositions.ModalDecomposition.makeMatrix(values, height, width)

Makes height by width matrix from array of values returns numpy array with arrays as columns

BunchAnalyzer.Decompositions.ModalDecomposition.makeMatrixNearHeight(values, h)

Makes a matrix from values with height as close to h as possible If errors occur try removing one or two values so as to avoid a prime number of entries or an otherwise oddly divisible number

BunchAnalyzer.Decompositions.ModalDecomposition.makeSquarestMatrix(vectors)

Makes most square matrix possible given vectors vectors = [ [...],[...],[...] ]

BunchAnalyzer.Decompositions.ModalDecomposition.performDynamicModalDecomposition(parsedData, delta_t, modeIndices=[0, 1], vectorLength=None)

Takes parsed data, array of mode indices (i.e. [0,1] ), and the delta t between values returns modes, ritz values, and mode norms for each dataset. modeIndices can be either an array of numbers to be applied to all datasets, or an array of arrays wherein each item corresponds to a dataset (at the same index) in segmentedData.

IntegralDecomposition

BunchAnalyzer.Decompositions.IntegralDecomposition.BesselDataDecomposition(data, delta_x, x, b, a=1, n_max=-1)

Decomposes the data of y values with delta_t between them and yields successive weighted Bessel functions. data is an array of y_vals delta_x is a real number greater than 0 (and is the x difference between values in data) x is a sympy expression a is the order of the Bessel function n_max is the maximum number of products the generator will produce, -1 for infinite Returns: a generator which creates each successive term in f(x)

BunchAnalyzer.Decompositions.IntegralDecomposition.BesselDecomposition(f, b, x, a=1)

Decomposes a function f(x) (defined 0 to b) using the variable x f(x) ~ Sum(cn * J(u*x/b) from n=0 to oo See: http://en.wikipedia.org/wiki/Fourier%E2%80%93Bessel_series f,b,x are sympy expressions Returns: a generator which creates each successive term in f(x)

BunchAnalyzer.Decompositions.IntegralDecomposition.BesselDecomposition_Numerical(f, b, delta_x, x=None, a=1, n_max=-1)

Decomposes a function f(x) (defined 0 to b inclusive) using variable x Generates numerical answers. Often only solution if integral is impossible to compute in literal form. f is a lambda function, generator, or sympy expression b is a real number greater than 0 delta_x is a real number greater than 0 x is a sympy variable a is the order of the desired Bessel Function, default=1 Returns: a generator which creates each successive term in f(x)

class BunchAnalyzer.Decompositions.IntegralDecomposition.FunctionIterator(f, x=None, delta_x=1.0, start=0, stop=-1)

An iterative wrapper for lambdas and generators stop<start for infinite series (unless generator runs out of values)

BunchAnalyzer.Decompositions.IntegralDecomposition.J_an(a, n, b, x)

Returns J_an defined up to b for a variable x

BunchAnalyzer.Decompositions.IntegralDecomposition.getPeaks(data, n=1)

Returns up to n indices in order of ‘sharpness’

BunchAnalyzer.Decompositions.IntegralDecomposition.innerProduct_Numerical(f, g, start, stop, w=None, x=None, delta_x=1.0)

Can use generators, lambdas, and sympy expressions returns <f,g>_w between start and stop for f(x) and g(x) if g is a sympy expression, performs integral f(x)g(x)w(x) dx if g is a lambda or list performs integral f(x)g(x)w(x) for each value calculates with resolution of delta_x (default 1)6

BunchAnalyzer.Decompositions.IntegralDecomposition.plotCompareFFT(f, x, start, stop, delta_x, multiplotter=None)

Plots a function and its FFT

BunchAnalyzer.Decompositions.IntegralDecomposition.plotCompareTwoFunctions(f, g, x, start, stop, delta_x=0.1, multiplotter=None, multiplotterIndex=1)

Plots two functions f(x) and g(x) side by side, generates data from start to stop in delta_x increments

Utilities – functions

class BunchAnalyzer.Utilities.Multiplot.MultiPlotter(numberOfPlots=1, figureNum=1)

A plotting storage object, meant to facilitate interaction with the matplotlib plotting library

Indices and tables

Table Of Contents

This Page