mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
Merge branch 'master' of ssh://bitbucket.org/cosmicvoids/void_identification
This commit is contained in:
commit
5a0f2383b3
26 changed files with 1232 additions and 306 deletions
|
@ -271,7 +271,7 @@ int main(int argc, char **argv) {
|
|||
filename = string(args.outfile_arg);
|
||||
filename = filename.append("summary.out");
|
||||
fp = fopen(filename.c_str(), "w");
|
||||
fprintf(fp, "# void ID, radius, radius ratio, common volume ratio, common volume ratio 2, relative dist, num matches, num significant matches\n");
|
||||
fprintf(fp, "# void ID, radius, radius ratio, common volume ratio, common volume ratio 2, relative dist, num matches, num significant matches, match ID\n");
|
||||
for (iVoid1 = 0; iVoid1 < catalog1.numVoids; iVoid1++) {
|
||||
int voidID = catalog1.voids[iVoid1].voidID;
|
||||
if (catalog1.voids[iVoid1].numMatches > 0) {
|
||||
|
@ -286,14 +286,15 @@ int main(int argc, char **argv) {
|
|||
rdist = catalog1.voids[iVoid1].matches[0].dist;
|
||||
rdist /= catalog1.voids[iVoid1].radius;
|
||||
|
||||
fprintf(fp, "%d %.4f %.4f %.4f %.4f %.4f %d %d\n", voidID,
|
||||
fprintf(fp, "%d %.4f %.4f %.4f %.4f %.4f %d %d %d\n", voidID,
|
||||
catalog1.voids[iVoid1].radiusMpc,
|
||||
rRatio,
|
||||
commonVolRatio,
|
||||
volRatio,
|
||||
rdist,
|
||||
catalog1.voids[iVoid1].numMatches,
|
||||
catalog1.voids[iVoid1].numBigMatches);
|
||||
catalog1.voids[iVoid1].numBigMatches,
|
||||
catalog2.voids[iVoid2].voidID);
|
||||
|
||||
} else {
|
||||
fprintf(fp, "%d %.2f 0.0 0.0 0.0 0.0 0 0\n", voidID,
|
||||
|
|
|
@ -260,7 +260,7 @@ void selectBox(SimuData *simu, std::vector<long>& targets, generateMock_info& ar
|
|||
acceptance =
|
||||
acceptance &&
|
||||
(simu->Pos[j][i] > ranges[j][0]) &&
|
||||
(simu->Pos[j][i] < ranges[j][1]);
|
||||
(simu->Pos[j][i] <= ranges[j][1]);
|
||||
p.Pos[j] = simu->Pos[j][i];
|
||||
p.Vel[j] = (simu->Vel[j] != 0) ? simu->Vel[j][i] : 0;
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ void selectBox(SimuData *simu, std::vector<long>& targets, generateMock_info& ar
|
|||
numAccepted++;
|
||||
}
|
||||
}
|
||||
cout << "Num accepted here = " << numAccepted << " / input = " << simu->NumPart << endl;
|
||||
cout << "SELECTBOX: Num accepted here = " << numAccepted << " / input = " << simu->NumPart << " (after resubsampling)" << endl;
|
||||
}
|
||||
|
||||
class PreselectParticles: public SimulationPreprocessor
|
||||
|
@ -385,7 +385,7 @@ void buildBox(SimuData *simu, long num_targets, long loaded,
|
|||
}
|
||||
}
|
||||
|
||||
void saveBox(SimuData *&boxed, const std::string& outbox)
|
||||
void saveBox(SimuData *&boxed, const std::string& outbox, generateMock_info& args_info)
|
||||
{
|
||||
double *ranges = boxed->as<double>("ranges");
|
||||
NcFile f(outbox.c_str(), NcFile::Replace, 0, 0, NcFile::Netcdf4);
|
||||
|
@ -395,6 +395,11 @@ void saveBox(SimuData *&boxed, const std::string& outbox)
|
|||
int num_snapshots = *boxed->as<int>("num_snapshots");
|
||||
long *uniqueID = boxed->as<long>("uniqueID");
|
||||
|
||||
if (!f.is_valid())
|
||||
{
|
||||
cerr << "Could not create parameter file '" << outbox << "'. Aborting." << endl;
|
||||
exit(1);
|
||||
}
|
||||
f.add_att("range_x_min", ranges[0]);
|
||||
f.add_att("range_x_max", ranges[1]);
|
||||
f.add_att("range_y_min", ranges[2]);
|
||||
|
@ -403,6 +408,7 @@ void saveBox(SimuData *&boxed, const std::string& outbox)
|
|||
f.add_att("range_z_max", ranges[5]);
|
||||
f.add_att("mask_index", -1);
|
||||
f.add_att("is_observation", 0);
|
||||
f.add_att("data_subsampling", args_info.subsample_arg);
|
||||
|
||||
NcDim *NumPart_dim = f.add_dim("numpart_dim", boxed->NumPart);
|
||||
NcDim *NumSnap_dim = f.add_dim("numsnap_dim", num_snapshots);
|
||||
|
@ -446,6 +452,13 @@ void makeBoxFromParameter(SimuData *simu, SimuData* &boxed, generateMock_info& a
|
|||
boxed->time = simu->time;
|
||||
boxed->BoxSize = simu->BoxSize;
|
||||
|
||||
NcAtt *d_sub = f.get_att("data_subsampling");
|
||||
if (d_sub == 0 || d_sub->as_double(0)/args_info.subsample_arg-1. > 1.e-5)
|
||||
{
|
||||
cerr << "Parameter file was not generated with the same simulation subsampling argument. Particles will be different. Stop here." << d_sub->as_double(0) << " " << args_info.subsample_arg <<endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NcVar *v_id = f.get_var("particle_ids");
|
||||
NcVar *v_snap = f.get_var("snapshot_split");
|
||||
long *edges1;
|
||||
|
@ -710,7 +723,7 @@ int main(int argc, char **argv)
|
|||
delete[] efac;
|
||||
}
|
||||
|
||||
saveBox(simuOut, args_info.outputParameter_arg);
|
||||
saveBox(simuOut, args_info.outputParameter_arg, args_info);
|
||||
generateOutput(simuOut, args_info.axis_arg,
|
||||
args_info.output_arg);
|
||||
delete preselector;
|
||||
|
|
|
@ -20,13 +20,16 @@
|
|||
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/format.hpp>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <CosmoTool/loadRamses.hpp>
|
||||
#include <CosmoTool/fortran.hpp>
|
||||
#include "simulation_loader.hpp"
|
||||
#include <libsdf/cosmo.h>
|
||||
|
||||
using boost::format;
|
||||
using namespace std;
|
||||
using namespace CosmoTool;
|
||||
|
||||
|
@ -82,6 +85,12 @@ public:
|
|||
|
||||
double tempData;
|
||||
|
||||
double shift = 0.5*simu->BoxSize;
|
||||
double rescale_position = simu->Hubble*1.e-5*100./simu->time;
|
||||
double rescale_velocity = one_kpc/one_Gyr;
|
||||
#define INFINITY std::numeric_limits<float>::max()
|
||||
float min_pos[3] = {INFINITY,INFINITY, INFINITY}, max_pos[3] = {-INFINITY,-INFINITY,-INFINITY};
|
||||
|
||||
cout << "loading multidark particles" << endl;
|
||||
long actualNumPart = 0;
|
||||
|
||||
|
@ -96,6 +105,17 @@ public:
|
|||
p.Pos[2] == -99 && p.Vel[2] == -99)
|
||||
break;
|
||||
|
||||
//p.Pos[0] = p.Pos[0]*rescale_position + shift;
|
||||
//p.Pos[1] = p.Pos[1]*rescale_position + shift;
|
||||
//p.Pos[2] = p.Pos[2]*rescale_position + shift;
|
||||
//p.Vel[2] = p.Vel[2]*rescale_velocity;
|
||||
|
||||
// enforce box size in case of roundoff error
|
||||
for (int k = 0; k < 3; k++) {
|
||||
if (p.Pos[k] < 0) p.Pos[k] += simu->BoxSize;
|
||||
if (p.Pos[k] >= simu->BoxSize) p.Pos[k] -= simu->BoxSize;
|
||||
}
|
||||
|
||||
if (preproc != 0 && !preproc->accept(p))
|
||||
continue;
|
||||
|
||||
|
@ -110,7 +130,14 @@ public:
|
|||
reallocArray(uniqueID, allocated, actualNumPart);
|
||||
reallocArray(index, allocated, actualNumPart);
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 3; k++) {
|
||||
min_pos[k] = std::min(min_pos[k], p.Pos[k]);
|
||||
max_pos[k] = std::max(max_pos[k], p.Pos[k]);
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < 3; k++) cout << boost::format("min[%d] = %g, max[%d] = %g") % k % min_pos[k] % k %max_pos[k] << endl;
|
||||
|
||||
applyTransformations(simu);
|
||||
simu->NumPart = actualNumPart;
|
||||
simu->TotalNumPart = actualNumPart;
|
||||
|
|
|
@ -190,7 +190,7 @@ public:
|
|||
if (load_flags & (NEED_POSITION | NEED_VELOCITY))
|
||||
rescaleParticles(d, d->Hubble*1e-5, one_kpc/one_Gyr);
|
||||
|
||||
// enforceBoxSize(d);
|
||||
enforceBoxSize(d);
|
||||
applyTransformations(d);
|
||||
basicPreprocessing(d, preproc);
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
#include <netcdfcpp.h>
|
||||
#include "pruneVoids_conf.h"
|
||||
#include <vector>
|
||||
#include "assert.h"
|
||||
#include "voidTree.hpp"
|
||||
#include "loadZobov.hpp"
|
||||
|
||||
#define LIGHT_SPEED 299792.458
|
||||
#define MPC2Z 100./LIGHT_SPEED
|
||||
|
@ -48,6 +51,8 @@
|
|||
#define CENTRAL_VOID 1
|
||||
#define EDGE_VOID 2
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct partStruct {
|
||||
float x, y, z, vol;
|
||||
} PART;
|
||||
|
@ -70,12 +75,26 @@ typedef struct voidStruct {
|
|||
float center[3], barycenter[3];
|
||||
int accepted;
|
||||
int voidType;
|
||||
int parentID, numChildren;
|
||||
bool isLeaf, hasHighCentralDen;
|
||||
gsl_vector *eval;
|
||||
gsl_matrix *evec;
|
||||
} VOID;
|
||||
|
||||
void openFiles(string outputDir, string sampleName, string name,
|
||||
int mockIndex, int numKept,
|
||||
FILE** fpZobov, FILE** fpCenters,
|
||||
FILE** fpCentersNoCut,
|
||||
FILE** fpBarycenter, FILE** fpDistances, FILE** fpShapes,
|
||||
FILE** fpSkyPositions);
|
||||
|
||||
void closeFiles(FILE* fpZobov, FILE* fpCenters,
|
||||
FILE* fpCentersNoCut,
|
||||
FILE* fpBarycenter, FILE* fpDistances, FILE* fpShapes,
|
||||
FILE* fpSkyPositions);
|
||||
|
||||
void outputVoid(int iVoid, VOID outVoid, FILE* fpZobov, FILE* fpCenters,
|
||||
FILE* fpCenterNoCut,
|
||||
FILE* fpCentersNoCut,
|
||||
FILE* fpSkyPositions, FILE* fpBarycenters, FILE* fpDistances,
|
||||
FILE* fpShapes, bool isObservation, double *boxLen);
|
||||
|
||||
|
@ -108,15 +127,12 @@ int main(int argc, char **argv) {
|
|||
int i, p, p2, numPartTot, numZonesTot, dummy, iVoid, iZ;
|
||||
int numVoids, mockIndex, numKept;
|
||||
double tolerance;
|
||||
FILE *fp, *fpZobovCentral, *fpZobovAll, *fpCentersCentral, *fpCentersAll,
|
||||
*fpCentersNoCutCentral, *fpCentersNoCutAll, *fpBarycenterCentral,
|
||||
*fpBarycenterAll, *fpDistancesCentral, *fpDistancesAll,
|
||||
*fpShapesCentral, *fpShapesAll, *fpSkyPositionsCentral,
|
||||
*fpSkyPositionsAll;
|
||||
FILE *fp, *fpZobov, *fpCenters, *fpCentersNoCut, *fpBarycenter,
|
||||
*fpDistances, *fpShapes, *fpSkyPositions;
|
||||
PART *part, *voidPart;
|
||||
ZONE2PART *zones2Parts;
|
||||
VOID2ZONE *void2Zones;
|
||||
std::vector<VOID> voids;
|
||||
vector<VOID> voids;
|
||||
float *temp, junk, voidVol;
|
||||
int junkInt, voidID, numPart, numZones, zoneID, partID, maxNumPart;
|
||||
int coreParticle, zoneNumPart;
|
||||
|
@ -124,6 +140,7 @@ int main(int argc, char **argv) {
|
|||
float centralRad, centralDen;
|
||||
double nearestEdge, redshift;
|
||||
char line[500], junkStr[10];
|
||||
string outputDir, sampleName, name;
|
||||
int mask_index;
|
||||
double ranges[3][2], boxLen[3], mul;
|
||||
double volNorm, radius;
|
||||
|
@ -249,6 +266,9 @@ int main(int argc, char **argv) {
|
|||
|
||||
voids[i-1].radius = pow(voidVol/volNorm*3./4./M_PI, 1./3.);
|
||||
voids[i-1].accepted = 1;
|
||||
|
||||
voids[i-1].isLeaf = true;
|
||||
voids[i-1].hasHighCentralDen = false;
|
||||
|
||||
voids[i-1].eval = gsl_vector_alloc(3);
|
||||
voids[i-1].evec = gsl_matrix_alloc(3,3);
|
||||
|
@ -306,6 +326,27 @@ int main(int argc, char **argv) {
|
|||
fclose(fp);
|
||||
free(temp);
|
||||
|
||||
// load voids *again* using Guilhem's code so we can get tree
|
||||
printf(" Re-loading voids and building tree..\n");
|
||||
ZobovRep zobovCat;
|
||||
if (!loadZobov(args.voidDesc_arg, args.zone2Part_arg,
|
||||
args.void2Zone_arg,
|
||||
0, zobovCat)) {
|
||||
printf("Error loading catalog!\n");
|
||||
return -1;
|
||||
}
|
||||
VoidTree *tree;
|
||||
tree = new VoidTree(zobovCat);
|
||||
zobovCat.allZones.erase(zobovCat.allZones.begin(), zobovCat.allZones.end());
|
||||
//zobovCat.allZones.erase(zobovCat.allVoids.begin(), zobovCat.allVoids.end());
|
||||
|
||||
// copy tree information to our own data structures
|
||||
for (iVoid = 0; iVoid < numVoids; iVoid++) {
|
||||
voidID = voids[iVoid].voidID;
|
||||
voids[iVoid].parentID = tree->getParent(voidID);
|
||||
voids[iVoid].numChildren = tree->getChildren(voidID).size();
|
||||
}
|
||||
|
||||
// check boundaries
|
||||
printf(" Computing void properties...\n");
|
||||
|
||||
|
@ -541,6 +582,7 @@ int main(int argc, char **argv) {
|
|||
int numCentral = 0;
|
||||
int numEdge = 0;
|
||||
int numNearZ = 0;
|
||||
int numAreParents = 0;
|
||||
int numTooSmall = 0;
|
||||
|
||||
printf(" Picking winners and losers...\n");
|
||||
|
@ -607,12 +649,30 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
voids.resize(iGood);
|
||||
printf(" 4th filter: rejected %d too close to low redshift boundaries\n", numNearZ);
|
||||
printf(" 4th filter: rejected %d below redshift boundaries\n", numNearZ);
|
||||
|
||||
numAreParents = 0;
|
||||
iGood = 0;
|
||||
for (iVoid = 0; iVoid < voids.size(); iVoid++) {
|
||||
if (voids[iVoid].numChildren > 0) {
|
||||
numAreParents++;
|
||||
voids[iVoid].isLeaf = false;
|
||||
} else {
|
||||
//voids[iGood++] = voids[iVoid];
|
||||
voids[iVoid].isLeaf = true;
|
||||
}
|
||||
}
|
||||
//voids.resize(iGood);
|
||||
//printf(" 5th filter: rejected %d that are not leaf nodes\n", numAreParents);
|
||||
|
||||
|
||||
for (iVoid = 0; iVoid < voids.size(); iVoid++) {
|
||||
if (voids[iVoid].centralDen > args.maxCentralDen_arg) {
|
||||
voids[iVoid].accepted = -1;
|
||||
voids[iVoid].hasHighCentralDen = true;
|
||||
numHighDen++;
|
||||
} else {
|
||||
voids[iVoid].hasHighCentralDen = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -630,80 +690,46 @@ int main(int argc, char **argv) {
|
|||
printf(" We have %d edge voids\n", numEdge);
|
||||
printf(" We have %d central voids\n", numCentral);
|
||||
printf(" We have %d too high central density\n", numHighDen);
|
||||
|
||||
printf(" We have %d that are not leaf nodes\n", numAreParents);
|
||||
|
||||
printf(" Output...\n");
|
||||
fpZobovCentral = fopen((std::string(args.outputDir_arg)+"/voidDesc_central_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpZobovCentral, "%d particles, %d voids.\n", mockIndex, numKept);
|
||||
fprintf(fpZobovCentral, "Void# FileVoid# CoreParticle CoreDens ZoneVol Zone#Part Void#Zones VoidVol Void#Part VoidDensContrast VoidProb\n");
|
||||
|
||||
fpZobovAll = fopen((std::string(args.outputDir_arg)+"/voidDesc_all_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpZobovAll, "%d particles, %d voids.\n", mockIndex, numKept);
|
||||
fprintf(fpZobovAll, "Void# FileVoid# CoreParticle CoreDens ZoneVol Zone#Part Void#Zones VoidVol Void#Part VoidDensContrast VoidProb\n");
|
||||
|
||||
fpBarycenterCentral = fopen((std::string(args.outputDir_arg)+"/barycenters_central_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fpBarycenterAll = fopen((std::string(args.outputDir_arg)+"/barycenters_all_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
|
||||
fpCentersCentral = fopen((std::string(args.outputDir_arg)+"/centers_central_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpCentersCentral, "# center x,y,z (Mpc/h), volume (normalized), radius (Mpc/h), redshift, volume (Mpc/h^3), void ID, density contrast, num part\n");
|
||||
|
||||
fpCentersAll = fopen((std::string(args.outputDir_arg)+"/centers_all_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpCentersAll, "# center x,y,z (Mpc/h), volume (normalized), radius (Mpc/h), redshift, volume (Mpc/h^3), void ID, density contrast, num part\n");
|
||||
|
||||
fpCentersNoCutCentral = fopen((std::string(args.outputDir_arg)+"/centers_nocut_central_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpCentersNoCutCentral, "# center x,y,z (Mpc/h), volume (normalized), radius (Mpc/h), redshift, volume (Mpc/h^3), void ID, density contrast, num part\n");
|
||||
|
||||
fpCentersNoCutAll = fopen((std::string(args.outputDir_arg)+"/centers_nocut_all_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpCentersNoCutAll, "# center x,y,z (Mpc/h), volume (normalized), radius (Mpc/h), redshift, volume (Mpc/h^3), void ID, density contrast, num part\n");
|
||||
|
||||
|
||||
fpDistancesCentral = fopen((std::string(args.outputDir_arg)+"boundaryDistancesCentral_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fpDistancesAll = fopen((std::string(args.outputDir_arg)+"boundaryDistancesAll_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
|
||||
fpSkyPositionsCentral = fopen((std::string(args.outputDir_arg)+"/sky_positions_central_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpSkyPositionsCentral, "# RA, dec, redshift, radius (Mpc/h), void ID\n");
|
||||
|
||||
fpSkyPositionsAll = fopen((std::string(args.outputDir_arg)+"/sky_positions_all_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpSkyPositionsAll, "# RA, dec, redshift, radius (Mpc/h), void ID\n");
|
||||
|
||||
fpShapesCentral = fopen((std::string(args.outputDir_arg)+"/shapes_central_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpShapesCentral, "# void ID, eig(1), eig(2), eig(3), eigv(1)-x, eiv(1)-y, eigv(1)-z, eigv(2)-x, eigv(2)-y, eigv(2)-z, eigv(3)-x, eigv(3)-y, eigv(3)-z\n");
|
||||
|
||||
fpShapesAll = fopen((std::string(args.outputDir_arg)+"/shapes_all_"+std::string(args.sampleName_arg)+".out").c_str(), "w");
|
||||
fprintf(fpShapesAll, "# void ID, eig(1), eig(2), eig(3), eigv(1)-x, eiv(1)-y, eigv(1)-z, eigv(2)-x, eigv(2)-y, eigv(2)-z, eigv(3)-x, eigv(3)-y, eigv(3)-z\n");
|
||||
|
||||
|
||||
outputDir = string(args.outputDir_arg);
|
||||
sampleName = (string(args.sampleName_arg)+".out");
|
||||
|
||||
name = "central";
|
||||
openFiles(outputDir, sampleName, name,
|
||||
mockIndex, numKept,
|
||||
&fpZobov, &fpCenters, &fpCentersNoCut, &fpBarycenter,
|
||||
&fpDistances, &fpShapes, &fpSkyPositions);
|
||||
|
||||
for (iVoid = 0; iVoid < voids.size(); iVoid++) {
|
||||
|
||||
if (voids[iVoid].voidType == CENTRAL_VOID) {
|
||||
outputVoid(iVoid, voids[iVoid], fpZobovCentral, fpCentersCentral,
|
||||
fpCentersNoCutCentral, fpSkyPositionsCentral,
|
||||
fpBarycenterCentral, fpDistancesCentral, fpShapesCentral,
|
||||
outputVoid(iVoid, voids[iVoid], fpZobov, fpCenters,
|
||||
fpCentersNoCut, fpSkyPositions,
|
||||
fpBarycenter, fpDistances, fpShapes,
|
||||
args.isObservation_flag, boxLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
closeFiles(fpZobov, fpCenters, fpCentersNoCut, fpBarycenter,
|
||||
fpDistances, fpShapes, fpSkyPositions);
|
||||
|
||||
name = "all";
|
||||
openFiles(outputDir, sampleName, name,
|
||||
mockIndex, numKept,
|
||||
&fpZobov, &fpCenters, &fpCentersNoCut, &fpBarycenter,
|
||||
&fpDistances, &fpShapes, &fpSkyPositions);
|
||||
for (iVoid = 0; iVoid < voids.size(); iVoid++) {
|
||||
if (voids[iVoid].voidType == EDGE_VOID ||
|
||||
voids[iVoid].voidType == CENTRAL_VOID) {
|
||||
outputVoid(iVoid, voids[iVoid], fpZobovAll, fpCentersAll,
|
||||
fpCentersNoCutAll, fpSkyPositionsAll,
|
||||
fpBarycenterAll, fpDistancesAll, fpShapesAll,
|
||||
outputVoid(iVoid, voids[iVoid], fpZobov, fpCenters,
|
||||
fpCentersNoCut, fpSkyPositions,
|
||||
fpBarycenter, fpDistances, fpShapes,
|
||||
args.isObservation_flag, boxLen);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fpZobovCentral);
|
||||
fclose(fpZobovAll);
|
||||
fclose(fpCentersCentral);
|
||||
fclose(fpCentersAll);
|
||||
fclose(fpCentersNoCutCentral);
|
||||
fclose(fpCentersNoCutAll);
|
||||
fclose(fpBarycenterCentral);
|
||||
fclose(fpBarycenterAll);
|
||||
fclose(fpDistancesCentral);
|
||||
fclose(fpDistancesAll);
|
||||
fclose(fpShapesCentral);
|
||||
fclose(fpShapesAll);
|
||||
fclose(fpSkyPositionsCentral);
|
||||
fclose(fpSkyPositionsAll);
|
||||
}
|
||||
closeFiles(fpZobov, fpCenters, fpCentersNoCut, fpBarycenter,
|
||||
fpDistances, fpShapes, fpSkyPositions);
|
||||
|
||||
clock2 = clock();
|
||||
printf(" Time: %f sec (for %d voids)\n",
|
||||
|
@ -716,9 +742,57 @@ int main(int argc, char **argv) {
|
|||
} // end main
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void openFiles(string outputDir, string sampleName, string name,
|
||||
int mockIndex, int numKept,
|
||||
FILE** fpZobov, FILE** fpCenters,
|
||||
FILE** fpCentersNoCut,
|
||||
FILE** fpBarycenter, FILE** fpDistances, FILE** fpShapes,
|
||||
FILE** fpSkyPositions) {
|
||||
|
||||
*fpZobov = fopen((outputDir+"/voidDesc_"+name+"_"+sampleName).c_str(), "w");
|
||||
fprintf(*fpZobov, "%d particles, %d voids.\n", mockIndex, numKept);
|
||||
fprintf(*fpZobov, "Void# FileVoid# CoreParticle CoreDens ZoneVol Zone#Part Void#Zones VoidVol Void#Part VoidDensContrast VoidProb\n");
|
||||
|
||||
*fpBarycenter = fopen((outputDir+"/barycenters_"+name+"_"+sampleName).c_str(), "w");
|
||||
|
||||
*fpCenters = fopen((outputDir+"/centers_"+name+"_"+sampleName).c_str(), "w");
|
||||
fprintf(*fpCenters, "# center x,y,z (Mpc/h), volume (normalized), radius (Mpc/h), redshift, volume (Mpc/h^3), void ID, density contrast, num part, parent ID, number of children\n");
|
||||
|
||||
*fpCentersNoCut = fopen((outputDir+"/centers_nocut_"+name+"_"+sampleName).c_str(), "w");
|
||||
fprintf(*fpCentersNoCut, "# center x,y,z (Mpc/h), volume (normalized), radius (Mpc/h), redshift, volume (Mpc/h^3), void ID, density contrast, num part, parent ID, number of children\n");
|
||||
|
||||
|
||||
*fpDistances = fopen((outputDir+"boundaryDistances_"+name+"_"+sampleName).c_str(), "w");
|
||||
|
||||
*fpSkyPositions = fopen((outputDir+"/sky_positions_"+name+"_"+sampleName).c_str(), "w");
|
||||
fprintf(*fpSkyPositions, "# RA, dec, redshift, radius (Mpc/h), void ID\n");
|
||||
|
||||
*fpShapes = fopen((outputDir+"/shapes_"+name+"_"+sampleName).c_str(), "w");
|
||||
fprintf(*fpShapes, "# void ID, eig(1), eig(2), eig(3), eigv(1)-x, eiv(1)-y, eigv(1)-z, eigv(2)-x, eigv(2)-y, eigv(2)-z, eigv(3)-x, eigv(3)-y, eigv(3)-z\n");
|
||||
|
||||
} // end openFiles
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void closeFiles(FILE* fpZobov, FILE* fpCenters,
|
||||
FILE* fpCentersNoCut,
|
||||
FILE* fpBarycenter, FILE* fpDistances, FILE* fpShapes,
|
||||
FILE* fpSkyPositions) {
|
||||
|
||||
fclose(fpZobov);
|
||||
fclose(fpCenters);
|
||||
fclose(fpCentersNoCut);
|
||||
fclose(fpBarycenter);
|
||||
fclose(fpDistances);
|
||||
fclose(fpShapes);
|
||||
fclose(fpSkyPositions);
|
||||
|
||||
} // end closeFile
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void outputVoid(int iVoid, VOID outVoid, FILE* fpZobov, FILE* fpCenters,
|
||||
FILE* fpCenterNoCut, FILE* fpSkyPositions,
|
||||
FILE* fpCentersNoCut, FILE* fpSkyPositions,
|
||||
FILE* fpBarycenters, FILE* fpDistances, FILE* fpShapes,
|
||||
bool isObservation, double *boxLen) {
|
||||
|
||||
|
@ -756,8 +830,8 @@ void outputVoid(int iVoid, VOID outVoid, FILE* fpZobov, FILE* fpCenters,
|
|||
outCenter[2] = (outVoid.barycenter[2]-boxLen[2]/2.)*100.;
|
||||
}
|
||||
|
||||
if (outVoid.accepted == 1) {
|
||||
fprintf(fpCenters, "%.2f %.2f %.2f %.2f %.2f %.5f %.2f %d %f %d\n",
|
||||
if (!outVoid.hasHighCentralDen && outVoid.isLeaf) {
|
||||
fprintf(fpCenters, "%.2f %.2f %.2f %.2f %.2f %.5f %.2f %d %f %d %d %d\n",
|
||||
outCenter[0],
|
||||
outCenter[1],
|
||||
outCenter[2],
|
||||
|
@ -767,10 +841,12 @@ void outputVoid(int iVoid, VOID outVoid, FILE* fpZobov, FILE* fpCenters,
|
|||
4./3.*M_PI*pow(outVoid.radius, 3),
|
||||
outVoid.voidID,
|
||||
outVoid.densCon,
|
||||
outVoid.numPart);
|
||||
outVoid.numPart,
|
||||
outVoid.parentID,
|
||||
outVoid.numChildren);
|
||||
}
|
||||
|
||||
fprintf(fpCenterNoCut, "%.2f %.2f %.2f %.2f %.2f %.5f %.2f %d %f %d\n",
|
||||
fprintf(fpCentersNoCut, "%.2f %.2f %.2f %.2f %.2f %.5f %.2f %d %f %d %d %d\n",
|
||||
outCenter[0],
|
||||
outCenter[1],
|
||||
outCenter[2],
|
||||
|
@ -780,7 +856,9 @@ void outputVoid(int iVoid, VOID outVoid, FILE* fpZobov, FILE* fpCenters,
|
|||
4./3.*M_PI*pow(outVoid.radius, 3),
|
||||
outVoid.voidID,
|
||||
outVoid.densCon,
|
||||
outVoid.numPart);
|
||||
outVoid.numPart,
|
||||
outVoid.parentID,
|
||||
outVoid.numChildren);
|
||||
|
||||
fprintf(fpSkyPositions, "%.2f %.2f %.5f %.2f %d\n",
|
||||
atan((outVoid.barycenter[1]-boxLen[1]/2.) /
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue