mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
merged guilhem's and my updates
This commit is contained in:
commit
168ef7a0d7
11 changed files with 124 additions and 39 deletions
|
@ -1,3 +1,4 @@
|
|||
#include <cassert>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
@ -152,6 +153,7 @@ bool loadZobov(const char *descName, const char *adjName, const char *voidsName,
|
|||
for (int j = 0; j < z.allVoids[volId].zId.size(); j++)
|
||||
{
|
||||
int zzid = z.allVoids[volId].zId[j];
|
||||
assert(zzid < z.allZones.size());
|
||||
actualNumber += z.allZones[zzid].pId.size();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <cstdlib>
|
||||
#include <netcdfcpp.h>
|
||||
#include <CosmoTool/fortran.hpp>
|
||||
#include "particleInfo.hpp"
|
||||
|
@ -5,6 +6,34 @@
|
|||
using namespace std;
|
||||
using namespace CosmoTool;
|
||||
|
||||
template<bool failure>
|
||||
double retrieve_attr_safe_double(NcFile& f, const char *name, double defval)
|
||||
{
|
||||
NcAtt *a = f.get_att(name);
|
||||
if (a == 0)
|
||||
{
|
||||
if (failure)
|
||||
abort();
|
||||
return defval;
|
||||
}
|
||||
return a->as_double(0);
|
||||
}
|
||||
|
||||
template<bool failure>
|
||||
int retrieve_attr_safe_int(NcFile& f, const char *name, int defval)
|
||||
{
|
||||
NcAtt *a = f.get_att(name);
|
||||
if (a == 0)
|
||||
{
|
||||
if (failure)
|
||||
abort();
|
||||
return defval;
|
||||
}
|
||||
return a->as_int(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool loadParticleInfo(ParticleInfo& info,
|
||||
const std::string& particles,
|
||||
const std::string& extra_info)
|
||||
|
@ -13,18 +42,19 @@ bool loadParticleInfo(ParticleInfo& info,
|
|||
int isObservation;
|
||||
|
||||
NcFile f_info(extra_info.c_str());
|
||||
NcError nerr(NcError::verbose_nonfatal);
|
||||
|
||||
if (!f_info.is_valid())
|
||||
return false;
|
||||
|
||||
info.ranges[0][0] = f_info.get_att("range_x_min")->as_double(0);
|
||||
info.ranges[0][1] = f_info.get_att("range_x_max")->as_double(0);
|
||||
info.ranges[1][0] = f_info.get_att("range_y_min")->as_double(0);
|
||||
info.ranges[1][1] = f_info.get_att("range_y_max")->as_double(0);
|
||||
info.ranges[2][0] = f_info.get_att("range_z_min")->as_double(0);
|
||||
info.ranges[2][1] = f_info.get_att("range_z_max")->as_double(0);
|
||||
info.mask_index = f_info.get_att("mask_index")->as_int(0); //PMS
|
||||
isObservation = f_info.get_att("is_observation")->as_int(0); //PMS
|
||||
info.ranges[0][0] = retrieve_attr_safe_double<true>(f_info, "range_x_min", 0);
|
||||
info.ranges[0][1] = retrieve_attr_safe_double<true>(f_info, "range_x_max", 0);
|
||||
info.ranges[1][0] = retrieve_attr_safe_double<true>(f_info, "range_y_min", 0);
|
||||
info.ranges[1][1] = retrieve_attr_safe_double<true>(f_info, "range_y_max", 0);
|
||||
info.ranges[2][0] = retrieve_attr_safe_double<true>(f_info, "range_z_min", 0);
|
||||
info.ranges[2][1] = retrieve_attr_safe_double<true>(f_info, "range_z_max", 0);
|
||||
info.mask_index = retrieve_attr_safe_int<true>(f_info, "mask_index", 0);
|
||||
isObservation = retrieve_attr_safe_int<false>(f_info, "is_observation", 0);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
info.length[i] = info.ranges[i][1] - info.ranges[i][0];
|
||||
|
|
|
@ -317,9 +317,9 @@ void buildBox(SimuData *simu, long num_targets, long loaded,
|
|||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
boxed->Pos[j][loaded] = (simu->Pos[j][pid]-ranges[j*2])*mul[j];
|
||||
assert(boxed->Pos[j][loaded] > 0);
|
||||
assert(boxed->Pos[j][loaded] < 1);
|
||||
boxed->Pos[j][loaded] = max(min((simu->Pos[j][pid]-ranges[j*2])*mul[j], double(1)), double(0));
|
||||
assert(boxed->Pos[j][loaded] >= 0);
|
||||
assert(boxed->Pos[j][loaded] <= 1);
|
||||
}
|
||||
uniqueID[loaded] = (simu_uniqueID != 0) ? simu_uniqueID[pid] : 0;
|
||||
expansion_fac[loaded] = efac[pid];
|
||||
|
@ -400,6 +400,7 @@ void makeBoxFromParameter(SimuData *simu, SimuData* &boxed, generateMock_info& a
|
|||
mul = new double[3];
|
||||
ranges = new double[6];
|
||||
snapshot_split = new long[*num_snapshots];
|
||||
expansion_fac = new double[boxed->NumPart];
|
||||
|
||||
|
||||
boxed->new_attribute("uniqueID", uniqueID, delete_adaptor<long>);
|
||||
|
@ -408,6 +409,7 @@ void makeBoxFromParameter(SimuData *simu, SimuData* &boxed, generateMock_info& a
|
|||
boxed->new_attribute("particle_id", particle_id, delete_adaptor<long>);
|
||||
boxed->new_attribute("num_snapshots", num_snapshots, delete_adaptor<int>);
|
||||
boxed->new_attribute("snapshot_split", snapshot_split, delete_adaptor<long>);
|
||||
boxed->new_attribute("expansion_fac", expansion_fac, delete_adaptor<double>);
|
||||
|
||||
v_id->get(particle_id, boxed->NumPart);
|
||||
v_snap->get(snapshot_split, *num_snapshots);
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
SimulationLoader *gadgetLoader(const std::string& snapshot, double Mpc_unitLength, int flags)
|
||||
{
|
||||
bool singleFile;
|
||||
bool singleFile = false;
|
||||
int num_files;
|
||||
SimuData *d;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ int main(int argc, char **argv) {
|
|||
double nearestEdge, redshift;
|
||||
char line[500], junkStr[10];
|
||||
int mask_index;
|
||||
double ranges[2][3], boxLen[3], mul;
|
||||
double ranges[3][2], boxLen[3], mul;
|
||||
double volNorm, radius;
|
||||
int clock1, clock2;
|
||||
int periodicX=0, periodicY=0, periodicZ=0;
|
||||
|
@ -180,7 +180,7 @@ int main(int argc, char **argv) {
|
|||
part[p].y += ranges[1][0];
|
||||
part[p].z += ranges[2][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
printf(" Read %d particles...\n", numPartTot);
|
||||
|
@ -350,19 +350,19 @@ int main(int argc, char **argv) {
|
|||
if (voids[iVoid].barycenter[0] > boxLen[0])
|
||||
voids[iVoid].barycenter[0] = voids[iVoid].barycenter[0] - boxLen[0];
|
||||
if (voids[iVoid].barycenter[0] < 0)
|
||||
voids[iVoid].barycenter[0] = boxLen[0] - voids[iVoid].barycenter[0];
|
||||
voids[iVoid].barycenter[0] = boxLen[0] + voids[iVoid].barycenter[0];
|
||||
}
|
||||
if (periodicY) {
|
||||
if (voids[iVoid].barycenter[1] > boxLen[1])
|
||||
voids[iVoid].barycenter[1] = voids[iVoid].barycenter[1] - boxLen[1];
|
||||
if (voids[iVoid].barycenter[1] < 1)
|
||||
voids[iVoid].barycenter[1] = boxLen[1] - voids[iVoid].barycenter[1];
|
||||
if (voids[iVoid].barycenter[1] < 0)
|
||||
voids[iVoid].barycenter[1] = boxLen[1] + voids[iVoid].barycenter[1];
|
||||
}
|
||||
if (periodicZ) {
|
||||
if (voids[iVoid].barycenter[2] > boxLen[2])
|
||||
voids[iVoid].barycenter[2] = voids[iVoid].barycenter[2] - boxLen[2];
|
||||
if (voids[iVoid].barycenter[2] < 2)
|
||||
voids[iVoid].barycenter[2] = boxLen[2] - voids[iVoid].barycenter[2];
|
||||
if (voids[iVoid].barycenter[2] < 0)
|
||||
voids[iVoid].barycenter[2] = boxLen[2] + voids[iVoid].barycenter[2];
|
||||
}
|
||||
|
||||
// compute central density
|
||||
|
@ -406,8 +406,8 @@ int main(int argc, char **argv) {
|
|||
for (p = 0; p < voids[iVoid].numPart; p++) {
|
||||
|
||||
dist[0] = fabs(voidPart[p].x - voids[iVoid].barycenter[0]);
|
||||
dist[0] = fabs(voidPart[p].y - voids[iVoid].barycenter[1]);
|
||||
dist[0] = fabs(voidPart[p].z - voids[iVoid].barycenter[2]);
|
||||
dist[1] = fabs(voidPart[p].y - voids[iVoid].barycenter[1]);
|
||||
dist[2] = fabs(voidPart[p].z - voids[iVoid].barycenter[2]);
|
||||
|
||||
if (periodicX) dist[0] = fmin(dist[0], boxLen[0]-dist[0]);
|
||||
if (periodicY) dist[1] = fmin(dist[1], boxLen[1]-dist[1]);
|
||||
|
@ -599,7 +599,7 @@ int main(int argc, char **argv) {
|
|||
voids[iVoid].densCon,
|
||||
voids[iVoid].voidProb);
|
||||
|
||||
fprintf(fpBarycenter, "%d %e %e %e\n",
|
||||
fprintf(fpBarycenter, "%d %e %e %e\n",
|
||||
voids[iVoid].voidID,
|
||||
voids[iVoid].barycenter[0],
|
||||
voids[iVoid].barycenter[1],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue