Пример #1
0
/*--------------------------------------------------------------------------------*/
size_t my_burst_dm_transform(float *indata1, float *indata2, float *outdata,
                             size_t ntime1, size_t ntime2, float delta_t,
                             size_t nfreq, size_t *chan_map, int depth,int jon) 
{

  double t1=omp_get_wtime();
  //printf("starting dedispersion.\n");

  //clean_rows_2pass(indata1,nfreq,ntime1);
  //if (ntime2>0)
  //  clean_rows_2pass(indata2,nfreq,ntime2);
  //printf("did row cleaning in %12.5f seconds.\n",omp_get_wtime()-t1);

  //t1=omp_get_wtime();
  Data *dat=put_data_into_burst_struct(indata1,indata2,ntime1,ntime2,nfreq,chan_map,depth);
  //printf("data are in struct.\n");

  //setup_data does a bunch of cleaning, like removal of noise-cal, glitch finding, 
  //calibration off the noise cal, channel weighting...  If that has been done, just
  //call remap_data which will copy the data to where it needs to go.

  //setup_data(dat);
  remap_data(dat);
  //printf("data are remapped.\n");

  if(jon == 1){
    //printf("calling jon.\n");
    dedisperse_gbt_jon(dat,outdata);
  }
  else{
    //printf("calling something else.\n");
    dedisperse_gbt(dat,outdata);
  }
  double t2=omp_get_wtime();
  //Peak best=find_peak(dat);
  //printf("dedispersion time was %12.4f seconds.\n",(t2-t1));

#if 0
  Peak best;
  find_peak_wrapper(dat->data[0],dat->nchan,dat->ndata,&best.snr,&best.dm_channel,&best.ind,&best.duration);
  double t3=omp_get_wtime();
  printf("times are %12.5f %12.5f, peak is %12.3f with channel %d at sample %d and duration %d\n",t2-t1,t3-t2,best.snr,best.dm_channel,best.ind,best.duration);
  
  int nskip=100;
  find_peak_wrapper(dat->data[nskip],dat->nchan-nskip,dat->ndata,&best.snr,&best.dm_channel,&best.ind,&best.duration);
  printf("times are %12.5f %12.5f, peak is %12.3f with channel %d at sample %d and duration %d\n",t2-t1,t3-t2,best.snr,best.dm_channel+nskip,best.ind,best.duration);
#endif

  size_t ngood=dat->ndata-dat->nchan;
  
  free(dat->raw_data[0]);
  free(dat->raw_data);
  free(dat->data[0]);
  free(dat->data);
  free(dat);

  //return ngood;
  return dat->ndata;

}
int main(int argc, char *argv[])
{
  //printf("file has %d bytes.\n",(int)get_file_size("GBT11B_wigglez1hr_01_0123_dump.dat"));
  //int nchan,nsamp;

  Data *dat=read_gbt("GBT11B_wigglez1hr_01_0123_dump.dat");
  printf("nchan and nsamp are %d %d\n",dat->raw_nchan,dat->ndata);
  printf("top and bottom channels are %12.5f %12.5f\n",dat->raw_chans[0],dat->raw_chans[dat->raw_nchan-1]);


  double t1=omp_get_wtime();


  //This sets up the mapping of GBT channels into the linear-in-lambda^2 channels, and cleans up the data
  map_chans(dat,12);
  clean_rows(dat);  
  setup_data(dat);


  float **tmp=matrix(dat->nchan, dat->ndata);
  memset(tmp[0],0,sizeof(tmp[0][0])*dat->ndata*dat->nchan);
  
  dedisperse_gbt(dat,tmp[0]);
  printf("total processing took %12.4f seconds.\n",omp_get_wtime()-t1);



  FILE *rawfile=fopen("gbt_i.dat","w");
  fwrite(dat->raw_data[0],sizeof(dat->raw_data[0][0]),dat->ndata*dat->nchan,rawfile);
  fclose(rawfile);


  FILE *outfile=fopen("gbt_dedispersed.dat","w");
  fwrite(dat->data[0],sizeof(dat->data[0][0]),dat->nchan*dat->ndata,outfile);
  fclose(outfile);


  FILE *fid=fopen("crap.dat","w");
  for (int i=0;i<dat->raw_nchan;i++) {
    fwrite(&(dat->raw_chans[i]),1,sizeof(float),fid);
    fwrite(&(dat->chans[dat->chan_map[i]]),1,sizeof(float),fid);
  }
  fclose(fid);
  for (int i=dat->ndata-6000;i<dat->ndata-5994;i++) {
    printf("dat[1][i]=%12.4f\n",dat->data[1][i]);
  }
}