mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
reconfigured to put RA, Dec, redshift, and unique (catalog) ID in the binary ZOBOV file
This commit is contained in:
parent
7c3d7a9d31
commit
a53e3bf290
5 changed files with 90 additions and 21 deletions
|
@ -40,6 +40,7 @@ struct ParticleData
|
||||||
vector<double> ra;
|
vector<double> ra;
|
||||||
vector<double> dec;
|
vector<double> dec;
|
||||||
vector<double> redshift;
|
vector<double> redshift;
|
||||||
|
vector<double> catalogID;
|
||||||
int id_mask;
|
int id_mask;
|
||||||
// PMS
|
// PMS
|
||||||
int mask_index;
|
int mask_index;
|
||||||
|
@ -85,6 +86,7 @@ void loadData(const string& fname, NYU_VData & data)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
d.uniqueID = d.index;
|
||||||
data.push_back(d);
|
data.push_back(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +127,7 @@ void generateGalaxiesInCube(NYU_VData& data, ParticleData& output_data,
|
||||||
output_data.ra.resize(data.size());
|
output_data.ra.resize(data.size());
|
||||||
output_data.dec.resize(data.size());
|
output_data.dec.resize(data.size());
|
||||||
output_data.redshift.resize(data.size());
|
output_data.redshift.resize(data.size());
|
||||||
|
output_data.uniqueID.resize(data.size());
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
|
@ -143,7 +146,6 @@ void generateGalaxiesInCube(NYU_VData& data, ParticleData& output_data,
|
||||||
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;
|
||||||
cout << "HELLO " << data[i].cz << " " << Dc << endl;
|
|
||||||
p.xyz[0] = Dc*cos(ra)*cos(dec);
|
p.xyz[0] = Dc*cos(ra)*cos(dec);
|
||||||
p.xyz[1] = Dc*sin(ra)*cos(dec);
|
p.xyz[1] = Dc*sin(ra)*cos(dec);
|
||||||
p.xyz[2] = Dc*sin(dec);
|
p.xyz[2] = Dc*sin(dec);
|
||||||
|
@ -157,6 +159,7 @@ void generateGalaxiesInCube(NYU_VData& data, ParticleData& output_data,
|
||||||
output_data.ra[i] = ra;
|
output_data.ra[i] = ra;
|
||||||
output_data.dec[i] = dec;
|
output_data.dec[i] = dec;
|
||||||
output_data.redshift[i] = data[i].cz;
|
output_data.redshift[i] = data[i].cz;
|
||||||
|
output_data.uniqueID[i] = data[i].uniqueID;
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
|
@ -273,6 +276,7 @@ void generateSurfaceMask(generateFromCatalog_info& args ,
|
||||||
output_data.ra.push_back(-1);
|
output_data.ra.push_back(-1);
|
||||||
output_data.dec.push_back(-1);
|
output_data.dec.push_back(-1);
|
||||||
output_data.redshift.push_back(-1);
|
output_data.redshift.push_back(-1);
|
||||||
|
output_data.uniqueID.push_back(-1);
|
||||||
//printf("INSERT MOCK %d %e %e %e\n", idx, p.xyz[0], p.xyz[1], p.xyz[2]);
|
//printf("INSERT MOCK %d %e %e %e\n", idx, p.xyz[0], p.xyz[1], p.xyz[2]);
|
||||||
insertion++;
|
insertion++;
|
||||||
}
|
}
|
||||||
|
@ -310,6 +314,7 @@ void generateSurfaceMask(generateFromCatalog_info& args ,
|
||||||
output_data.ra.push_back(-1);
|
output_data.ra.push_back(-1);
|
||||||
output_data.dec.push_back(-1);
|
output_data.dec.push_back(-1);
|
||||||
output_data.redshift.push_back(-1);
|
output_data.redshift.push_back(-1);
|
||||||
|
output_data.uniqueID.push_back(-1);
|
||||||
insertion++;
|
insertion++;
|
||||||
|
|
||||||
fprintf(fp, "%e %e %e\n",
|
fprintf(fp, "%e %e %e\n",
|
||||||
|
@ -341,6 +346,7 @@ void generateSurfaceMask(generateFromCatalog_info& args ,
|
||||||
output_data.ra.push_back(-1);
|
output_data.ra.push_back(-1);
|
||||||
output_data.dec.push_back(-1);
|
output_data.dec.push_back(-1);
|
||||||
output_data.redshift.push_back(-1);
|
output_data.redshift.push_back(-1);
|
||||||
|
output_data.uniqueID.push_back(-1);
|
||||||
insertion++;
|
insertion++;
|
||||||
fprintf(fp, "%e %e %e\n",
|
fprintf(fp, "%e %e %e\n",
|
||||||
(p.xyz[0]),
|
(p.xyz[0]),
|
||||||
|
@ -357,6 +363,7 @@ void generateSurfaceMask(generateFromCatalog_info& args ,
|
||||||
output_data.ra.push_back(-1);
|
output_data.ra.push_back(-1);
|
||||||
output_data.dec.push_back(-1);
|
output_data.dec.push_back(-1);
|
||||||
output_data.redshift.push_back(-1);
|
output_data.redshift.push_back(-1);
|
||||||
|
output_data.uniqueID.push_back(-1);
|
||||||
insertion++;
|
insertion++;
|
||||||
fprintf(fp, "%e %e %e\n",
|
fprintf(fp, "%e %e %e\n",
|
||||||
(p.xyz[0]),
|
(p.xyz[0]),
|
||||||
|
@ -414,11 +421,40 @@ void saveForZobov(ParticleData& pdata, const string& fname, const string& paramn
|
||||||
for (uint32_t i = 0; i < pdata.pos.size(); i++)
|
for (uint32_t i = 0; i < pdata.pos.size(); i++)
|
||||||
{
|
{
|
||||||
f.writeReal32((pdata.pos[i].xyz[j]+Lmax)/(2*Lmax));
|
f.writeReal32((pdata.pos[i].xyz[j]+Lmax)/(2*Lmax));
|
||||||
if (i < 10) printf("TEST WRITE %d %e\n", (pdata.pos[i].xyz[j]+Lmax)/(2*Lmax));
|
|
||||||
}
|
}
|
||||||
f.endCheckpoint();
|
f.endCheckpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << format("Writing RA...") << endl;
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (uint32_t i = 0; i < pdata.pos.size(); i++) {
|
||||||
|
f.writeReal32(pdata.pos[i].ra);
|
||||||
|
}
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
cout << format("Writing Dec...") << endl;
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (uint32_t i = 0; i < pdata.pos.size(); i++) {
|
||||||
|
f.writeReal32(pdata.pos[i].Dec);
|
||||||
|
}
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
cout << format("Writing Redshift...") << endl;
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (uint32_t i = 0; i < pdata.pos.size(); i++) {
|
||||||
|
f.writeReal32(pdata.pos[i].cz);
|
||||||
|
}
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
cout << format("Writing Unique ID...") << endl;
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (uint32_t i = 0; i < pdata.pos.size(); i++) {
|
||||||
|
f.writeReal32(pdata.pos[i].uniqueID);
|
||||||
|
}
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
NcFile fp(paramname.c_str(), NcFile::Replace);
|
||||||
|
NcFile fp(paramname.c_str(), NcFile::Replace);
|
||||||
NcFile fp(paramname.c_str(), NcFile::Replace);
|
NcFile fp(paramname.c_str(), NcFile::Replace);
|
||||||
|
|
||||||
fp.add_att("range_x_min", -Lmax/100.);
|
fp.add_att("range_x_min", -Lmax/100.);
|
||||||
|
@ -434,9 +470,6 @@ if (i < 10) printf("TEST WRITE %d %e\n", (pdata.pos[i].xyz[j]+Lmax)/(2*Lmax));
|
||||||
|
|
||||||
NcDim *NumPart_dim = fp.add_dim("numpart_dim", nOutputPart);
|
NcDim *NumPart_dim = fp.add_dim("numpart_dim", nOutputPart);
|
||||||
NcVar *v = fp.add_var("particle_ids", ncInt, NumPart_dim);
|
NcVar *v = fp.add_var("particle_ids", ncInt, NumPart_dim);
|
||||||
NcVar *vra = fp.add_var("RA", ncInt, NumPart_dim);
|
|
||||||
NcVar *vdec = fp.add_var("DEC", ncInt, NumPart_dim);
|
|
||||||
NcVar *vredshift = fp.add_var("z", ncInt, NumPart_dim);
|
|
||||||
//NcVar *v2 = fp.add_var("expansion", ncDouble, NumPart_dim);
|
//NcVar *v2 = fp.add_var("expansion", ncDouble, NumPart_dim);
|
||||||
|
|
||||||
//double *expansion_fac = new double[pdata.pos.size()];
|
//double *expansion_fac = new double[pdata.pos.size()];
|
||||||
|
@ -445,9 +478,6 @@ if (i < 10) printf("TEST WRITE %d %e\n", (pdata.pos[i].xyz[j]+Lmax)/(2*Lmax));
|
||||||
// expansion_fac[i] = 1.0;
|
// expansion_fac[i] = 1.0;
|
||||||
|
|
||||||
v->put(&pdata.id_gal[0], nOutputPart);
|
v->put(&pdata.id_gal[0], nOutputPart);
|
||||||
vra->put(&pdata.ra[0], nOutputPart);
|
|
||||||
vdec->put(&pdata.dec[0], nOutputPart);
|
|
||||||
vredshift->put(&pdata.redshift[0], nOutputPart);
|
|
||||||
//v2->put(expansion_fac, pdata.pos.size());
|
//v2->put(expansion_fac, pdata.pos.size());
|
||||||
|
|
||||||
//delete[] expansion_fac;
|
//delete[] expansion_fac;
|
||||||
|
|
|
@ -178,14 +178,17 @@ SimuData *doLoadMultidark(const char *multidarkname)
|
||||||
for (int k = 0; k < 3; k++)
|
for (int k = 0; k < 3; k++)
|
||||||
outd->Pos[k] = new float[outd->NumPart];
|
outd->Pos[k] = new float[outd->NumPart];
|
||||||
outd->Vel[2] = new float[outd->NumPart];
|
outd->Vel[2] = new float[outd->NumPart];
|
||||||
|
outd->uniqueID = new float[outd->NumPart];
|
||||||
|
|
||||||
cout << "loading multidark particles" << endl;
|
cout << "loading multidark particles" << endl;
|
||||||
actualNumPart = 0;
|
actualNumPart = 0;
|
||||||
for (int i = 0; i < outd->NumPart; i++) {
|
for (int i = 0; i < outd->NumPart; i++) {
|
||||||
fscanf(fp, "%f %f %f %f\n", &outd->Pos[0][i], &outd->Pos[1][i],
|
fscanf(fp, "%d %f %f %f %f\n", &outd->uniqueID[i],
|
||||||
|
&outd->Pos[0][i], &outd->Pos[1][i],
|
||||||
&outd->Pos[2][i], &outd->Vel[2][i]);
|
&outd->Pos[2][i], &outd->Vel[2][i]);
|
||||||
|
|
||||||
if (outd->Pos[0][i] == -99 && outd->Pos[1][i] == -99 &&
|
if (outd->uniqueID[i] == -99 &&
|
||||||
|
outd->Pos[0][i] == -99 && outd->Pos[1][i] == -99 &&
|
||||||
outd->Pos[2][i] == -99 && outd->Vel[2][i] == -99) {
|
outd->Pos[2][i] == -99 && outd->Vel[2][i] == -99) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -361,6 +364,39 @@ void generateOutput(SimuData *data, int axis,
|
||||||
}
|
}
|
||||||
f.endCheckpoint();
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
cout << "Writing RA..." << endl;
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (uint32_t i = 0; i < data->NumPart; i++)
|
||||||
|
{
|
||||||
|
f.writeReal32(data->uniqueID[i]);
|
||||||
|
}
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
cout << "Writing Dec..." << endl;
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (uint32_t i = 0; i < data->NumPart; i++)
|
||||||
|
{
|
||||||
|
f.writeReal32(data->uniqueID[i]);
|
||||||
|
}
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
cout << "Writing redshift..." << endl;
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (uint32_t i = 0; i < data->NumPart; i++)
|
||||||
|
{
|
||||||
|
f.writeReal32(data->uniqueID[i]);
|
||||||
|
}
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
cout << "Writing unique ID..." << endl;
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (uint32_t i = 0; i < data->NumPart; i++)
|
||||||
|
{
|
||||||
|
f.writeReal32(data->uniqueID[i]);
|
||||||
|
}
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeBox(SimuData *simu, double *efac, SimuData *&boxed, generateMock_info& args_info)
|
void makeBox(SimuData *simu, double *efac, SimuData *&boxed, generateMock_info& args_info)
|
||||||
|
|
|
@ -529,7 +529,7 @@ int main(int argc, char **argv) {
|
||||||
outCenter[2] = (voids[iVoid].barycenter[2]-boxLen[2]/2.)*100.;
|
outCenter[2] = (voids[iVoid].barycenter[2]-boxLen[2]/2.)*100.;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fpInfo, "%.2f %.2f %.2f %.2f %.2f %.5f %.2f %d\n",
|
fprintf(fpInfo, "%.2f %.2f %.2f %.2f %.2f %.5f %.2f %d %f\n",
|
||||||
outCenter[0],
|
outCenter[0],
|
||||||
outCenter[1],
|
outCenter[1],
|
||||||
outCenter[2],
|
outCenter[2],
|
||||||
|
@ -537,7 +537,8 @@ int main(int argc, char **argv) {
|
||||||
voids[iVoid].radius,
|
voids[iVoid].radius,
|
||||||
voids[iVoid].redshift,
|
voids[iVoid].redshift,
|
||||||
4./3.*M_PI*pow(voids[iVoid].radius, 3),
|
4./3.*M_PI*pow(voids[iVoid].radius, 3),
|
||||||
voids[iVoid].voidID
|
voids[iVoid].voidID,
|
||||||
|
voids[iVoid].densCon,
|
||||||
);
|
);
|
||||||
|
|
||||||
fprintf(fpSkyPositions, "%.2f %.2f %.5f %.2f %d\n",
|
fprintf(fpSkyPositions, "%.2f %.2f %.5f %.2f %d\n",
|
||||||
|
@ -572,7 +573,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fprintf(fpInfo, "%.2f %.2f %.2f %.2f %.2f %.5f %.2f %d\n",
|
fprintf(fpInfo, "%.2f %.2f %.2f %.2f %.2f %.5f %.2f %d %f\n",
|
||||||
outCenter[0],
|
outCenter[0],
|
||||||
outCenter[1],
|
outCenter[1],
|
||||||
outCenter[2],
|
outCenter[2],
|
||||||
|
@ -580,7 +581,8 @@ int main(int argc, char **argv) {
|
||||||
voids[iVoid].radius,
|
voids[iVoid].radius,
|
||||||
voids[iVoid].redshift,
|
voids[iVoid].redshift,
|
||||||
4./3.*M_PI*pow(voids[iVoid].radius, 3),
|
4./3.*M_PI*pow(voids[iVoid].radius, 3),
|
||||||
voids[iVoid].voidID);
|
voids[iVoid].voidID,
|
||||||
|
voids[iVoid].densCon);
|
||||||
}
|
}
|
||||||
fclose(fpInfo);
|
fclose(fpInfo);
|
||||||
|
|
||||||
|
|
3
external/cosmotool/src/loadSimu.hpp
vendored
3
external/cosmotool/src/loadSimu.hpp
vendored
|
@ -24,9 +24,10 @@ namespace CosmoTool
|
||||||
int *Id;
|
int *Id;
|
||||||
float *Pos[3];
|
float *Pos[3];
|
||||||
float *Vel[3];
|
float *Vel[3];
|
||||||
|
float *uniqueID;
|
||||||
int *type;
|
int *type;
|
||||||
public:
|
public:
|
||||||
SimuData() : Id(0),NumPart(0),type(0) { Pos[0]=Pos[1]=Pos[2]=0; Vel[0]=Vel[1]=Vel[2]=0; }
|
SimuData() : Id(0),NumPart(0),type(0), uniqueID(0) { Pos[0]=Pos[1]=Pos[2]=0; Vel[0]=Vel[1]=Vel[2]=0; uniqueID=0}
|
||||||
~SimuData()
|
~SimuData()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
|
|
|
@ -284,7 +284,7 @@ for thisSubSample in subSamples:
|
||||||
outFile.write("%d\n" %(maxKeep))
|
outFile.write("%d\n" %(maxKeep))
|
||||||
|
|
||||||
numKept = 0
|
numKept = 0
|
||||||
for line in inFile:
|
for (i,line) in enumerate(inFile):
|
||||||
if np.random.uniform() > keepFraction: continue
|
if np.random.uniform() > keepFraction: continue
|
||||||
numKept += 1
|
numKept += 1
|
||||||
if numKept > maxKeep: break
|
if numKept > maxKeep: break
|
||||||
|
@ -294,9 +294,9 @@ for thisSubSample in subSamples:
|
||||||
z = float(line[2])
|
z = float(line[2])
|
||||||
vz = float(line[3])
|
vz = float(line[3])
|
||||||
|
|
||||||
outFile.write("%e %e %e %e\n" %(x,y,z,vz))
|
outFile.write("%d %e %e %e %e\n" %(i,x,y,z,vz))
|
||||||
|
|
||||||
outFile.write("-99 -99 -99 -99\n")
|
outFile.write("-99 -99 -99 -99 -99\n")
|
||||||
inFile.close()
|
inFile.close()
|
||||||
outFile.close()
|
outFile.close()
|
||||||
|
|
||||||
|
@ -315,9 +315,9 @@ for thisSubSample in subSamples:
|
||||||
y = np.random.uniform()*lbox
|
y = np.random.uniform()*lbox
|
||||||
z = np.random.uniform()*lbox
|
z = np.random.uniform()*lbox
|
||||||
|
|
||||||
outFile.write("%e %e %e %e\n" %(x,y,z, 0.))
|
outFile.write("%d %e %e %e %e\n" % (i, x,y,z, 0.))
|
||||||
|
|
||||||
outFile.write("-99 -99 -99 -99\n")
|
outFile.write("-99 -99 -99 -99 -99\n")
|
||||||
outFile.close()
|
outFile.close()
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ if args.halos or args.all:
|
||||||
vz = float(line[5])
|
vz = float(line[5])
|
||||||
|
|
||||||
# write to output file
|
# write to output file
|
||||||
outFile.write("%e %e %e %e\n" %(x,y,z,vz))
|
outFile.write("%d %e %e %e %e\n" %(numKept,x,y,z,vz))
|
||||||
|
|
||||||
inFile.close()
|
inFile.close()
|
||||||
outFile.close()
|
outFile.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue