mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
Merged
This commit is contained in:
commit
60ae61a436
3 changed files with 114 additions and 9 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <CosmoTool/loadSimu.hpp>
|
#include <CosmoTool/loadSimu.hpp>
|
||||||
#include <CosmoTool/loadRamses.hpp>
|
#include <CosmoTool/loadRamses.hpp>
|
||||||
|
#include <CosmoTool/loadGadget.hpp>
|
||||||
#include <CosmoTool/interpolate.hpp>
|
#include <CosmoTool/interpolate.hpp>
|
||||||
#include <CosmoTool/fortran.hpp>
|
#include <CosmoTool/fortran.hpp>
|
||||||
#include "generateMock_conf.h"
|
#include "generateMock_conf.h"
|
||||||
|
@ -61,6 +62,72 @@ SimuData *doLoadRamses(const char *basename, int baseid, int velAxis, bool goRed
|
||||||
return outd;
|
return outd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SimuData *doLoadGadget(const char *gadgetname, int velAxis, bool goRedshift)
|
||||||
|
{
|
||||||
|
SimuData *d, *outd;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
d = loadGadgetMulti(gadgetname, -1, 0);
|
||||||
|
}
|
||||||
|
catch (const NoSuchFileException& e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
d = loadGadgetMulti(gadgetname, 0, 0);
|
||||||
|
}
|
||||||
|
catch(const NoSuchFileException& e)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outd = new SimuData;
|
||||||
|
|
||||||
|
outd->NumPart = d->TotalNumPart;
|
||||||
|
outd->BoxSize = d->BoxSize;
|
||||||
|
outd->TotalNumPart = outd->NumPart;
|
||||||
|
outd->Hubble = d->Hubble;
|
||||||
|
outd->Omega_Lambda = d->Omega_Lambda;
|
||||||
|
outd->Omega_M = d->Omega_M;
|
||||||
|
outd->time = d->time;
|
||||||
|
|
||||||
|
for (int k = 0; k < 3; k++)
|
||||||
|
outd->Pos[k] = new float[outd->NumPart];
|
||||||
|
outd->Vel[2] = new float[outd->NumPart];
|
||||||
|
delete d;
|
||||||
|
|
||||||
|
int curCpu = 0;
|
||||||
|
cout << "loading file 0 " << endl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
d = loadGadgetMulti(gadgetname, curCpu, NEED_POSITION|NEED_VELOCITY|NEED_GADGET_ID);
|
||||||
|
for (int k = 0; k < 3; k++)
|
||||||
|
for (int i = 0; i < d->NumPart; i++)
|
||||||
|
{
|
||||||
|
assert(d->Id[i] >= 1);
|
||||||
|
assert(d->Id[i] <= outd->TotalNumPart);
|
||||||
|
outd->Pos[k][d->Id[i]-1] = d->Pos[k][i];
|
||||||
|
outd->Vel[2][d->Id[i]-1] = d->Vel[velAxis][i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (goRedshift)
|
||||||
|
for (int i = 0; i < d->NumPart; i++)
|
||||||
|
outd->Pos[velAxis][d->Id[i]-1] += d->Vel[velAxis][i]/100.;
|
||||||
|
|
||||||
|
delete d;
|
||||||
|
curCpu++;
|
||||||
|
cout << "loading file " << curCpu << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const NoSuchFileException& e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return outd;
|
||||||
|
}
|
||||||
|
|
||||||
static double cubic(double a)
|
static double cubic(double a)
|
||||||
{
|
{
|
||||||
return a*a*a;
|
return a*a*a;
|
||||||
|
@ -324,10 +391,38 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
generateMock_conf_print_version();
|
generateMock_conf_print_version();
|
||||||
|
|
||||||
|
if (args_info.ramsesBase_given || args_info.ramsesId_given)
|
||||||
|
{
|
||||||
|
if (args_info.ramsesBase_given && args_info.ramsesId_given)
|
||||||
simu = doLoadRamses(args_info.ramsesBase_arg,
|
simu = doLoadRamses(args_info.ramsesBase_arg,
|
||||||
args_info.ramsesId_arg,
|
args_info.ramsesId_arg,
|
||||||
args_info.axis_arg, false);
|
args_info.axis_arg, false);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cerr << "Both ramsesBase and ramsesId are required to be able to load snapshots" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simu == 0)
|
||||||
|
{
|
||||||
|
cerr << "Error while loading" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args_info.gadget_given)
|
||||||
|
{
|
||||||
|
simu = doLoadGadget(args_info.gadget_arg, args_info.axis_arg, false);
|
||||||
|
if (simu == 0)
|
||||||
|
{
|
||||||
|
cerr << "Error while loading " << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cerr << "Either a ramses snapshot or a gadget snapshot is required." << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
cout << "Hubble = " << simu->Hubble << endl;
|
cout << "Hubble = " << simu->Hubble << endl;
|
||||||
cout << "Boxsize = " << simu->BoxSize << endl;
|
cout << "Boxsize = " << simu->BoxSize << endl;
|
||||||
cout << "Omega_M = " << simu->Omega_M << endl;
|
cout << "Omega_M = " << simu->Omega_M << endl;
|
||||||
|
@ -335,7 +430,13 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
double *expfact;
|
double *expfact;
|
||||||
|
|
||||||
|
if (args_info.cosmo_flag)
|
||||||
metricTransform(simu, args_info.axis_arg, args_info.preReShift_flag, args_info.peculiarVelocities_flag, expfact);
|
metricTransform(simu, args_info.axis_arg, args_info.preReShift_flag, args_info.peculiarVelocities_flag, expfact);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
expfact = new double[simu->NumPart];
|
||||||
|
for (int j = 0; j < simu->NumPart; j++) expfact[j] = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
makeBox(simu, expfact, simuOut, args_info);
|
makeBox(simu, expfact, simuOut, args_info);
|
||||||
delete simu;
|
delete simu;
|
||||||
|
|
|
@ -4,8 +4,10 @@ version "0"
|
||||||
option "configFile" - "Configuration file path" string optional
|
option "configFile" - "Configuration file path" string optional
|
||||||
|
|
||||||
# Ramses data
|
# Ramses data
|
||||||
option "ramsesBase" - "Base directory for ramses" string required
|
option "ramsesBase" - "Base directory for ramses" string optional
|
||||||
option "ramsesId" - "Ramses snapshot id" int required
|
option "ramsesId" - "Ramses snapshot id" int optional
|
||||||
|
|
||||||
|
option "gadget" - "Base name of gadget snapshot (without parallel writing extension)" string optional
|
||||||
|
|
||||||
option "axis" - "Redshift axis (X=0, Y=1, Z=2)" int optional default="2"
|
option "axis" - "Redshift axis (X=0, Y=1, Z=2)" int optional default="2"
|
||||||
|
|
||||||
|
@ -21,3 +23,5 @@ option "rangeZ_max" - "Maximum range in Z for making the box (after distorti
|
||||||
|
|
||||||
option "preReShift" - "Reshift the zero of the Z axis" flag off
|
option "preReShift" - "Reshift the zero of the Z axis" flag off
|
||||||
option "peculiarVelocities" - "Added peculiar velocities distortion" flag off
|
option "peculiarVelocities" - "Added peculiar velocities distortion" flag off
|
||||||
|
|
||||||
|
option "cosmo" - "Apply cosmological redshift" flag on
|
||||||
|
|
|
@ -9,6 +9,7 @@ bool loadParticleInfo(ParticleInfo& info,
|
||||||
const std::string& particles,
|
const std::string& particles,
|
||||||
const std::string& extra_info)
|
const std::string& extra_info)
|
||||||
{
|
{
|
||||||
|
int numpart;
|
||||||
|
|
||||||
NcFile f_info(extra_info.c_str());
|
NcFile f_info(extra_info.c_str());
|
||||||
|
|
||||||
|
@ -29,7 +30,6 @@ bool loadParticleInfo(ParticleInfo& info,
|
||||||
{
|
{
|
||||||
UnformattedRead f(particles);
|
UnformattedRead f(particles);
|
||||||
|
|
||||||
int numpart;
|
|
||||||
float mul, offset;
|
float mul, offset;
|
||||||
|
|
||||||
f.beginCheckpoint();
|
f.beginCheckpoint();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue