void run_3d_ps_corr_bf(void) { ////// // Runs xi(pi,sigma) in brute-force mode np_t sum_wd,sum_wd2,sum_wr,sum_wr2; Catalog cat_dat,cat_ran; Box3D *boxes_dat,*boxes_ran; int *indices_dat,*indices_ran; int nfull_dat,nfull_ran; histo_t *DD=(histo_t *)my_calloc(nb_rt*nb_rl,sizeof(histo_t)); histo_t *DR=(histo_t *)my_calloc(nb_rt*nb_rl,sizeof(histo_t)); histo_t *RR=(histo_t *)my_calloc(nb_rt*nb_rl,sizeof(histo_t)); timer(4); set_r_z(); #ifdef _VERBOSE print_info("*** 3D correlation function (pi,sigma): \n"); print_info(" - Range: (%.3lf,%.3lf) < (pi,sigma) < (%.3lf,%.3lf) Mpc/h\n", 0.,0.,1/i_rl_max,1/i_rt_max); print_info(" - #bins: (%d,%d)\n",nb_rl,nb_rt); print_info(" - Resolution: (d(pi),d(sigma)) = (%.3lf,%.3lf) Mpc/h\n", 1./(i_rl_max*nb_rl),1./(i_rt_max*nb_rt)); print_info(" - Using a brute-force approach \n"); print_info("\n"); #endif read_dr_catalogs(&cat_dat,&cat_ran, &sum_wd,&sum_wd2,&sum_wr,&sum_wr2); print_info("*** Boxing catalogs \n"); init_3D_params(cat_dat,cat_ran,3); boxes_dat=mk_Boxes3D_from_Catalog(cat_dat,&indices_dat,&nfull_dat); free_Catalog(cat_dat); boxes_ran=mk_Boxes3D_from_Catalog(cat_ran,&indices_ran,&nfull_ran); free_Catalog(cat_ran); print_info("\n"); #ifdef _DEBUG write_Boxes3D(n_boxes3D,boxes_dat,"debug_Box3DDat.dat"); write_Boxes3D(n_boxes3D,boxes_ran,"debug_Box3DRan.dat"); #endif //_DEBUG print_info("*** Correlating \n"); print_info(" - Auto-correlating data \n"); timer(0); auto_3d_ps_bf(nfull_dat,indices_dat,boxes_dat,DD); timer(2); print_info(" - Auto-correlating random \n"); auto_3d_ps_bf(nfull_ran,indices_ran,boxes_ran,RR); timer(2); print_info(" - Cross-correlating \n"); cross_3d_ps_bf(nfull_dat,indices_dat, boxes_dat,boxes_ran,DR); timer(1); print_info("\n"); write_CF(fnameOut,DD,DR,RR, sum_wd,sum_wd2,sum_wr,sum_wr2); print_info("*** Cleaning up\n"); free_Boxes3D(n_boxes3D,boxes_dat); free_Boxes3D(n_boxes3D,boxes_ran); free(indices_dat); free(indices_ran); end_r_z(); free(DD); free(DR); free(RR); }
void run_auto_3d_ps(double *output, int ngals, double *ra, double *dec, double *z, double *w, double r_p_max, int pi_max, int r_p_nbins, int ndecades, int logtrue, double O_M, double O_L) { // set the cosmology from given values omega_M = O_M; omega_L = O_L; corr_type = 9; nb_r=0; // CUTE variables that we need for the calculation np_t sum_wd,sum_wd_2; Catalog cat_dat; Box3D *boxes_dat; int *indices_dat; int nfull_dat; // assume that pi_max is a whole number and we take 1 Mpc bins // Set up a binner object Binner binner; binner.logbin = logtrue; binner.n_logint = r_p_nbins / ndecades; printf("number of logbins is: %d\n", binner.n_logint); binner.dim1_nbin = r_p_nbins; binner.dim2_nbin = pi_max; binner.dim3_nbin = 1; binner.dim1_max = r_p_max; binner.dim2_max = pi_max; binner.dim3_min = 0.08; binner.dim3_max = 0.45; // this is a dummy bin // consistency check and setting more variables process_binner(binner); // Set up the histograms for the measurements. histo_t *DD=(histo_t *)my_calloc(nb_rt*nb_rl,sizeof(histo_t)); timer(4); set_r_z(); // Now to create CUTE catalogues with the arrays cat_dat = make_cat(ra, dec, z, w, ngals, &sum_wd, &sum_wd_2); // set up the boxes for pair-counting printf("*** Boxing catalogs \n"); init_3D_params(cat_dat,cat_dat,3); boxes_dat=mk_Boxes3D_from_Catalog(cat_dat,&indices_dat,&nfull_dat); // Where the meat of the crunching happens. // This is the same code as my original edit of CUTE. printf("\n"); printf(" - Auto-correlating\n"); timer(0); auto_3d_ps_bf(nfull_dat,indices_dat,boxes_dat,DD); timer(1); // Fill the output array that the python wrapper gets. // (write_CF used to be called here) int ii; for(ii=0;ii<nb_rt;ii++) { int jj; double rt=pow(10,((ii+0.5)-nb_rt)/n_logint+log_rt_max); for(jj=0;jj<nb_rl;jj++) { double rl=(jj+0.5)/(nb_rl*i_rl_max); int ind=jj+nb_rl*ii; output[3 * (ii * pi_max + jj)] = rl; output[3 * (ii * pi_max + jj) + 1] = rt; output[3 * (ii * pi_max + jj) + 2] = DD[ind]; } } printf("*** Cleaning up\n"); free_Catalog(cat_dat); free_Boxes3D(n_boxes3D,boxes_dat); free(indices_dat); end_r_z(); free(DD); }