LEEFILT $SSW/smei/bham/idl/utils/leefilt_smei.pro
[Previous] [Next]
 NAME:
	LEEFILT

 PURPOSE:
	Performs the Lee filter algorithm on an image array using a
	box of size 2N+1.  This function can also be used on vectors.

 CATEGORY:
	E3 Smoothing (image).

 CALLING SEQUENCE:
	Result = LEEFILT(A [, N, Sig])

 INPUTS:
	A:	The input image array or one-dimensional vector.

 OPTIONAL INPUT PARAMETERS:
	N:	The size of the filter box is 2N+1.  The default value is 5.

	Sig:	Estimate of the standard deviation.  The default is 5.
		If Sig is negative the procedure requests a value to be
		entered, and displays the resulting image or vector.  This
               cycle continues until a zero value of Sig is entered.

 KEYWORDS:

	EXACT:  Use this keyword to use a more accurate, but much slower
		Lee filter algorithm. Recommended when N > ~7.

   DOUBLE = Set this keyword to force the computations to be done
            in double-precision arithmetic.

 OUTPUTS:
	The filtered image or vector is returned.

 CALLS: ***
	LEEFILT_SMEI, LEE_FILTER_EXACT, LEE_FILTER_FAST
 CALLED BY:
	MKMOVIE, MKMOVIE0 obsolete version of mkmoviepro, MK_IMG
 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	Displays the filtered image in an IDL window using TVSCL or PLOT if
       Sig is negative.

 RESTRICTIONS:
	None.

 PROCEDURE:
	The LEE (Optical Engineering, Vol 25, No 5, Pg 636-643, May 1986)
       technique smooths additive image noise by generating statistics in
       a local neighborhood and comparing them to the expected values.

 MODIFICATION HISTORY:
	Written, 24-Nov-1982, by R. A. Howard, Naval Research Lab,
				 Washington, DC 20375
       Modified, 30-May-1996, SVP. Modifed to match 1986 algorithm &
                              Added /EXACT at user suggestion.
                              Added PLOT for vector support.
   CT, RSI, May 2000: Added double-precision support.
   SJT: UB: Sep 05: Added NaN and Median options.


LOCAL_COORD $SSW/smei/bham/idl/utils/local_coord.pro
[Previous] [Next]
 NAME:
	LOCAL_COORD


 PURPOSE:
	Convert a "local" NDC coordinate to a global one


 CATEGORY:
	Utils


 CALLING SEQUENCE:
	gc = local_coord(lc, origin, size)


 INPUTS:
	lc	float	The "local" NDC position
	origin	float	The origin of the local coordinates in cm.
	size	float	The size of the local system in cm.


 KEYWORD PARAMETERS:
	/x	If set then this is an X coordinate (default)
	/y	If set, then this is a Y coordinate.


 OUTPUTS:
	gc	Float	The real NDC position


 RESTRICTIONS:
	Only works if the current device is PS


 MODIFICATION HISTORY:
	Original: 16/5/03; SJT


LocalExtrema $SSW/smei/ucsd/sat/idl/toolbox/math/localextrema.pro
[Previous] [Next]
 NAME:
	LocalExtrema
 PURPOSE:
	Return location of local maxima and minima in an array
 CATEGORY:
	Math
 CALLING SEQUENCE:
	R = LocalExtrema(Array, [/minima, /float])
 INPUTS:
	Array		array[*]; type: 1-dim array
					input array to be searched for extrema
 OPTIONAL INPUT PARAMETERS:
	By default the locations of an alternating sequence of
	maxima and minima are returned.

	/maxima		if /maxima is set then the locations of maxima are returned
	/minima		if /minima is set then the locations of minima are returned

	/float		by default integer indices are returned for the location of the extrema.
				If /float is set then the location is refined by fitting a quadratic to
				the minimum element and its two neighbours. The extremum of the
				quadratic is returned as a floating point number.
 OUTPUTS:
	R			scalar or array; type: integer or float
					indices of minima or maxima
 OPTIONAL OUTPUT PARAMETERS:
	fnc=fnc		array[*]; same size as R, same type as 'Array'
					function values in locations R. If the /float keyword is set it
					returns the function values in the extremum of the quadratic fit.
	count=count scalar; type: integer
					# extrema
 INCLUDE:
	@compile_opt.pro			; On error, return to caller
 CALLS: ***
	BadValue, InitVar
 CALLED BY:
	even_light_pedestal, smei_frm_hbar, smei_frm_hbar_inside, smei_star_fit
 RESTRICTIONS:
 >	Only genuine maxima and minima are detected,
 >	The edges of the array are excluded, i.e. only the locations of
	'internal' extrema (with neighbour on both sides) are returned
 PROCEDURE:
	Let 'array' represent a function f(x) in points x=[0,1,.]
	Let f have an extremum in grid point j, i.e. f(j) > f(j-1) and f(j) > f(j+1)
	Define dx = x-j and g(dx) = f(j+dx)-f(j), i.e. g(0) = 0 is an extremum of g
	The quadratic for g through 0 and its two neighbours -1 and +1 is:
		y(dx) = 0.5*dx*{ g(-1)*(dx-1)+g(+1)*(dx+1) }
	which has a maximum at
		dx = 0.5*(g(-1)-g(1))/(g(-1)+g(1))
 MODIFICATION HISTORY:
	MAR-2000, Paul Hick (UCSD/CASS)
	FEB-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
		Introduced /maxima keyword to return maxima. This used to be the default.
		The default now is to return an alternating sequence of minima and maxima.


lsqCircleFit $SSW/smei/ucsd/gen/idl/toolbox/math/lsqcirclefit.pro
[Previous] [Next]
 NAME:
	lsqCircleFit
 PURPOSE:
	Least square fitting a circle to a set of points
 CATEGORY:
	gen/idl/toolbox/math
 CALLING SEQUENCE:
	R = lsqCircleFit(x,y)
 INPUTS:
	x		array[n,m] or array[2,n,m]; type: any
				m sets of n x-coordinates
				if y is not specified than x must be of the form x[2,n,m]
				with x[0,*,*] the x-values and x[1,*,*] the y-values. 
	y		array[n,m]; type: any
				m sets of n y-coordinates matching the x-array
 OUTPUTS:
	R		array[3] or array[3,m]; type: float or double
				x-coordinate and y-coordinate of center, followed by the radius
 OPTIONAL OUTPUT PARAMETERS:
	chisq=chisq
			scalar or array[m]; type: float
				residual 'chi-square' = sqrt ( sqrt( (1/N)*Sum( ((x-x0)^2+(y-y0)^2-R^2)^2 ) ) )
 INCLUDE:
	@compile_opt.pro			; On error, return to caller
 CALLS: ***
	SubArray, SyncArgs
 CALLED BY:
	even_light, even_light_corrections
 PROCEDURE:
 >	If both x and y is specified than it is allowed to specify only one set of x-value
	x[n] with multiple sets of y-values y[n,m]. Each of the sets of y-values is combined
	with the set of x-values.
 >	Standard least square fit.
	Each row in the input arrays x and y is fitted to a circle. A separate center and radius
	is returned for each of the rows.
 MODIFICATION HISTORY:
	MAR-2000, Paul Hick (UCSD/CASS)
	FEB-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu), added SyncArgs call.


lsqLinearFit $SSW/smei/ucsd/gen/idl/toolbox/math/lsqlinearfit.pro
[Previous] [Next]
 NAME:
	lsqLinearFit
 PURPOSE:
	Least-squares fit of function of N independent variables
 CATEGORY:
	gen/idl/toolbox/math
 CALLING SEQUENCE:
	FUNCTION lsqLinearFit, f,x,y,z,t, zero_intercept=zero_intercept
 INPUTS:
	f			array[n]; type: float
					z coordinates (function values)
 OPTIONAL PARAMETERS:
	x			array[n] or array[m,n]; type: float
					array[n]: x coordinates
					array[m,n]; m-elements position vectors
						for n points in m-dim space

						If x is absent then a 1-dim lsq fit
						using the array index is used.
	y,z,t		array[n]; type: float
					x,y,z,t are the position vectors for
						n points.
 /zero_intercept
				fits to a linear function with no leading constant
				(i.e. it fits to a linear function that goes through
				the origin x=y=z=t=0)
				The intercept Result[0] is explicitly set to zero
				in this case.
 OUTPUTS:
	Result		array[m+1]; type: float
					least-square fit parameters of the linear
					function fitted to the points.
 INCLUDE:
	@compile_opt.pro		; On error, return to caller
 CALLED BY:
	smei_star_lsqfit
 SEE ALSO:
	circlefit, normalfit
 CALLS: ***
	InitVar, IsTime, IsType, MEAN, SuperArray, TimeGet, TimeLimits, TimeUnit
 PROCEDURE:
	For 1,2,3 and 4-dim fits the solution is evaluated directly
	from analytic expressions. For higher dimensions a matrix
	inversion is used.
 MODIFICATION HISTORY:
	FEB-2003, Paul Hick (UCSD/CASS)
	SEP-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
		Added /zero_intercept.


lsqNormalFit $SSW/smei/ucsd/gen/idl/toolbox/math/lsqnormalfit.pro
[Previous] [Next]
 NAME:
	lsqNormalFit
 PURPOSE:
	Find least squares fit to a data series x,y
 CATEGORY:
	gen/idl/toolbox/math
 CALLING SEQUENCE:
	A = lsqNormalFit(x, y, /plot, /oplot, /worst)
 INPUTS:
	x,y	arrays to be fitted
 OPTIONAL INPUT PARAMETERS:
	/plot	data points and fit are plotted
	/oplot	the fit is plotted using the current user scale
	/worst	will also plot the worst possible fit
 OUTPUTS:
	A	fltarr(5,2)
		A[*,0] represents the best fit; A[*,1] represents the worst fit

	The equation for the straight line fit:
		A[0,i]*(x-A[1,i])+A[2,i]*(y-A[3,i]) = 0

	A[1,i] is the average of the x-array
	A[3,i] is the average of the y-array

	A[4,i] is the residual average distance of the `normalized' data points to the fit.
 INCLUDE:
	@compile_opt.pro		; On error, return to caller
 CALLS: ***
	InitVar, POLY_FIT
 CALLED BY:
	even_light_info, qLine_FitPlot, vu_correlate, vu_insitucurve
 PROCEDURE:
	The x and y arrays are `normalized' by dividing the arrays by their
	respective standard deviations. The resulting arrays are fitted by
	minimizing the perpendicular distance to a straight line fit.
	The result is symmetric: interchanging x and y arrays will give the same fit.
 MODIFICATION HISTORY:
	JUN-1994, Paul Hick (UCSD)
	AUG-1999, Paul Hick (pphick@ucsd.edu); added title keyword
	APR-2000, Paul Hick (pphick@ucsd.edu); added _extra keyword
	FEB-2001, Paul Hick (pphick@ucsd.edu); changed the main plotting command to
		use the input arrays directly for plotting.