/*--------------------------------------------------------------------------------*/ 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; }
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); }