mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
many bug fixes from the previous update; new changes appear to work now
This commit is contained in:
parent
90964d2be3
commit
0b54a31d0c
7 changed files with 72 additions and 21 deletions
|
@ -54,3 +54,33 @@ void computeContourPixels(Healpix_Map<float>& m, vector<int>& contour)
|
|||
write_Healpix_map_to_fits(h, contour_map, planckType<int>());
|
||||
}
|
||||
}
|
||||
|
||||
void computeMaskPixels(Healpix_Map<float>& m, vector<int>& contour)
|
||||
{
|
||||
for (int p = 0; p < m.Npix(); p++)
|
||||
{
|
||||
|
||||
if (m[p]>0)
|
||||
{
|
||||
contour.push_back(p);
|
||||
// This is boundary go to next pixel
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG)
|
||||
{
|
||||
Healpix_Map<int> contour_map;
|
||||
|
||||
contour_map.SetNside(m.Nside(), RING);
|
||||
contour_map.fill(0);
|
||||
for (int p = 0; p < contour.size(); p++)
|
||||
{
|
||||
contour_map[contour[p]]=1;
|
||||
}
|
||||
|
||||
fitshandle h;
|
||||
h.create("!mask_map.fits");
|
||||
write_Healpix_map_to_fits(h, contour_map, planckType<int>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
|
||||
void computeContourPixels(Healpix_Map<float>& map, std::vector<int>& contour);
|
||||
void computeFilledPixels(Healpix_Map<float>& map, std::vector<int>& contour);
|
||||
void computeMaskPixels(Healpix_Map<float>& map, std::vector<int>& contour);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -295,10 +295,10 @@ void generateSurfaceMask(generateFromCatalog_info& args ,
|
|||
|
||||
int nPart = 100;
|
||||
// TEST
|
||||
for (int iDir = 0; iDir < 0; iDir++) {
|
||||
for (int iFace = 0; iFace < 0; iFace++) {
|
||||
//for (int iDir = 0; iDir < 3; iDir++) {
|
||||
//for (int iFace = 0; iFace < 2; iFace++) {
|
||||
//for (int iDir = 0; iDir < 0; iDir++) {
|
||||
//for (int iFace = 0; iFace < 0; iFace++) {
|
||||
for (int iDir = 0; iDir < 3; iDir++) {
|
||||
for (int iFace = 0; iFace < 2; iFace++) {
|
||||
|
||||
int iy = (iDir + 1) % 3;
|
||||
int iz = (iDir + 2) % 3;
|
||||
|
@ -483,6 +483,7 @@ void saveForZobov(ParticleData& pdata, const string& fname, const string& paramn
|
|||
|
||||
//delete[] expansion_fac;
|
||||
|
||||
/*
|
||||
FILE *infoFile = fopen("sample_info.txt", "w");
|
||||
fprintf(infoFile, "x_min = %f\n", -Lmax/100.);
|
||||
fprintf(infoFile, "x_max = %f\n", Lmax/100.);
|
||||
|
@ -493,7 +494,7 @@ void saveForZobov(ParticleData& pdata, const string& fname, const string& paramn
|
|||
fprintf(infoFile, "mask_index = %d\n", pdata.mask_index);
|
||||
fprintf(infoFile, "total_particles = %d\n", pdata.pos.size());
|
||||
fclose(infoFile);
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -545,6 +546,7 @@ int main(int argc, char **argv)
|
|||
mask.Import(o_mask);
|
||||
|
||||
computeContourPixels(mask,pixel_list);
|
||||
computeMaskPixels(mask,full_mask_list);
|
||||
|
||||
// We compute a cube holding all the galaxies + the survey surface mask
|
||||
|
||||
|
|
|
@ -505,6 +505,7 @@ void makeBox(SimuData *simu, double *efac, SimuData *&boxed, generateMock_info&
|
|||
delete[] expansion_fac;
|
||||
|
||||
|
||||
/*
|
||||
FILE *fp = fopen("sample_info.txt", "w");
|
||||
fprintf(fp, "x_min = %f\n", ranges[0][0]);
|
||||
fprintf(fp, "x_max = %f\n", ranges[0][1]);
|
||||
|
@ -515,6 +516,7 @@ void makeBox(SimuData *simu, double *efac, SimuData *&boxed, generateMock_info&
|
|||
fprintf(fp, "mask_index = -1\n");
|
||||
fprintf(fp, "total_particles = %d\n", boxed->NumPart);
|
||||
fclose(fp);
|
||||
*/
|
||||
}
|
||||
|
||||
void makeBoxFromParameter(SimuData *simu, double *efac, SimuData* &boxed, generateMock_info& args_info)
|
||||
|
|
|
@ -64,9 +64,23 @@ for sample in dataSampleList:
|
|||
# save this sample's information
|
||||
with open(zobovDir+"/sample_info.dat", 'w') as output:
|
||||
pickle.dump(sample, output, pickle.HIGHEST_PROTOCOL)
|
||||
#fp = open(zobovDir+"/sample_info.txt", 'w')
|
||||
#fp.write("Redshift range: %f - %f" %(sample.zBoundary[0], sample.zBoundary[1])
|
||||
#fp.close()
|
||||
|
||||
fp = open(zobovDir+"/sample_info.txt", 'w')
|
||||
fp.write("Sample name: %s\n" % sample.fullName)
|
||||
fp.write("Sample nickname: %s\n" % sample.nickName)
|
||||
fp.write("Data type: %s\n" % sample.dataType)
|
||||
fp.write("Redshift range: %f - %f\n" %(sample.zBoundary[0],sample.zBoundary[1]))
|
||||
fp.write("Estimated mean particle separation: %g\n" % sample.minVoidRadius)
|
||||
|
||||
if (sample.dataType == "simulation"):
|
||||
fp.write("Particles placed on lightcone: %g\n" % sample.useLightCone)
|
||||
fp.write("Peculiar velocities included: %g\n" % sample.usePecVel)
|
||||
fp.write("Additional subsampling fraction: %g\n" % sample.subsample)
|
||||
fp.write("Simulation box length (Mpc/h): %g\n" % sample.boxLen)
|
||||
fp.write("Simulation Omega_M: %g\n" % sample.omegaM)
|
||||
fp.write("Number of simulation subvolumes: %g\n", sample.numSubvolumes)
|
||||
fp.write("My subvolume index: %g\n", sample.mySubvolume)
|
||||
fp.close()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
if (startCatalogStage <= 1) and (endCatalogStage >= 1) and not sample.isCombo:
|
||||
|
|
|
@ -323,26 +323,28 @@ if (args.script or args.all) and dataFormat == "multidark":
|
|||
print " Doing halo scripts"
|
||||
|
||||
for minHaloMass in minHaloMasses:
|
||||
# estimate number of halos to get density
|
||||
dataFile = catalogDir+haloFileBase+fileNums[0]
|
||||
inFile = open(dataFile, 'r')
|
||||
numPart = 0
|
||||
for line in inFile:
|
||||
line = line.split(',')
|
||||
if numHaloMass == "none" or float(line[6]) > minHaloMass:
|
||||
numPart += 1
|
||||
if minHaloMass == "none" or float(line[6]) > minHaloMass:
|
||||
numPart += 1
|
||||
inFile.close()
|
||||
|
||||
minRadius = 2*int(np.ceil(lbox/numPart**(1./3.)))
|
||||
|
||||
if dataFormat == "multidark":
|
||||
setName = prefix+"halos_min"str(minHaloMass)
|
||||
setName = prefix+"halos_min"+str(minHaloMass)
|
||||
writeScript(setName, "md.halos_min"+str(minHaloMass)+"_z",
|
||||
scriptDir, catalogDir, fileNums,
|
||||
redshifts,
|
||||
numSubvolumes, numSlices, False, lbox, minRadius, omegaM)
|
||||
writeScript(setName, "md.halos_min"+str(minHaloMass)+"_z",
|
||||
scriptDir, catalogDir, fileNums,
|
||||
numSlices, True, lbox, minRadius, omegaM)
|
||||
redshifts,
|
||||
numSubvolumes, numSlices, True, lbox, minRadius, omegaM)
|
||||
|
||||
if args.halos or args.all:
|
||||
print " Doing halos"
|
||||
|
@ -355,9 +357,11 @@ if args.halos or args.all:
|
|||
|
||||
dataFile = catalogDir+haloFileBase+fileNums[iRedshift]
|
||||
inFile = open(dataFile, 'r')
|
||||
numPart = 0
|
||||
for line in inFile:
|
||||
line = line.split(',')
|
||||
if numHaloMass == "none" or float(line[6]) > minHaloMass:
|
||||
if minHaloMass == "none" or float(line[6]) > minHaloMass:
|
||||
numPart += 1
|
||||
inFile.close()
|
||||
|
||||
sampleName = "md.halos_z"+redshift
|
||||
|
@ -370,18 +374,16 @@ if args.halos or args.all:
|
|||
outFile.write("%d\n" %(numPart))
|
||||
|
||||
inFile = open(dataFile, 'r')
|
||||
numKept = 0
|
||||
for line in inFile:
|
||||
if numHaloMass == "none" or float(line[6]) > minHaloMass:
|
||||
numKept += 1
|
||||
line = line.split(',')
|
||||
for (iHalo,line) in enumerate(inFile):
|
||||
line = line.split(',')
|
||||
if minHaloMass == "none" or float(line[6]) > minHaloMass:
|
||||
x = float(line[0])
|
||||
y = float(line[1])
|
||||
z = float(line[2])
|
||||
vz = float(line[5])
|
||||
|
||||
# write to output file
|
||||
outFile.write("%d %e %e %e %e\n" %(numKept,x,y,z,vz))
|
||||
outFile.write("%d %e %e %e %e\n" %(iHalo,x,y,z,vz))
|
||||
|
||||
inFile.close()
|
||||
outFile.close()
|
||||
|
|
|
@ -83,7 +83,7 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
|||
if os.access("mask_index.txt", os.F_OK):
|
||||
os.system("mv %s %s" % ("mask_index.txt", zobovDir))
|
||||
os.system("mv %s %s" % ("total_particles.txt", zobovDir))
|
||||
os.system("mv %s %s" % ("sample_info.txt", zobovDir))
|
||||
#os.system("mv %s %s" % ("sample_info.txt", zobovDir))
|
||||
|
||||
if os.access("galaxies.txt", os.F_OK):
|
||||
os.system("mv %s %s" % ("galaxies.txt", zobovDir))
|
||||
|
@ -160,7 +160,7 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
|||
|
||||
if os.access("comoving_distance.txt", os.F_OK):
|
||||
os.system("mv %s %s" % ("comoving_distance.txt", zobovDir))
|
||||
os.system("mv %s %s" % ("sample_info.txt", zobovDir))
|
||||
#os.system("mv %s %s" % ("sample_info.txt", zobovDir))
|
||||
|
||||
if os.access(parmFile, os.F_OK):
|
||||
os.unlink(parmFile)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue