Ejemplo n.º 1
0
static void init_kernel(int z, int fftlen, kernel * kern)
{
   int numkern;
   fcomplex *tempkern;

   kern->z = z;
   kern->fftlen = fftlen;
   kern->numbetween = ACCEL_NUMBETWEEN;
   kern->kern_half_width = z_resp_halfwidth((double) z, LOWACC);
   numkern = 2 * kern->numbetween * kern->kern_half_width;
   kern->numgoodbins = kern->fftlen - numkern;
   kern->data = gen_cvect(kern->fftlen);
   tempkern = gen_z_response(0.0, kern->numbetween, kern->z, numkern);
   place_complex_kernel(tempkern, numkern, kern->data, kern->fftlen);
   free(tempkern);
   COMPLEXFFT(kern->data, kern->fftlen, -1);
}
Ejemplo n.º 2
0
void rz_interp(fcomplex * data, int numdata, double r, double z,
               int kern_half_width, fcomplex * ans)
  /* This routine uses the correlation method to do a Fourier        */
  /* complex interpolation at a single point in the f-fdot plane.    */
  /* It does the correlations manually. (i.e. no FFTs)               */
  /* Arguments:                                                      */
  /*   'data' is a complex array of the data to be interpolated.     */
  /*   'numdata' is the number of complex points (bins) in data.     */
  /*   'r' is the Fourier frequency in data that we want to          */
  /*      interpolate.  This can (and should) be fractional.         */
  /*   'z' is the fdot to use (z=f-dot*T^2 (T is integration time)). */
  /*   'kern_half_width' is the half-width of the kernel in bins.    */
  /*   'ans' is the complex answer.                                  */
{
   float *dataptr, *respptr;
   int ii, numkern, nsum, intfreq, lodata, hidata, loresp, hiresp;
   double fracfreq, dintfreq, tmpd, tmpr;
   fcomplex *response;

   /* Check 'r' and return 0.0 + 0.0i if out of bounds.        */
   /* Should this return an error and exit instead?            */

   if (r > numdata - 1.0 || r < 0.0) {
      ans->r = 0.0;
      ans->i = 0.0;
      return;
   }

   /* Split 'r' into integer and fractional parts */

   fracfreq = modf(r, &dintfreq);
   intfreq = (int) dintfreq;

   /* Return immediately if 'r' is close to an           */
   /* integer frequency and z is very close to zero      */

   if (fabs(z) < 1E-4) {
      if (fracfreq < 1E-5) {
         ans->r = data[intfreq].r;
         ans->i = data[intfreq].i;
         return;
      }
      if ((1.0 - fracfreq) < 1E-5) {
         ans->r = data[intfreq + 1].r;
         ans->i = data[intfreq + 1].i;
         return;
      }
   }

   /* Generate the response function */

   numkern = 2 * kern_half_width;
   response = gen_z_response(fracfreq, 1, z, numkern);

   /* Determine the summation boundaries */

   lodata = intfreq - kern_half_width;
   if (lodata < 0) {
      loresp = abs(lodata);
      lodata = 0;
   } else {
      loresp = 0;
   }
   hidata = intfreq + kern_half_width - 1;
   if (hidata > numdata - 1) {
      hiresp = numkern - hidata + numdata - 1;
   } else {
      hiresp = numkern;
   }
   nsum = hiresp - loresp;

   /* Set up our pointers */

   dataptr = (float *) (data + lodata);
   respptr = (float *) (response + loresp);

   /* Do the summation */

   ans->r = 0.0;
   ans->i = 0.0;

   for (ii = 0; ii < nsum; ii++) {
      tmpd = *(dataptr++);
      tmpr = *(respptr++);
      ans->r += tmpd * tmpr + (*dataptr) * (*respptr);
      ans->i += (*dataptr) * tmpr - (*respptr) * tmpd;
      dataptr++;
      respptr++;
   }

   vect_free(response);
   return;
}