mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
Slight re-organization of C/C++ tools. Significant modifications to support observational data. Python and pipeline scripts added
This commit is contained in:
parent
15496df4ff
commit
14abbc2018
42 changed files with 16252 additions and 557 deletions
135
zobov/voztie.c
135
zobov/voztie.c
|
@ -6,7 +6,7 @@
|
|||
int main(int argc, char *argv[]) {
|
||||
|
||||
FILE *part, *adj, *vol;
|
||||
char partfile[80], *suffix, adjfile[80], volfile[80];
|
||||
char partfile[200], *suffix, adjfile[200], volfile[200], *outDir;
|
||||
float *vols, volstemp;
|
||||
|
||||
PARTADJ *adjs;
|
||||
|
@ -16,11 +16,17 @@ int main(int argc, char *argv[]) {
|
|||
int i,j,k,p,nout;
|
||||
int nvp,npnotdone,nvpmax, nvpsum, *orig;
|
||||
double avgnadj, avgvol;
|
||||
|
||||
if (argc != 3) {
|
||||
|
||||
// PMS
|
||||
int mockIndex;
|
||||
// END PMS
|
||||
|
||||
if (argc != 5) {
|
||||
printf("Wrong number of arguments.\n");
|
||||
printf("arg1: number of divisions (default 2)\n");
|
||||
printf("arg2: suffix describing this run\n\n");
|
||||
printf("arg2: suffix describing this run\n");
|
||||
printf("arg3: file directory\n");
|
||||
printf("arg4: Beginning index of mock particles\n\n");
|
||||
exit(0);
|
||||
}
|
||||
if (sscanf(argv[1],"%d",&numdiv) != 1) {
|
||||
|
@ -32,13 +38,18 @@ int main(int argc, char *argv[]) {
|
|||
numdiv = 2;
|
||||
}
|
||||
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;
|
||||
|
||||
for (i = 0; i < numdiv; i++) {
|
||||
for (j = 0; j < numdiv; j++) {
|
||||
for (k = 0; k < numdiv; k++) {
|
||||
sprintf(partfile,"part.%s.%02d.%02d.%02d",suffix,i,j,k);
|
||||
sprintf(partfile,"%s/part.%s.%02d.%02d.%02d",outDir,suffix,i,j,k);
|
||||
part = fopen(partfile,"r");
|
||||
if (part == NULL) {
|
||||
printf("Unable to open file %s.\n\n",partfile);
|
||||
|
@ -46,6 +57,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
fread(&np2,1,sizeof(int),part);
|
||||
fread(&nvp,1,sizeof(int),part);
|
||||
nvpsum += nvp;
|
||||
if (np == -1)
|
||||
np = np2;
|
||||
else
|
||||
|
@ -58,9 +70,14 @@ 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
|
||||
|
||||
adjs = (PARTADJ *)malloc(np*sizeof(PARTADJ));
|
||||
if (adjs == NULL) printf("Couldn't allocate adjs.\n");
|
||||
vols = (float *)malloc(np*sizeof(float));
|
||||
|
@ -77,7 +94,7 @@ int main(int argc, char *argv[]) {
|
|||
for (i = 0; i < numdiv; i++) {
|
||||
for (j = 0; j < numdiv; j++) {
|
||||
for (k = 0; k < numdiv; k++) {
|
||||
sprintf(partfile,"part.%s.%02d.%02d.%02d",suffix,i,j,k);
|
||||
sprintf(partfile,"%s/part.%s.%02d.%02d.%02d",outDir,suffix,i,j,k);
|
||||
part = fopen(partfile,"r");
|
||||
if (part == NULL) {
|
||||
printf("Unable to open file %s.\n\n",partfile);
|
||||
|
@ -93,10 +110,14 @@ 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) {
|
||||
// printf("Inconsistent volumes for p. %d: (%10g,%10g)!\n",
|
||||
// orig[p],vols[orig[p]],volstemp);
|
||||
// exit(0);
|
||||
// PMS
|
||||
if (fabs(vols[orig[p]]-volstemp)/volstemp > 1.5e-3 && orig[p] < mockIndex) {
|
||||
//if (fabs(vols[orig[p]]-volstemp)/volstemp > 1.5e-3) {
|
||||
// END PMS
|
||||
printf("Inconsistent volumes for p. %d: (%10g,%10g)!\n",
|
||||
orig[p],vols[orig[p]],volstemp);
|
||||
// TEST
|
||||
//exit(0);
|
||||
}
|
||||
vols[orig[p]] = volstemp;
|
||||
}
|
||||
|
@ -121,8 +142,71 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
int numRemoved = 0;
|
||||
|
||||
// unlink particles adjacent to mock galaxies
|
||||
for (i = 0; i < mockIndex; i++) {
|
||||
for (j = 0; j < adjs[i].nadj; j++) {
|
||||
if (adjs[i].adj[j] > mockIndex) {
|
||||
//printf("KILLING %d\n", i);
|
||||
vols[i] = 1.e-29;
|
||||
adjs[i].nadj = 0;
|
||||
numRemoved++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update all other adjacencies
|
||||
for (i = 0; i < mockIndex; i++) {
|
||||
|
||||
int numAdjSaved = 0;
|
||||
for (j = 0; j < adjs[i].nadj; j++) {
|
||||
|
||||
//if ( vols[adjs[i].adj[j]] != -99) {
|
||||
if ( adjs[adjs[i].adj[j]].nadj != 0) {
|
||||
adjs[i].adj[numAdjSaved] = adjs[i].adj[j];
|
||||
numAdjSaved++;
|
||||
}
|
||||
|
||||
}
|
||||
adjs[i].nadj = numAdjSaved;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
for (i = 0; i < mockIndex; i++) {
|
||||
printf("ADJ: %d %d : ", i, adjs[i].nadj);
|
||||
for (j = 0; j < adjs[i].nadj; j++) {
|
||||
printf(" %d", adjs[i].adj[j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
printf("Removed %d mock galaxies and %d adjacent galaxies.\n", np-mockIndex,
|
||||
numRemoved);
|
||||
printf("There are %d galaxies remaining.\n", mockIndex-numRemoved);
|
||||
|
||||
// END PMS
|
||||
|
||||
npnotdone = 0; avgnadj = 0.; avgvol = 0.;
|
||||
for (p=0;p<np;p++) {
|
||||
// PMS
|
||||
if (vols[p] == 1.e-29) continue;
|
||||
// END PMS
|
||||
if (vols[p] == -1.) npnotdone++;
|
||||
avgnadj += (double)(adjs[p].nadj);
|
||||
avgvol += (double)(vols[p]);
|
||||
|
@ -138,25 +222,34 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
/* Now the output! */
|
||||
|
||||
sprintf(adjfile,"adj%s.dat",suffix);
|
||||
sprintf(volfile,"vol%s.dat",suffix);
|
||||
sprintf(adjfile,"%s/adj%s.dat",outDir,suffix);
|
||||
sprintf(volfile,"%s/vol%s.dat",outDir,suffix);
|
||||
|
||||
printf("Outputting to %s, %s\n\n",adjfile,volfile);
|
||||
printf("Outputting to%s, %s\n\n", adjfile, volfile);
|
||||
|
||||
adj = fopen(adjfile,"w");
|
||||
if (adj == NULL) {
|
||||
printf("Unable to open %s\n",adjfile);
|
||||
exit(0);
|
||||
}
|
||||
fwrite(&np,1, sizeof(int),adj);
|
||||
// PMS
|
||||
fwrite(&mockIndex,1, sizeof(int),adj);
|
||||
//fwrite(&np,1, sizeof(int),adj);
|
||||
// END OMS
|
||||
/* Adjacencies: first the numbers of adjacencies,
|
||||
and the number we're actually going to write per particle */
|
||||
for (i=0;i<np;i++)
|
||||
// PMS
|
||||
for (i=0;i<mockIndex;i++)
|
||||
//for (i=0;i<np;i++)
|
||||
// END PMS
|
||||
fwrite(&adjs[i].nadj,1,sizeof(int),adj);
|
||||
|
||||
/* Now the lists of adjacencies (without double counting) */
|
||||
for (i=0;i<np;i++)
|
||||
if (adjs[i].nadj > 0) {
|
||||
// PMS
|
||||
for (i=0;i<mockIndex;i++) {
|
||||
//for (i=0;i<np;i++) {
|
||||
//if (adjs[i].nadj > 0) {
|
||||
// END PMS
|
||||
nout = 0;
|
||||
for (j=0;j<adjs[i].nadj; j++) if (adjs[i].adj[j] > i) nout++;
|
||||
fwrite(&nout,1,sizeof(int),adj);
|
||||
|
@ -173,8 +266,12 @@ int main(int argc, char *argv[]) {
|
|||
printf("Unable to open %s\n",volfile);
|
||||
exit(0);
|
||||
}
|
||||
fwrite(&np,1, sizeof(int),vol);
|
||||
fwrite(vols,sizeof(float),np,vol);
|
||||
// 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
|
||||
|
||||
fclose(vol);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue