Ejemplo n.º 1
0
void before_mem_tt(unsigned long brk_start)
{
	if(debug)
		remap_data(UML_ROUND_DOWN(&_stext), UML_ROUND_UP(&_etext), 1);
	remap_data(UML_ROUND_DOWN(&_sdata), UML_ROUND_UP(&_edata), 1);
	remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1);
}
/*--------------------------------------------------------------------------------*/
void setup_data(Data *dat)
{
  //clean_cols(dat);

  
  remove_noisecal(dat,NOISE_PERIOD,1);
  
  if (1) {
    float *sigs=vector(dat->raw_nchan);
    clean_outliers(dat,SIG_THRESH,sigs);
    sigs2weights(sigs,dat->raw_nchan,0.3);
    clean_rows(dat);
    apply_weights(dat,sigs);
    
    free(sigs);
  }
  //remove_noisecal(dat,NOISE_PERIOD);


  //zap_bad_channels(dat,"bad_chans.dat");
  


  remap_data(dat);

  
}
Ejemplo n.º 3
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;

}
Ejemplo n.º 4
0
static int remap_data_next(ft_data *ftd, int isign){
  int dirold, dirnew, index;

  dirold = ftd->dir;
  dirnew = next_dir(dirold, isign);

  index = remap_dir[dirold][dirnew];
  if(index == NODIR){
    printf("fourier_ftdata_alldir: Bad map %d to %d\n",dirold, dirnew);
    terminate(1);
  }
  remap_data(index, ftd);
  ftd->dir = dirnew;

  return dirnew;
}
void add_to_ring(DTYPE* indata, DTYPE* outdata, CM_DTYPE* chan_map, DTYPE* ring_buffer_data, int ringt0, int chunk_size, int ring_length, float delta_t, size_t nfreq, float freq0, float delta_f, int depth)
{
     omp_set_dynamic(0);
     omp_set_num_threads(8);

     //zero-pad data
     int ndm = get_nchan_from_depth(depth);
     float * indata_pad = (float*)malloc(sizeof(float)*nfreq*(chunk_size + ndm));
     for(int i = 0; i < nfreq; i++){
       memcpy(indata_pad + i*(chunk_size + ndm), indata + i*chunk_size,sizeof(float)*chunk_size);
       memset(indata_pad + i*(chunk_size + ndm) + chunk_size,0,sizeof(float)*(ndm));
     }


	Data *dat=put_data_into_burst_struct(indata_pad,chunk_size + ndm,nfreq,chan_map,depth);
	remap_data(dat);
     int nchan = dat->nchan;


	float** ring_buffer = (float**)malloc(sizeof(float*)*nchan);
	make_rect_mat(ring_buffer,ring_buffer_data,nchan,ring_length);

	//allocate the triangular matrix for output
	//float* tmp = malloc((nchan*chunk_size + (nchan*(nchan - 1))/2)*sizeof(float));
     //float* tmp = (float*)malloc(nchan*(chunk_size + nchan)*sizeof(float));
	//float** tmp_mat = (float**)malloc(nchan*sizeof(float*));
	//make_triangular_mat(tmp_mat,tmp,nchan,chunk_size,1);
     //make_rect_mat(tmp_mat, tmp, nchan, chunk_size + nchan);
     float** tmp_mat = matrix(nchan,chunk_size + nchan);

	dedisperse_lagged(dat->data,tmp_mat,nchan,chunk_size);
     //printf("ringt0: %i\n",ringt0);
	update_ring_buffer(tmp_mat,ring_buffer,nchan,chunk_size,ring_length,&ringt0);
     //printf("ringt0: %i\n",ringt0);

     //probably not the most efficient way to use the output array
     //does not stop copying if data is incomplete
     //does not prevent overlap
     //ring buffer must be long enough

     //because of the search padding requirement...
	for(int i = 0; i < nchan; i++){
          int src0 = (ring_length + ringt0 - i) % ring_length;
          int src1 = (ring_length + ringt0 + chunk_size - i) % ring_length;
          //printf("ring length %i, cs %i\n",ring_length,chunk_size);
          //printf("i: %i, src0: %i, src1 %i\n",i,src0,src1);
          if (src1 < src0){
           int first_cpy = (ring_length - src0);
           int second_cpy = chunk_size - first_cpy;
           memcpy(outdata + i*(chunk_size + nchan), ring_buffer[i] + src0, first_cpy*sizeof(float));
           memcpy(outdata + i*(chunk_size + nchan) + first_cpy, ring_buffer[i] + src0 + first_cpy, (second_cpy)*sizeof(float));
          }
          else{
		 memcpy(outdata + i*(chunk_size + nchan), ring_buffer[i] + src0, (chunk_size)*sizeof(float));
          }
    }
     free(dat->data[0]);
     free(dat->data);
     free(dat->raw_data[0]);
     free(dat->raw_data);
     free(dat);
	//free(tmp);
     free(indata_pad);
     //free(tmp_mat[0]);
     free(tmp_mat[0]);
     free(tmp_mat);
     //free(ring_buffer);
}