add smooth func to the scan data
r3287 | jgn | 2011-11-25 14:24:26 +1100 (Fri, 25 Nov 2011) | 1 line
This commit is contained in:
committed by
Douglas Clowes
parent
5bd8e4ae3a
commit
9b7fd70774
39
fitcenter.c
39
fitcenter.c
@@ -15,6 +15,14 @@
|
|||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
#include "fitcenter.h"
|
#include "fitcenter.h"
|
||||||
#define THRESHOLD .1
|
#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 {
|
typedef struct __FitCenter {
|
||||||
pObjectDescriptor pDes;
|
pObjectDescriptor pDes;
|
||||||
@@ -70,7 +78,31 @@
|
|||||||
free(self->fAxis);
|
free(self->fAxis);
|
||||||
}
|
}
|
||||||
free(self);
|
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; i<iDataLen; i++) pData[i] = lData[i];
|
||||||
|
|
||||||
|
for(int i=0; i<iDataLen; i++){
|
||||||
|
lData[i] = pData[i] * ggf1[ind];
|
||||||
|
for(int j=1; j<=ind; j++){
|
||||||
|
if((i-j)>0)
|
||||||
|
lData[i] = pData[i-j] * ggf1[ind-j];
|
||||||
|
if((i+j)<iDataLen)
|
||||||
|
lData[i] = pData[i+j] * ggf1[ind+j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
static int Init(pFit self)
|
static int Init(pFit self)
|
||||||
{
|
{
|
||||||
@@ -98,6 +130,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
GetScanCounts(self->pScan,self->lCounts, self->iNP);
|
GetScanCounts(self->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);
|
GetScanVar(self->pScan,0,self->fAxis,self->iNP);
|
||||||
GetScanVarName(self->pScan,0,self->pName,131);
|
GetScanVarName(self->pScan,0,self->pName,131);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user