/****************************************************************** * calculate deconvolution filter 1/(s[w]+water_level). * the water-level is c*auto-correlation(s[t]). A low-pass gaussian filter * exp(-w^2/(4 sigma^2)) * is also applied. ******************************************************************/ void water( complex *a, /* IN/OUT, spectrum of s(t) */ int nft, /* number of pts of s(w), 2^N*/ float dt, /* sampling interval in sec */ float c, /* water-level in %*/ float gauss /* sigma in Hz */ ) { int j; float w, delw; double *d2, agg, water, u; u = 1+c; d2 = (double *) malloc ((nft+1)*sizeof(double)); delw = PI/(dt*nft); d2[0] = a[0].x*a[0].x; d2[nft] = a[0].y*a[0].y; water = d2[0]+d2[nft]; for (j=1; j<nft; j++) { d2[j] = a[j].x*a[j].x+a[j].y*a[j].y; water += d2[j]; } water = c*water/nft; /* in terms of auto-correlation */ a[0].x *= u/(d2[0]+water); for (w=delw,j=1; j<nft; j++,w+=delw) { agg = 0.5*w/gauss; a[j] = dmltp(u*exp(-agg*agg)/(d2[j]+water),conjg(a[j])); } agg = 0.5*w/gauss; a[0].y *= u*exp(-agg*agg)/(d2[j]+water); free(d2); }
complex cinvs(complex a) { complex dmltp(float, complex); complex conjg(complex a); return(dmltp(1./(a.x*a.x+a.y*a.y), conjg(a))); }