diff --git a/fitcenter.c b/fitcenter.c index d042bd0a..dd73573e 100644 --- a/fitcenter.c +++ b/fitcenter.c @@ -15,6 +15,14 @@ #include "scan.h" #include "fitcenter.h" #define THRESHOLD .1 + +//Jing: Flag to smooth the scan data +#define SMOOTHSCANDATA + +float ggf1[] = {0.006, 0.061, 0.242, 0.383, 0.242, 0.061, 0.006}; // Gaussian Smooth Filter +float ggf2[] = {0.1429, 0.1429, 0.1429, 0.1429, 0.1429, 0.1429, 0.1429}; // Mean Smooth Filter + + /*--------------------------------------------------------------------------*/ typedef struct __FitCenter { pObjectDescriptor pDes; @@ -70,7 +78,31 @@ free(self->fAxis); } free(self); - } + } + + +/* Jing: smmoth the scan data */ + void SmoothScanCounts(long *lData, int iDataLen) + { + int ind = (int) (sizeof(ggf1)/sizeof(float) - 1)/2; + long * pData = (long *)malloc(iDataLen * sizeof(long)); + + for(int i=0; i0) + lData[i] = pData[i-j] * ggf1[ind-j]; + if((i+j)pScan,self->lCounts, self->iNP); + +#ifdef SMOOTHSCANDATA //Jing: Smoothe the scan data with a Gaussian filter + SmoothScanCounts(self->lCounts, self->iNP); +#endif + GetScanVar(self->pScan,0,self->fAxis,self->iNP); GetScanVarName(self->pScan,0,self->pName,131);