removed mock particle tracking, since that is no longer used

This commit is contained in:
Paul M. Sutter 2025-04-21 16:23:25 -04:00
parent fc2d7157f4
commit d9efa15474
8 changed files with 71 additions and 173 deletions

View file

@ -64,9 +64,6 @@ struct ParticleData
vector<double> redshift;
vector<double> catalogID;
vector<long> uniqueID;
// PMS
int mask_index;
// END PMS
int edgeFlag = 0;
vector<Position> pos;
double box[3][2];
@ -263,12 +260,8 @@ void flagEdgeGalaxies(prepObservation_info& args ,
size_t nEval;
//End Maubert - Needed for comobile distance in mock_sphere
// TODO - REMOVE THIS
output_data.mask_index = output_data.id_gal.size();
// write a small text file with galaxy position (for diagnostic purposes)
// TODO - remove this
FILE *fp;
fp = fopen("galaxies.txt", "w");
//for (int i = 0; i < output_data.id_gal.size(); i++) {
@ -414,11 +407,9 @@ void saveForZobov(ParticleData& pdata, const string& fname,
fp.putAtt("range_y_max", ncDouble, Lmax/100.);
fp.putAtt("range_z_min", ncDouble, -Lmax/100.);
fp.putAtt("range_z_max", ncDouble, Lmax/100.);
fp.putAtt("mask_index", ncInt, pdata.mask_index); // PMS
fp.putAtt("is_observation", ncInt, 1); // PMS
fp.putAtt("is_observation", ncInt, 1);
int nOutputPart = pdata.mask_index;
//int nOutputPart = pdata.pos.size();
int nOutputPart = pdata.pos.size();
NcDim NumPart_dim = fp.addDim("numpart_dim", nOutputPart);
NcVar v = fp.addVar("particle_ids", ncInt, NumPart_dim);
@ -497,10 +488,7 @@ int main(int argc, char **argv)
saveForZobov(output_data, args_info.output_arg, args_info.params_arg);
// PMS - TODO REMOVE THIS
FILE *fp = fopen("mask_index.txt", "w");
fprintf(fp, "%d", output_data.mask_index);
fclose(fp);
FILE *fp;
fp = fopen("total_particles.txt", "w");
fprintf(fp, "%d", output_data.pos.size());
fclose(fp);

View file

@ -116,7 +116,7 @@ double expanFun (double z, void * p) {
void openFiles(string outputDir, string sampleName,
string prefix, string dataPortion,
int mockIndex, int numKept,
int numPartTot, int numKept,
FILE** fpZobov, FILE** fpCenters,
FILE** fpCentersNoCut,
FILE** fpBarycenter, FILE** fpShapes,
@ -128,7 +128,7 @@ void closeFiles(FILE* fpZobov, FILE* fpCenters,
FILE* fpSkyPositions);
void outputVoids(string outputDir, string sampleName, string prefix,
string dataPortion, int mockIndex,
string dataPortion, int numPartTot,
vector<VOID> voids,
bool isObservation, double *boxLen,
bool doTrim, bool doCentralDenCut);
@ -187,7 +187,7 @@ int main(int argc, char **argv) {
int i, p, p2, numPartTot, numZonesTot, dummy, iVoid;
int numVoids, mockIndex;
int numVoids;
double tolerance;
FILE *fp;
PART *part, *voidPart, *flaggedPart;
@ -202,7 +202,6 @@ int main(int argc, char **argv) {
double nearestEdge, redshift;
char line[500], junkStr[10];
string outputDir, sampleName, dataPortion, prefix;
int mask_index;
double ranges[3][2], boxLen[3], mul;
double volNorm, radius;
int clock1, clock2, clock3, clock4;
@ -213,7 +212,6 @@ int main(int argc, char **argv) {
gsl_eigen_symmv_workspace *eigw = gsl_eigen_symmv_alloc(3);
numVoids = args.numVoids_arg;
mockIndex = args.mockIndex_arg;
tolerance = args.tolerance_arg;
clock1 = clock();
@ -309,9 +307,6 @@ int main(int argc, char **argv) {
interval = 1.*(clock4 - clock3)/CLOCKS_PER_SEC;
printf(" Read %d particles (%.2f sec)...\n", numPartTot, interval);
if (mockIndex == -1) mockIndex = numPartTot;
// read in desired voids
clock3 = clock();
printf(" Loading voids...\n");
@ -393,12 +388,8 @@ int main(int argc, char **argv) {
// and volumes
printf(" Loading particle volumes...\n");
fp = fopen(args.partVol_arg, "r");
fread(&mask_index, 1, 4, fp);
if (mask_index != mockIndex) {
printf("NON-MATCHING MOCK INDICES!? %d %d\n", mask_index, mockIndex);
exit(-1);
}
for (p = 0; p < mask_index; p++) {
fread(&numPartTot, 1, 4, fp);
for (p = 0; p < numPartTot; p++) {
fread(&temp[0], 1, 4, fp);
part[p].vol = temp[0];
}
@ -408,7 +399,7 @@ int main(int argc, char **argv) {
printf(" Loading particle edge flags...\n");
int numFlagged = 0;
fp = fopen(args.partEdge_arg, "r");
for (p = 0; p < mask_index; p++) {
for (p = 0; p < numPartTot; p++) {
fscanf(fp, "%d", &part[p].edgeFlag);
if (part[p].edgeFlag > 0) numFlagged++;
}
@ -417,7 +408,7 @@ int main(int argc, char **argv) {
// copy flagged galaxies to separate array for faster processing later
flaggedPart = (PART *) malloc(numFlagged * sizeof(PART));
int iFlag = 0;
for (p = 0; p < mask_index; p++) {
for (p = 0; p < numPartTot; p++) {
if (part[p].edgeFlag > 0) {
flaggedPart[iFlag] = part[p];
iFlag++;
@ -428,20 +419,20 @@ int main(int argc, char **argv) {
// and finally finally adjacencies
printf(" Loading particle adjacencies...\n");
fp = fopen(args.partAdj_arg, "r");
fread(&mask_index, 1, 4, fp);
if (mask_index != mockIndex) {
printf("NON-MATCHING MOCK INDICES!? %d %d\n", mask_index, mockIndex);
fread(&numPartTot, 1, 4, fp);
if (numPartTot != numPartTot) {
printf("NON-MATCHING MOCK INDICES!? %d %d\n", numPartTot, numPartTot);
exit(-1);
}
int tempInt;
for (p = 0; p < mask_index; p++) {
for (p = 0; p < numPartTot; p++) {
fread(&tempInt, 1, 4, fp);
part[p].nadj = tempInt;
part[p].ncnt = 0;
if (part[p].nadj > 0)
part[p].adj = (int *) malloc(part[p].nadj * sizeof(int));
}
for (p = 0; p < mask_index; p++) {
for (p = 0; p < numPartTot; p++) {
fread(&tempInt, 1, 4, fp);
int nin = tempInt;
if (nin > 0) {
@ -452,7 +443,7 @@ int main(int argc, char **argv) {
// this bit has been readjusted just in case we are
// accidentally still linking to mock particles
//if (tempAdj < mask_index) {
//if (tempAdj < numPartTot) {
assert(p < tempAdj);
//if (part[p].ncnt == part[p].nadj) {
// printf("OVERFLOW %d\n", p);
@ -461,7 +452,7 @@ int main(int argc, char **argv) {
//} else {
part[p].adj[part[p].ncnt] = tempAdj;
part[p].ncnt++;
if (tempAdj < mask_index) {
if (tempAdj < numPartTot) {
part[tempAdj].adj[part[tempAdj].ncnt] = p;
part[tempAdj].ncnt++;
}
@ -542,9 +533,8 @@ int main(int argc, char **argv) {
partID = zones2Parts[zoneID].partIDs[p];
// something went haywire
if (partID > mask_index ||
(part[partID].vol < 1.e-27 && part[partID].vol > 0.)) {
printf("BAD PART!? %d %d %e", partID, mask_index, part[partID].vol);
if (part[partID].vol < 1.e-27 && part[partID].vol > 0.) {
printf("BAD PART!? %d %d %e", partID, numPartTot, part[partID].vol);
exit(-1);
}
@ -567,7 +557,7 @@ int main(int argc, char **argv) {
//printf("NORMAL!! %d %d %e\n", iVoid, partID, part[partID].vol);
}
for (int iAdj = 0; iAdj < part[partID].ncnt; iAdj++) {
if (part[partID].adj[iAdj] > mockIndex) {
if (part[partID].adj[iAdj] > numPartTot) {
printf("CONTAMINATED!! %d %d %d\n", iVoid, partID, iAdj);
}
}
@ -949,7 +939,7 @@ int main(int argc, char **argv) {
for (int i = 0; i < 2; i++) {
dataPortion = dataPortions[i];
outputVoids(outputDir, sampleName, prefix, dataPortion,
mockIndex,
numPartTot,
voids,
args.isObservation_flag, boxLen, true, true);
}
@ -959,7 +949,7 @@ int main(int argc, char **argv) {
for (int i = 0; i < 2; i++) {
dataPortion = dataPortions[i];
outputVoids(outputDir, sampleName, prefix, dataPortion,
mockIndex,
numPartTot,
voids,
args.isObservation_flag, boxLen, false, false);
}
@ -977,14 +967,14 @@ int main(int argc, char **argv) {
// ----------------------------------------------------------------------------
void openFiles(string outputDir, string sampleName,
string prefix, string dataPortion,
int mockIndex, int numKept,
int numPartTot, int numKept,
FILE** fpZobov, FILE** fpCenters,
FILE** fpBarycenter, FILE** fpShapes,
FILE** fpExtra,
FILE** fpSkyPositions) {
*fpZobov = fopen((outputDir+"/"+prefix+"voidDesc_"+dataPortion+"_"+sampleName).c_str(), "w");
fprintf(*fpZobov, "%d particles, %d voids.\n", mockIndex, numKept);
fprintf(*fpZobov, "%d particles, %d voids.\n", numPartTot, numKept);
fprintf(*fpZobov, "Void# FileVoid# CoreParticle CoreDens ZoneVol Zone#Part Void#Zones VoidVol Void#Part VoidDensContrast VoidProb\n");
*fpBarycenter = fopen((outputDir+"/"+prefix+"macrocenters_"+dataPortion+"_"+sampleName).c_str(), "w");
@ -1022,7 +1012,7 @@ void closeFiles(FILE* fpZobov, FILE* fpCenters,
// ----------------------------------------------------------------------------
void outputVoids(string outputDir, string sampleName, string prefix,
string dataPortion, int mockIndex,
string dataPortion, int numPartTot,
vector<VOID> voids,
bool isObservation, double *boxLen, bool doTrim,
bool doCentralDenCut) {
@ -1034,7 +1024,7 @@ void outputVoids(string outputDir, string sampleName, string prefix,
openFiles(outputDir, sampleName, prefix, dataPortion,
mockIndex, voids.size(),
numPartTot, voids.size(),
&fpZobov, &fpCenters, &fpBarycenter,
&fpShapes, &fpExtra, &fpSkyPositions);

View file

@ -19,7 +19,6 @@ option "partAdj" - "Adjacency file from ZOBOV" string required
option "partEdge" - "Boundary flag file" string required
option "zone2Part" - "Particle file from ZOBOV" string required
option "mockIndex" - "Beginning index of mock particles" int required
option "numVoids" - "Number of voids" int required

View file

@ -61,8 +61,6 @@ int main(int argc,char **argv) {
double *sorter, e1,maxdenscontrast;
int *iord;
int mockIndex;
e1 = exp(1.)-1.;
if (argc != 8) {
@ -73,7 +71,6 @@ int main(int argc,char **argv) {
printf("arg4: output file containing zones in each void\n");
printf("arg5: output text file\n");
printf("arg6: Density threshold (0 for no threshold)\n");
printf("arg7: Beginning index of mock galaxies\n\n");
exit(0);
}
adjfile = argv[1];
@ -85,10 +82,6 @@ int main(int argc,char **argv) {
printf("Bad density threshold.\n");
exit(0);
}
if (sscanf(argv[7],"%d",&mockIndex) == 0) {
printf("Bad mock galaxy index.\n");
exit(0);
}
printf("TOLERANCE: %f\n", voltol);
if (voltol <= 0.) {
printf("Proceeding without a density threshold.\n");
@ -101,8 +94,6 @@ int main(int argc,char **argv) {
exit(0);
}
fread(&np,1, sizeof(int),adj);
if (mockIndex < 0)
mockIndex = np;
printf("adj: %d particles\n", np);
FF;
@ -158,7 +149,7 @@ int main(int argc,char **argv) {
for (i=0;i<np;i++) {
/* fread(&nin,1,sizeof(int),adj); /* actually nadj */
// PMS
if (p[i].ncnt != p[i].nadj && i < mockIndex) {
if (p[i].ncnt != p[i].nadj && i < np) {
/*if (p[i].ncnt != p[i].nadj) {*/
// END PMS
p[i].nadj = p[i].ncnt;
@ -183,10 +174,7 @@ int main(int argc,char **argv) {
FF;
for (i=0;i<np;i++) {
fread(&p[i].dens,1,sizeof(float),vol);
// PMS
if ((p[i].dens < 1e-30) || (p[i].dens > 1e30) && i < mockIndex) {
//if ((p[i].dens < 1e-30) || (p[i].dens > 1e30)) {
// END PMS
if ((p[i].dens < 1e-30) || (p[i].dens > 1e30)) {
printf("Whacked-out volume found, of particle %d: %f\n",i,p[i].dens);
p[i].dens = 1.;
}

View file

@ -28,19 +28,17 @@ int main(int argc, char *argv[]) {
int numGuards;
int b[3];
int numThreads;
int mockIndex;
if (argc != 10) {
if (argc != 9) {
printf("Wrong number of arguments.\n");
printf("arg1: position file\n");
printf("arg2: buffer size (default 0.1)\n");
printf("arg3: box size\n");
printf("arg6: number of divisions (default 2)\n");
printf("arg7: suffix describing this run\n");
printf("arg8: number of parallel threads\n");
printf("arg9: location of voboz executables\n");
printf("arg10: output directory\n");
printf("arg11: index of mock galaxies\n\n");
printf("arg4: number of divisions (default 2)\n");
printf("arg5: suffix describing this run\n");
printf("arg6: number of parallel threads\n");
printf("arg7: location of voboz executables\n");
printf("arg8: output directory\n");
exit(0);
}
posfile = argv[1];
@ -72,11 +70,6 @@ int main(int argc, char *argv[]) {
}
vobozPath = argv[7];
outDir = argv[8];
if (sscanf(argv[9],"%d",&mockIndex) != 1) {
printf("That's no mock galaxy index; try again.\n");
exit(0);
}
/* Read the position file */
np = posread(posfile,&rfloat,1./boxsize);
@ -187,7 +180,7 @@ int main(int argc, char *argv[]) {
}
}
fprintf(scr,"wait\n");
fprintf(scr,"%s/voztie %d %s %s %d\n", vobozPath, numdiv,suffix, outDir, mockIndex);
fprintf(scr,"%s/voztie %d %s %s %d\n", vobozPath, numdiv,suffix, outDir);
fclose(scr);
sprintf(systemstr,"chmod u+x %s",scrfile);

View file

@ -34,10 +34,6 @@ int main(int argc, char *argv[]) {
int numRemoved = 0;
// PMS
int mockIndex;
// END PMS
if (argc != 5) {
printf("Wrong number of arguments.\n");
printf("arg1: number of divisions (default 2)\n");
@ -57,10 +53,6 @@ int main(int argc, char *argv[]) {
suffix = argv[2];
outDir = argv[3];
if (sscanf(argv[4],"%d",&mockIndex) != 1) {
printf("That's no mock galaxy index; try again.\n");
exit(0);
}
np = -1; nvpmax = -1; nvpsum = 0;
@ -92,10 +84,6 @@ int main(int argc, char *argv[]) {
printf("We have %d particles to tie together.\n",np); fflush(stdout);
printf("The maximum number of particles in a file is %d.\n",nvpmax);
// PMS
if (mockIndex == -1) mockIndex = np;
// END PMS
cnt_adj = (int *)malloc(np*sizeof(int));
if (cnt_adj == NULL)
printf("Could not allocate cnt_adj.\n");
@ -137,7 +125,7 @@ int main(int argc, char *argv[]) {
for (p=0;p<nvp;p++) {
fread(&volstemp,1,sizeof(float),part);
if (vols[orig[p]] > -1.)
if (fabs(vols[orig[p]]-volstemp)/volstemp > 1.5e-3 && orig[p] < mockIndex) {
if (fabs(vols[orig[p]]-volstemp)/volstemp > 1.5e-3) {
printf("Inconsistent volumes for p. %d: (%10g,%10g)!\n",
orig[p],vols[orig[p]],volstemp);
//exit(0);
@ -183,16 +171,10 @@ int main(int argc, char *argv[]) {
// PMS : remove mock galaxies and anything adjacent to a mock galaxy
printf("\nRemoving mock galaxies...\n");
// completely unlink mock particles
for (i = mockIndex; i < np; i++) {
vols[i] = 1.e-29;
adjs[i].nadj = 0;
}
// unlink particles adjacent to mock galaxies
for (i = 0; i < mockIndex; i++) {
for (i = 0; i < np; i++) {
for (j = 0; j < adjs[i].nadj; j++) {
if (adjs[i].adj[j] > mockIndex) {
if (adjs[i].adj[j] > np) {
//printf("KILLING %d\n", i);
vols[i] = 1.e-29;
adjs[i].nadj = 0;
@ -203,7 +185,7 @@ int main(int argc, char *argv[]) {
}
// update all other adjacencies
for (i = 0; i < mockIndex; i++) {
for (i = 0; i < np; i++) {
int numAdjSaved = 0;
for (j = 0; j < adjs[i].nadj; j++) {
@ -217,10 +199,6 @@ int main(int argc, char *argv[]) {
adjs[i].nadj = numAdjSaved;
}
printf("Removed %d mock galaxies and %d adjacent galaxies.\n", np-mockIndex,
numRemoved);
printf("There are %d galaxies remaining.\n", mockIndex-numRemoved);
// END PMS
*/
@ -254,19 +232,19 @@ int main(int argc, char *argv[]) {
printf("Unable to open %s\n",adjfile);
exit(0);
}
fwrite(&mockIndex,1, sizeof(int),adj);
fwrite(&np,1, sizeof(int),adj);
/* Adjacencies: first the numbers of adjacencies,
and the number we're actually going to write per particle */
// Recount the number of adjacencies after merge
for(i=0;i<mockIndex;i++)
for(i=0;i<np;i++)
cnt_adj[i] = adjs[i].nadj;
for (i=0;i<mockIndex;i++)
for (i=0;i<np;i++)
fwrite(&cnt_adj[i],1,sizeof(int),adj);
/* Now the lists of adjacencies (without double counting) */
for (i=0;i<mockIndex;i++) {
for (i=0;i<np;i++) {
nout = 0;
for (j=0;j<adjs[i].nadj; j++)
if (adjs[i].adj[j] > i)
@ -287,12 +265,8 @@ int main(int argc, char *argv[]) {
printf("Unable to open %s\n",volfile);
exit(0);
}
// PMS
fwrite(&mockIndex,1, sizeof(int),vol);
fwrite(vols,sizeof(float),mockIndex,vol);
//fwrite(&np,1, sizeof(int),vol);
//fwrite(vols,sizeof(float),np,vol);
// END PMS
fwrite(&np,1, sizeof(int),vol);
fwrite(vols,sizeof(float),np,vol);
fclose(vol);