⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smooth.par.lib

📁 su 的源代码库
💻 LIB
字号:
SMOOTH - Functions to compute smoothing of 1-D or 2-D input datadlsq_smoothing		perform 1 or 2-D smoothing of a 2_D dataset			via damped least squares. The user specifies			the degree of smoothing required and the program			outputs an rms error function to help decide if the			degree of smoothing was right SG_smoothing_filter	computes a 1-D smmothing filter via Savitzky-Golay			least squares. This filter is then convolved with 			the data to effect the smoothing. A 2-D array can be			smoothed in both directions with two passes through			this function rwa_smoothing_filter	computes 1-D smoothing filter via running window average			The window can be rectangular or triangular (weighted).			This filter will then be convolved with the data.			A 2-D array can be smoothed first in one direction and 			then n the other with two passes through the function.Function Prototypes:void dlsq_smoothing (int nt, int nx, int ift, int ilt, int ifx, int ilx, 	float r1, float r2, float rw, float **traces);void SG_smoothing_filter(int np, int nl, int nr, int ld, int m, float *filter);void rwa_smoothing_filter (int flag, int nl, int nr, float *filter);void gaussian2d_smoothing (int nx, int nt, int nsx, int nst, float **data);void gaussian1d_smoothing (int ns, int nsr, float *data);void smooth_histogram (int nintlh, float *pdf);dlsq_smoothing:Input:nt		number of samples in vertical (time) axisnx		number of samples in horizontal axis (traces)ift		index of upper left corner of data window to smoothilt		index of lower left corner of data window to smoothifx		index of upper right corner of data window to smoothilx		index of lower right corner of data window to smoothr1		smoothing parameter in first dimension, usually between 1&20r2		smoothing parameter in second dimension, usually between 1&20rw		smoothing parameter of window function. If zero, the window		will have sharp edgestraces		2-D array of data to smoothOutput:traces		2-D array of smoothed dataNotes:Larger r1 and r2 result in smoother data. Recommended ranges are from 1 to 20.The program outputs a file called err which gives the rms error between theinput and the smoothed data as a function of the first dimension (time ordepth). For most applications, if this error is between 0.1 and 0.01 the smoothing parameters are O.K, otherwise, try changing them.The smoothing can be done in a window of data rather than in the whole databy specifying the index coordinates of the window. If smoothing of the wholedata is desired, ifx=0, ilx=nx, ift=0, ilt=nt.If smoothing of only one trace is desired, ifx=0, ilx=1, ift=0, ilt=nt.Smoothing of the window boundaries (blurring the edges of the window) can be done with a rw different than zero, otherwise the edges will be sharp.	Credits:Adapted by Gabriel Alvarez (1995) from the program smooth2.c of the CWP library 	written by Zhenyue Liu (1992)SG_smoothing_filter:Input:np		number of points in output filter (np>=nl+nr+1)nl		number of left (past) data points usednr		number of right (future) data points usedld		order of desired derivative (=0 for smoothed function)m		order of smoothing polynomial (normally 2 or 4)Output parameters:filter		vector of m-points filter coefficients to be convolved 		with the data to be smoothedNotes:This filter is based on the assumption that the underlying function can bewell-fitted by a polynomial. When this is the case, the results are prettygood.  The filter is particularly good to smooth data that contains narrow peaks,since it tends to honor them. If the peaks are too narrow with respect to thefilter width, however, some attenuation of the peaks occurs. Higher order (higher m) filters tend to perform better with narrower peaks at the expense ofthe degree of smoothing of broader features. In general, the best results areobtained when the full width (nl+nr+1) of the 4-degree filter is between 1 and2 times the FWHM (full width at half of maximum) of the features that wedesire to smooth in the data.Wider filters produce greater smoothing effect than narrower ones for filtersof a given order.To within the roundoff error, the filter coefficients should add to one so thatthe area under the curve is preserved after the smoothing. The sign of the samples is not preserved in general.In order to compute filtered numerical derivatives (and not just to smooth the data), the parameter ld should be given the value of the desiredderivative (everything else is the same). 	A typical call to the convolution subroutine to apply the filter will be:conv (nl+nr+1,-nl,filter,nd,0,data,nd,0,result);  where data[nd] is the inputdata to smooth and result[nd] is the smoothed dataReferences:Press, Teukolsky, Vettering, Flannery, Numerical Recipes in C:		the art of scientific programming. Cambridge University		Press. Second Edition (1992).Ziegler, Applied Spectroscopy, Vol. 35, pp. 88-92.Bromba and Ziegler, Analytical Chemistry, Vol. 53, pp 1582-1586.Credits:Adapted from Numerical Recipes in C by Gabriel Alvarez (1995)rwa_smoothing_filter:Input:flag		=1 for rectangular window. =2 for triangular (weighted) windownl		number of left (past) data points usednr		number of right (future) data points usedOutput:filter		array[nl+nr+1] of filter points to be convolved with the dataNotes:The rectangular window should only be used when the data to be smoothed isfairly smooth already.  larger windows are not recommended unless realsmoothing is desired.The triangular window will give more weight to the points that are closerto the one to smooth. Although this is normally desirable, the degree ofsmoothing for a given filter length is much less than with the rectangularwindom.Both of this windows preserve the are under the curve and the sign of the samples to be smoothed.A typical call to the convolution subroutine to apply the filter will be:conv (nl+nr+1,-nl,filter,nd,0,data,nd,0,result);  where data[nd] is the inputdata to smooth and result[nd] is the smoothed dataCredits:Gabriel Alvarez (1995).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -