diff --git a/c_tools/mock/generateMock.cpp b/c_tools/mock/generateMock.cpp index 52564e2..9a72aa5 100644 --- a/c_tools/mock/generateMock.cpp +++ b/c_tools/mock/generateMock.cpp @@ -274,7 +274,7 @@ void selectBox(SimuData *simu, std::vector& 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("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("num_snapshots"); long *uniqueID = boxed->as("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) + { + cerr << "Parameter file was not generated with the same simulation subsampling argument. Particles will be different. Stop here." << 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; diff --git a/c_tools/mock/loaders/sdf_loader.cpp b/c_tools/mock/loaders/sdf_loader.cpp index b716536..cab171d 100644 --- a/c_tools/mock/loaders/sdf_loader.cpp +++ b/c_tools/mock/loaders/sdf_loader.cpp @@ -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); diff --git a/external/external_build.cmake b/external/external_build.cmake index 401abaf..2885053 100644 --- a/external/external_build.cmake +++ b/external/external_build.cmake @@ -234,6 +234,7 @@ ExternalProject_Add(cosmotool -DGSLCBLAS_LIBRARY=${GSLCBLAS_LIBRARY} -DNETCDF_LIBRARY=${NETCDF_LIBRARY} -DNETCDFCPP_LIBRARY=${NETCDFCPP_LIBRARY} + -DENABLE_SHARP=OFF ) SET(COSMOTOOL_LIBRARY ${CMAKE_BINARY_DIR}/ext_build/cosmotool/lib/libCosmoTool.a) set(COSMOTOOL_INCLUDE_PATH ${CMAKE_BINARY_DIR}/ext_build/cosmotool/include) diff --git a/python_tools/void_python_tools/backend/launchers.py b/python_tools/void_python_tools/backend/launchers.py index 69e5973..4f834ca 100644 --- a/python_tools/void_python_tools/backend/launchers.py +++ b/python_tools/void_python_tools/backend/launchers.py @@ -163,6 +163,8 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None, dataFileLine = "gadget " + datafile elif sample.dataFormat == "sdf": dataFileLine = "sdf " + datafile + else: + raise ValueError("unknown dataFormat '%s'" % sample.dataFormat) iX = float(sample.mySubvolume[0]) iY = float(sample.mySubvolume[1]) diff --git a/zobov/jozov.c b/zobov/jozov.c index e5ebf7f..697d039 100644 --- a/zobov/jozov.c +++ b/zobov/jozov.c @@ -85,7 +85,7 @@ int main(int argc,char **argv) { printf("Bad density threshold.\n"); exit(0); } - if (sscanf(argv[7],"%f",&mockIndex) == 0) { + if (sscanf(argv[7],"%d",&mockIndex) == 0) { printf("Bad mock galaxy index.\n"); exit(0); } @@ -108,29 +108,29 @@ int main(int argc,char **argv) { p = (PARTICLE *)malloc(np*sizeof(PARTICLE)); /* Adjacencies*/ for (i=0;i 0) - p[i].adj = (int *)malloc(p[i].nadj*sizeof(int)); + p[i].adj = (pid_t *)malloc(p[i].nadj*sizeof(pid_t)); else p[i].adj = 0; p[i].ncnt = 0; /* Temporarily, it's an adj counter */ } for (i=0;i 0) for (k=0;k 0.5) rtemp[d] --; if (rtemp[d] < -0.5) rtemp[d] ++; isitinbuf = isitinbuf && (fabs(rtemp[d]) 0) && - ((fabs(rtemp[0])>width2)||(fabs(rtemp[1])>width2)||(fabs(rtemp[2])>width2))) { - + if (isitinbuf && !isitinmain) { /*printf("%3.3f ",sqrt(rtemp[0]*rtemp[0] + rtemp[1]*rtemp[1] + rtemp[2]*rtemp[2])); printf("|%2.2f,%2.2f,%2.2f,%f,%f",r[i][0],r[i][1],r[i][2],width2,totwidth2);*/ @@ -323,14 +325,14 @@ int main(int argc, char *argv[]) { printf("nvp = %d\n",nvp); /* Tell us where the original particles were */ - fwrite(orig,sizeof(int),nvp,out); + fwrite(orig,sizeof(pid_t),nvp,out); /* Volumes*/ fwrite(vols,sizeof(float),nvp,out); /* Adjacencies */ for (i=0;i 0) - fwrite(adjs[i].adj,adjs[i].nadj,sizeof(int),out); + fwrite(adjs[i].adj,adjs[i].nadj,sizeof(pid_t),out); else printf("0"); } fclose(out); diff --git a/zobov/voztie.c b/zobov/voztie.c index cc8c006..6c67519 100644 --- a/zobov/voztie.c +++ b/zobov/voztie.c @@ -14,10 +14,12 @@ int main(int argc, char *argv[]) { int numdiv,np,np2,na; - int i,j,k,p,nout; - int nvp,npnotdone,nvpmax, nvpsum, *orig; + pid_t i,j,k,p,nout; + pid_t nvp,npnotdone,nvpmax, nvpsum, *orig; double avgnadj, avgvol; + int numRemoved = 0; + // PMS int mockIndex; // END PMS @@ -87,7 +89,7 @@ int main(int argc, char *argv[]) { if (adjs == NULL) printf("Couldn't allocate adjs.\n"); vols = (float *)malloc(np*sizeof(float)); if (vols == NULL) printf("Couldn't allocate vols.\n"); - orig = (int *)malloc(nvpmax*sizeof(int)); + orig = (pid_t *)malloc(nvpmax*sizeof(pid_t)); if (orig == NULL) printf("Couldn't allocate orig.\n"); if ((cnt_adj==NULL) || (vols == NULL) || (orig == NULL) || (adjs == NULL)) { printf("Not enough memory to allocate. Exiting.\n"); @@ -96,6 +98,7 @@ int main(int argc, char *argv[]) { for (p=0;p -1.) @@ -131,12 +134,12 @@ int main(int argc, char *argv[]) { fread(&na,1,sizeof(int),part); if (na > 0) { adjs[orig[p]].nadj = na; - adjs[orig[p]].adj = (int *)malloc(na*sizeof(int)); + adjs[orig[p]].adj = (pid_t *)malloc(na*sizeof(pid_t)); if (adjs[orig[p]].adj == NULL) { printf("Couldn't allocate adjs[orig[%d]].adj.\n",p); exit(0); } - fread(adjs[orig[p]].adj,na,sizeof(int),part); + fread(adjs[orig[p]].adj,na,sizeof(pid_t),part); } else { printf("0"); fflush(stdout); } @@ -157,8 +160,6 @@ int main(int argc, char *argv[]) { 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++) { @@ -217,7 +218,7 @@ printf("\n"); avgvol += (double)(vols[p]); } if (npnotdone > 0) - printf("%d particles not done!\n"); + printf("%d particles not done!\n", npnotdone); printf("%d particles done more than once.\n",nvpsum-np); avgnadj /= (double)np; avgvol /= (double)np; @@ -272,9 +273,9 @@ printf("\n"); for (j=0;j i) nout++; fwrite(&nout,1,sizeof(int),adj); for (j=0;j i) - fwrite(&(adjs[i].adj[j]),1,sizeof(int),adj); + fwrite(&id,1,sizeof(pid_t),adj); } }