(file) Return to autocorr_test.c CVS log (file) Jump to this file's LXR Page (dir) Up to [CENS] / emstar / devel / loc / ar

File: [CENS] / emstar / devel / loc / ar / autocorr_test.c (download) / (as text)
Revision: 1.1, Wed Aug 10 03:49:18 2005 UTC (4 years, 3 months ago) by girod
Branch: MAIN
CVS Tags: pregeonet, acoustic-05-18-06, PRE_TOSNIC_FIX, PRE_64BIT, LAURA_CALIBRATION_EXPERIMENTS, HEAD, ESS_RELEASE_3_5, ESS_RELEASE_3_4, ESS_RELEASE_3_2, ESS_RELEASE_3_1, ESS_RELEASE_3_0, ESS_RELEASE_2_0, ESS_CONNECTIVITY, ESS_CENTROUTE_TESTING, ESS2-CMS-V1_5_pretest, ESS2-CMS-V1_4cMergeSympathy, EMSTAR_RELEASE_2_5, CYCLOPS_RELEASE_CANDIDATE_2_0, CYCLOPS_PRERELEASE_STABLE, CENTROUTE_EMSTAR_SOCKETS, BG_1_0, BANGLADESH_ARSENIC_1_2, BANGLADESH_ARSENIC_1_1, AMARSS_JR_DEPLOYMENT_6_05_07
added autocorreltion test program.  discovered that changing from
double to float causes serious problems for pn generator
more updates to offline calc program
added test to ar_net to check for short read from sensor

/*
 *
 * Copyright (c) 2005 The Regents of the University of California.  All 
 * rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * - Neither the name of the University nor the names of its
 *   contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

/*
 *  test program determines max autocorrelation for different seed values
 */

#include "ar.h"

int main(int argc, char **argv)
{
  int i,j;
  int chirp_len = CHIRP_CHIPS*MOD_FACTOR*RANGE_FACTOR;

  int16_t *bpsk = g_new(int16_t,chirp_len);
  float *f_input;
  float *correl;
  complex *fft_input;
  complex *fft_correl;
  f_input = g_new(float,chirp_len);
  correl = g_new(float,chirp_len);
  fft_input = g_new(complex,chirp_len);
  fft_correl = g_new(complex,chirp_len);

  for (i=1; i<1000; i++) {
    ar_pn_generate_chirp(bpsk, chirp_len, i, 0, (float)(CHIRP_CHIPS*MOD_FACTOR) / 8192);

    /* convert to float */
    for (j=0; j<chirp_len; j++) 
      f_input[j] = (float)bpsk[j];

    nl_fft(f_input, fft_input, chirp_len);
    nl_fd_correl(fft_correl, correl, fft_input, fft_input, chirp_len);

    float max = 0;
    for (j=3; j<(chirp_len-2); j++) {
      if (fabs(correl[j]) > max)
	max = fabs(correl[j]);
    }
    
    float frac = fabs(correl[0]) / max;
    printf ("%d %f %f\n", i, max, frac);

#if 0
    for (j=0; j<chirp_len; j++) {
      printf("%d %f %f\n", j, f_input[j], correl[j]);
    }
#endif
  }

  return 0;
}

CENS CVS Mailing List
Powered by
ViewCVS 0.9.2