mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
Finished subsubsampling on regeneration
This commit is contained in:
parent
8625ab633c
commit
14b52c4248
1 changed files with 42 additions and 7 deletions
|
@ -222,17 +222,12 @@ void generateOutput(SimuData *data, int axis,
|
|||
// cleared. That way new particles can be appended if this is a multi-file snapshot.
|
||||
void selectBox(SimuData *simu, std::vector<long>& targets, generateMock_info& args_info, SimulationPreprocessor *preselect)
|
||||
{
|
||||
float subsample;
|
||||
if (args_info.subsample_given) {
|
||||
subsample = args_info.subsample_arg;
|
||||
} else {
|
||||
subsample = 1.0;
|
||||
}
|
||||
double ranges[3][2] = {
|
||||
{ args_info.rangeX_min_arg, args_info.rangeX_max_arg },
|
||||
{ args_info.rangeY_min_arg, args_info.rangeY_max_arg },
|
||||
{ args_info.rangeZ_min_arg, args_info.rangeZ_max_arg }
|
||||
};
|
||||
long numAccepted =0;
|
||||
|
||||
for (uint32_t i = 0; i < simu->NumPart; i++)
|
||||
{
|
||||
|
@ -252,9 +247,12 @@ void selectBox(SimuData *simu, std::vector<long>& targets, generateMock_info& ar
|
|||
if (preselect != 0)
|
||||
acceptance = acceptance && preselect->accept(p);
|
||||
|
||||
if (acceptance)
|
||||
if (acceptance) {
|
||||
targets.push_back(i);
|
||||
numAccepted++;
|
||||
}
|
||||
}
|
||||
cout << "Num accepted here = " << numAccepted << " / input = " << simu->NumPart << endl;
|
||||
}
|
||||
|
||||
class PreselectParticles: public SimulationPreprocessor
|
||||
|
@ -490,6 +488,40 @@ void makeBoxFromParameter(SimuData *simu, SimuData* &boxed, generateMock_info& a
|
|||
uniqueID[i] |= (unsigned long)(tmp_int[i]) << 32;
|
||||
|
||||
delete[] tmp_int;
|
||||
|
||||
PreselectParticles *preselect = 0;
|
||||
|
||||
if (args_info.resubsample_given)
|
||||
{
|
||||
preselect = new PreselectParticles(args_info.resubsample_arg, args_info.resubsample_seed_arg);
|
||||
preselect->reset();
|
||||
}
|
||||
|
||||
if (preselect == 0)
|
||||
return;
|
||||
|
||||
long pid_read = 0, pid_write = 0;
|
||||
for (int s_id = 0; s_id < *num_snapshots; s_id++)
|
||||
{
|
||||
long previous_write = pid_write;
|
||||
for (long q = 0; q < snapshot_split[s_id]; q++)
|
||||
{
|
||||
SingleParticle p;
|
||||
p.ID = -1;
|
||||
assert(pid_read < boxed->NumPart);
|
||||
if (preselect->accept(p))
|
||||
{
|
||||
particle_id[pid_write] = particle_id[pid_read];
|
||||
uniqueID[pid_write] = uniqueID[pid_read];
|
||||
expansion_fac[pid_write] = uniqueID[pid_read];
|
||||
pid_write++;
|
||||
}
|
||||
pid_read++;
|
||||
}
|
||||
snapshot_split[s_id] = pid_write - previous_write;
|
||||
}
|
||||
boxed->NumPart = pid_write;
|
||||
delete preselect;
|
||||
}
|
||||
|
||||
void makeBoxFromSimulation(SimulationLoader *loader, SimuData* &boxed, MetricFunctor metric, generateMock_info& args_info)
|
||||
|
@ -522,6 +554,9 @@ void makeBoxFromSimulation(SimulationLoader *loader, SimuData* &boxed, MetricFun
|
|||
}
|
||||
|
||||
createBox(loader->getHeader(), targets, split, boxed, args_info);
|
||||
|
||||
if (preselect)
|
||||
delete preselect;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue