mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
Merge branch 'master' of ssh://bitbucket.org/cosmicvoids/void_identification
This commit is contained in:
commit
5a0f2383b3
26 changed files with 1232 additions and 306 deletions
|
@ -260,7 +260,7 @@ void selectBox(SimuData *simu, std::vector<long>& targets, generateMock_info& ar
|
|||
acceptance =
|
||||
acceptance &&
|
||||
(simu->Pos[j][i] > ranges[j][0]) &&
|
||||
(simu->Pos[j][i] < ranges[j][1]);
|
||||
(simu->Pos[j][i] <= ranges[j][1]);
|
||||
p.Pos[j] = simu->Pos[j][i];
|
||||
p.Vel[j] = (simu->Vel[j] != 0) ? simu->Vel[j][i] : 0;
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ void selectBox(SimuData *simu, std::vector<long>& 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<double>("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<int>("num_snapshots");
|
||||
long *uniqueID = boxed->as<long>("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-1. > 1.e-5)
|
||||
{
|
||||
cerr << "Parameter file was not generated with the same simulation subsampling argument. Particles will be different. Stop here." << d_sub->as_double(0) << " " << args_info.subsample_arg <<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;
|
||||
|
|
|
@ -20,13 +20,16 @@
|
|||
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/format.hpp>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <CosmoTool/loadRamses.hpp>
|
||||
#include <CosmoTool/fortran.hpp>
|
||||
#include "simulation_loader.hpp"
|
||||
#include <libsdf/cosmo.h>
|
||||
|
||||
using boost::format;
|
||||
using namespace std;
|
||||
using namespace CosmoTool;
|
||||
|
||||
|
@ -82,6 +85,12 @@ public:
|
|||
|
||||
double tempData;
|
||||
|
||||
double shift = 0.5*simu->BoxSize;
|
||||
double rescale_position = simu->Hubble*1.e-5*100./simu->time;
|
||||
double rescale_velocity = one_kpc/one_Gyr;
|
||||
#define INFINITY std::numeric_limits<float>::max()
|
||||
float min_pos[3] = {INFINITY,INFINITY, INFINITY}, max_pos[3] = {-INFINITY,-INFINITY,-INFINITY};
|
||||
|
||||
cout << "loading multidark particles" << endl;
|
||||
long actualNumPart = 0;
|
||||
|
||||
|
@ -96,6 +105,17 @@ public:
|
|||
p.Pos[2] == -99 && p.Vel[2] == -99)
|
||||
break;
|
||||
|
||||
//p.Pos[0] = p.Pos[0]*rescale_position + shift;
|
||||
//p.Pos[1] = p.Pos[1]*rescale_position + shift;
|
||||
//p.Pos[2] = p.Pos[2]*rescale_position + shift;
|
||||
//p.Vel[2] = p.Vel[2]*rescale_velocity;
|
||||
|
||||
// enforce box size in case of roundoff error
|
||||
for (int k = 0; k < 3; k++) {
|
||||
if (p.Pos[k] < 0) p.Pos[k] += simu->BoxSize;
|
||||
if (p.Pos[k] >= simu->BoxSize) p.Pos[k] -= simu->BoxSize;
|
||||
}
|
||||
|
||||
if (preproc != 0 && !preproc->accept(p))
|
||||
continue;
|
||||
|
||||
|
@ -110,7 +130,14 @@ public:
|
|||
reallocArray(uniqueID, allocated, actualNumPart);
|
||||
reallocArray(index, allocated, actualNumPart);
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 3; k++) {
|
||||
min_pos[k] = std::min(min_pos[k], p.Pos[k]);
|
||||
max_pos[k] = std::max(max_pos[k], p.Pos[k]);
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < 3; k++) cout << boost::format("min[%d] = %g, max[%d] = %g") % k % min_pos[k] % k %max_pos[k] << endl;
|
||||
|
||||
applyTransformations(simu);
|
||||
simu->NumPart = actualNumPart;
|
||||
simu->TotalNumPart = actualNumPart;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue