useComoving passed to mock_sphere particles + modified lower redshift bound to be consistent with pruneVoids

This commit is contained in:
Marie Aubert 2018-10-11 17:52:01 +02:00
parent 23c9a369ee
commit 3eb3a0cf5d

View file

@ -104,11 +104,17 @@ double expanFun (double z, void * p) {
void loadData(const string& fname, NYU_VData & data) void loadData(const string& fname, NYU_VData & data)
{ {
ifstream f(fname.c_str()); ifstream f(fname.c_str());
int lastidx = -1 ;
while (!f.eof()) while (!f.eof())
{ {
NYU_Data d; NYU_Data d;
f >> d.index >> d.sector >> d.region >> d.ra >> d.dec >> d.cz >> d.fgotten >> d.phi_z; f >> d.index >> d.sector >> d.region >> d.ra >> d.dec >> d.cz >> d.fgotten >> d.phi_z;
// Maubert - avoid double counting of last particle in array if EOF is after a blank line
if (d.index == lastidx ){
continue;
}
lastidx = d.index;
// End Maubert
d.uniqueID = d.index; d.uniqueID = d.index;
data.push_back(d); data.push_back(d);
} }
@ -165,7 +171,8 @@ void generateGalaxiesInCube(NYU_VData& data, ParticleData& output_data,
if (useComoving) { if (useComoving) {
//double pos = gsl_interp_eval(interp, redshifts, dL, data[i].cz, acc); //double pos = gsl_interp_eval(interp, redshifts, dL, data[i].cz, acc);
gsl_integration_qng(&expanF, 1.e-6, data[i].cz/LIGHT_SPEED, // Maubert - Lower boundary in redshift set to 0 to be consistent with pruneVoids (was 1.e-6 before).
gsl_integration_qng(&expanF, 0.0, data[i].cz/LIGHT_SPEED,
1.e-6, 1.e-6,
1.e-6, &result, &error, &nEval); 1.e-6, &result, &error, &nEval);
double Dc = result*LIGHT_SPEED; double Dc = result*LIGHT_SPEED;
@ -220,8 +227,24 @@ void generateSurfaceMask(generateFromCatalog_info& args ,
vector<int>& pixel_list, vector<int>& pixel_list,
vector<int>& full_mask_list, vector<int>& full_mask_list,
NYU_VData& data, NYU_VData& data,
ParticleData& output_data) ParticleData& output_data,
bool useComoving,
double omegaM)
{ {
//Maubert - Needed for comobile distance in mock_sphere
gsl_function expanF;
expanF.function = &expanFun;
struct my_expan_params expanParams;
expanParams.Om = omegaM;
expanParams.w0 = -1.0;
expanParams.wa = 0.0;
expanF.params = &expanParams;
double result, error ;
size_t nEval;
//End Maubert - Needed for comobile distance in mock_sphere
// Find the first free index // Find the first free index
int idx = -1; int idx = -1;
int insertion = 0; int insertion = 0;
@ -367,17 +390,36 @@ void generateSurfaceMask(generateFromCatalog_info& args ,
// PMS // PMS
// TEST - insert mock galaxies along spheres of survey redshift boundaries // TEST - insert mock galaxies along spheres of survey redshift boundaries
fp = fopen("mock_sphere.txt", "w"); fp = fopen("mock_sphere.txt", "w");
//Maubert - insert mock galaxies according to useComoving specification
// Added & compute rmin & rmax out of loop
double rmin ;
double rmax ;
if (useComoving) {
gsl_integration_qng(&expanF, 0.0, args.zMin_arg,
1.e-6,
1.e-6, &result, &error, &nEval);
rmin = result* LIGHT_SPEED;
gsl_integration_qng(&expanF, 0.0, args.zMax_arg,
1.e-6,
1.e-6, &result, &error, &nEval);
rmax = result* LIGHT_SPEED;
} else {
rmin = args.zMin_arg * LIGHT_SPEED;
rmax = args.zMax_arg * LIGHT_SPEED;
}
//for (int q = 0; q < 0; q++) { //for (int q = 0; q < 0; q++) {
for (int q = 0; q < full_mask_list.size(); q++) { for (int q = 0; q < full_mask_list.size(); q++) {
vec3 v = mask.pix2vec(full_mask_list[q]); vec3 v = mask.pix2vec(full_mask_list[q]);
Position p; Position p;
double r = args.zMin_arg * LIGHT_SPEED; //double r = args.zMin_arg * LIGHT_SPEED;
if (r > 0.) {
p.xyz[0] = v.x * r; if (rmin > 0.) {
p.xyz[1] = v.y * r; p.xyz[0] = v.x * rmin;
p.xyz[2] = v.z * r; p.xyz[1] = v.y * rmin;
p.xyz[2] = v.z * rmin;
output_data.pos.push_back(p); output_data.pos.push_back(p);
output_data.id_gal.push_back(idx); output_data.id_gal.push_back(idx);
output_data.ra.push_back(-1); output_data.ra.push_back(-1);
@ -391,10 +433,10 @@ void generateSurfaceMask(generateFromCatalog_info& args ,
(p.xyz[2])); (p.xyz[2]));
} }
r = args.zMax_arg * LIGHT_SPEED; //r = args.zMax_arg * LIGHT_SPEED;
p.xyz[0] = v.x * r; p.xyz[0] = v.x * rmax;
p.xyz[1] = v.y * r; p.xyz[1] = v.y * rmax;
p.xyz[2] = v.z * r; p.xyz[2] = v.z * rmax;
output_data.pos.push_back(p); output_data.pos.push_back(p);
output_data.id_gal.push_back(idx); output_data.id_gal.push_back(idx);
output_data.ra.push_back(-1); output_data.ra.push_back(-1);
@ -590,7 +632,8 @@ int main(int argc, char **argv)
generateGalaxiesInCube(data, output_data, args_info.useComoving_flag, generateGalaxiesInCube(data, output_data, args_info.useComoving_flag,
args_info.omegaM_arg); args_info.omegaM_arg);
generateSurfaceMask(args_info, mask, pixel_list, full_mask_list, generateSurfaceMask(args_info, mask, pixel_list, full_mask_list,
data, output_data); data, output_data,args_info.useComoving_flag,
args_info.omegaM_arg);
saveForZobov(output_data, args_info.output_arg, args_info.params_arg); saveForZobov(output_data, args_info.output_arg, args_info.params_arg);
// saveData(output_data); // saveData(output_data);