PyPO User Manual
FitGauss.py File Reference

File containing methods for fitting Gaussian distributions to field components. More...

Functions

def PyPO.FitGauss.calcEstimates (x, y, area, field_norm)
 Calculate estimates for beam parameters from an input field component. More...
 
def PyPO.FitGauss.fitGaussAbs (field, surfaceObject, thres, scale, ratio=1)
 Fit a Gaussian to an amplitude pattern of a field component. More...
 
def PyPO.FitGauss.GaussAbs (p0, *args)
 Generate absolute Gaussian from parameters. More...
 
def PyPO.FitGauss.generateGauss (p0, surfaceObject, scale)
 Generate a Gaussian from Gaussian and surface parameters. More...
 

Detailed Description

File containing methods for fitting Gaussian distributions to field components.

Function Documentation

◆ calcEstimates()

def PyPO.FitGauss.calcEstimates (   x,
  y,
  area,
  field_norm 
)

Calculate estimates for beam parameters from an input field component.

These estimates are used as initial values for Gaussian fitting.

Parameters
xGrid of x co-ordinates of input field.
yGrid of y co-ordinates of input field.
areaGrid of area elements.
field_normNormalised input field component.
Returns
x0 Semi-major axis size of estimate.
y0 Semi-minor axis size of estimate.
xm Mean x-center of estimate.
ym Mean y-center of estimate.
theta Position angle of estimate.

◆ fitGaussAbs()

def PyPO.FitGauss.fitGaussAbs (   field,
  surfaceObject,
  thres,
  scale,
  ratio = 1 
)

Fit a Gaussian to an amplitude pattern of a field component.

First, the center and position angle of the pattern is calculated using the method of image moments. Then, local maxima that might interfere with fitting are removed using the findConnectedSubsets method from MatUtils.py.

Parameters
fieldComponent of field to fit.
surfaceObjectSurface on which the field is defined.
thresThreshold for fitting in decibels.
modeWhether to fit the Gaussian in linear or logarithmic space.
ratioAllowed maximal ratio of fit to actual beam. If "None", will just attempt to fit the Gaussian to supplied pattern. If given, will only accept a fit if the ratio of integrated power in the fitted Gaussian to the supplied beam pattern is less than or equal to the given value. Defaults to 1.
Returns
popt Optimal parameters for Gaussian.

◆ GaussAbs()

def PyPO.FitGauss.GaussAbs (   p0,
args 
)

Generate absolute Gaussian from parameters.

Called in optimalisation. This method returns an overlap parameter of the fitted Gaussian .

Parameters
p0Array containing parameters for Gaussian.
argsExtra arguments for defining Gaussian and fit.
Returns
epsilon Coupling of field with Gaussian.

◆ generateGauss()

def PyPO.FitGauss.generateGauss (   p0,
  surfaceObject,
  scale 
)

Generate a Gaussian from Gaussian and surface parameters.

Parameters
p0Gaussian parameters.
surfaceObjectSurface on which Gaussian is defined.
scaleWhether to generate Gaussian in linear or decibel space.
Returns
Psi Gaussian distribution.