mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
Moved subsampling to the loaders to be able to do online subsampling (only implemented for gadget and multidark so far, the other coming in...)
This commit is contained in:
parent
ecb4479178
commit
5cf7a94538
9 changed files with 330 additions and 34 deletions
|
@ -1,3 +1,4 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <CosmoTool/loadGadget.hpp>
|
||||
|
@ -16,9 +17,10 @@ private:
|
|||
double unitMpc;
|
||||
SimuData *gadget_header;
|
||||
string snapshot_name;
|
||||
SimulationPreprocessor *preproc;
|
||||
public:
|
||||
GadgetLoader(const string& basename, SimuData *header, int flags, bool singleFile, int _num, double unit)
|
||||
: snapshot_name(basename), load_flags(flags), onefile(singleFile), _num_files(_num), unitMpc(1/unit), gadget_header(header)
|
||||
GadgetLoader(const string& basename, SimuData *header, int flags, bool singleFile, int _num, double unit, SimulationPreprocessor *p)
|
||||
: snapshot_name(basename), load_flags(flags), onefile(singleFile), _num_files(_num), unitMpc(1/unit), gadget_header(header), preproc(p)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -34,7 +36,7 @@ public:
|
|||
int num_files() {
|
||||
return _num_files;
|
||||
}
|
||||
|
||||
|
||||
SimuData *loadFile(int id) {
|
||||
SimuData *d;
|
||||
|
||||
|
@ -70,12 +72,38 @@ public:
|
|||
|
||||
applyTransformations(d);
|
||||
|
||||
long numAccepted = 0;
|
||||
bool *accepted = new bool[d->NumPart];
|
||||
for (long i = 0; i < d->NumPart; i++)
|
||||
{
|
||||
SingleParticle p;
|
||||
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
p.Pos[k] = (d->Pos[k]) ? 0 : d->Pos[k][i];
|
||||
p.Vel[k] = (d->Vel[k]) ? 0 : d->Vel[k][i];
|
||||
}
|
||||
p.ID = (d->Id) ? 0 : d->Id[i];
|
||||
|
||||
accepted[i] = preproc->accept(p);
|
||||
numAccepted += accepted[i];
|
||||
}
|
||||
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
filteredCopy(d->Pos[k], accepted, d->NumPart);
|
||||
filteredCopy(d->Vel[k], accepted, d->NumPart);
|
||||
}
|
||||
filteredCopy(d->Id, accepted, d->NumPart);
|
||||
filteredCopy(d->type, accepted, d->NumPart);
|
||||
delete[] accepted;
|
||||
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
SimulationLoader *gadgetLoader(const std::string& snapshot, double Mpc_unitLength, int flags)
|
||||
SimulationLoader *gadgetLoader(const std::string& snapshot, double Mpc_unitLength, int flags, SimulationPreprocessor *p)
|
||||
{
|
||||
bool singleFile = false;
|
||||
int num_files;
|
||||
|
@ -120,5 +148,5 @@ SimulationLoader *gadgetLoader(const std::string& snapshot, double Mpc_unitLengt
|
|||
}
|
||||
}
|
||||
|
||||
return new GadgetLoader(snapshot, header, flags, singleFile, num_files, Mpc_unitLength);
|
||||
return new GadgetLoader(snapshot, header, flags, singleFile, num_files, Mpc_unitLength, p);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue