mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
added ramses loader
This commit is contained in:
parent
455fcdb9d8
commit
87de672f8c
3 changed files with 104 additions and 10 deletions
|
@ -684,7 +684,7 @@ int main(int argc, char **argv)
|
||||||
if (args_info.ramsesBase_given && args_info.ramsesId_given) {
|
if (args_info.ramsesBase_given && args_info.ramsesId_given) {
|
||||||
loader = ramsesLoader(args_info.ramsesBase_arg,
|
loader = ramsesLoader(args_info.ramsesBase_arg,
|
||||||
args_info.ramsesId_arg,
|
args_info.ramsesId_arg,
|
||||||
false,
|
true, // double precision with ramses... set this to false if you are dealing with single precision
|
||||||
NEED_POSITION|NEED_VELOCITY|NEED_GADGET_ID, preselector);
|
NEED_POSITION|NEED_VELOCITY|NEED_GADGET_ID, preselector);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,6 +25,28 @@
|
||||||
#include <CosmoTool/fortran.hpp>
|
#include <CosmoTool/fortran.hpp>
|
||||||
#include "simulation_loader.hpp"
|
#include "simulation_loader.hpp"
|
||||||
|
|
||||||
|
// ben edit
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <regex.h>
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cassert>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <fstream>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
|
// end ben edit
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace CosmoTool;
|
using namespace CosmoTool;
|
||||||
|
|
||||||
|
@ -61,12 +83,24 @@ public:
|
||||||
SimuData *loadFile(int id) {
|
SimuData *loadFile(int id) {
|
||||||
SimuData *d;
|
SimuData *d;
|
||||||
|
|
||||||
|
|
||||||
|
// cludgy hack until I can get baseid working in this function... the problem is with SimuData *loadFile(int id) ... just need to learn a bit more C++ ~ Ben
|
||||||
|
|
||||||
|
string baseidstr = snapshot_name.c_str();
|
||||||
|
unsigned found = baseidstr.find_last_of("/");
|
||||||
|
baseidstr = baseidstr.substr(found-5,found);
|
||||||
|
baseidstr = baseidstr.substr(0,5); // remove trailing slash
|
||||||
|
baseid = atoi(baseidstr.c_str());
|
||||||
|
|
||||||
if (id >= _num_files)
|
if (id >= _num_files)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
d = loadRamsesSimu(snapshot_name.c_str(), baseid, id, double_precision, load_flags);
|
|
||||||
|
d = loadRamsesSimu("/home/ben/phd/software/VIDE/vide_public/output_00091/", baseid, id, double_precision, load_flags);
|
||||||
assert(d != 0);
|
assert(d != 0);
|
||||||
|
|
||||||
|
cout << " Id " << id << "\n";
|
||||||
|
|
||||||
if (d->Id != 0)
|
if (d->Id != 0)
|
||||||
{
|
{
|
||||||
long *uniqueID = new long[d->NumPart];
|
long *uniqueID = new long[d->NumPart];
|
||||||
|
@ -87,18 +121,66 @@ public:
|
||||||
SimulationLoader *ramsesLoader(const std::string& snapshot, int baseid, bool double_precision, int flags, SimulationPreprocessor *p)
|
SimulationLoader *ramsesLoader(const std::string& snapshot, int baseid, bool double_precision, int flags, SimulationPreprocessor *p)
|
||||||
{
|
{
|
||||||
SimuData *d, *header;
|
SimuData *d, *header;
|
||||||
int num_files = 0;
|
int num_files = 0; // how many particle files are there?
|
||||||
|
|
||||||
header = loadRamsesSimu(snapshot.c_str(), baseid, 0, double_precision, 0);
|
header = loadRamsesSimu(snapshot.c_str(), baseid, 0, double_precision, 0);
|
||||||
|
|
||||||
if (header == 0)
|
if (header == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while ((d = loadRamsesSimu(snapshot.c_str(), baseid, num_files, double_precision, 0)) != 0)
|
|
||||||
|
// count number of CPU's for this output... kinda copy/paste of loadRamses.cpp in cosmotool/src
|
||||||
|
|
||||||
|
ostringstream ss_fname;
|
||||||
|
ss_fname << snapshot.c_str() << "/info_" << setfill('0') << setw(5) << baseid << ".txt";
|
||||||
|
cout << "Opening info file " << ss_fname.str() << " to find cpu number" << endl;
|
||||||
|
ifstream infile(ss_fname.str().c_str());
|
||||||
|
if (!infile)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
int err;
|
||||||
|
regex_t unit_l_rx;
|
||||||
|
|
||||||
|
// const char *pattern = "^unit_l[ ]*=[ ]*([0-9\\.E+\\-]+)";
|
||||||
|
const char *pattern = "^([A-Za-z_]+)[ ]*=[ ]*([0-9\\.E+\\-]+)";
|
||||||
|
|
||||||
|
err = regcomp (&unit_l_rx, pattern, REG_EXTENDED);
|
||||||
|
cout << unit_l_rx.re_nsub << endl;
|
||||||
|
if (err)
|
||||||
{
|
{
|
||||||
num_files++;
|
char errString[255];
|
||||||
delete d;
|
regerror(err, &unit_l_rx, errString, sizeof(errString));
|
||||||
|
cout << errString << endl;
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map<string,double> infoMap;
|
||||||
|
string line;
|
||||||
|
while (getline(infile, line))
|
||||||
|
{
|
||||||
|
regmatch_t allMatch[4];
|
||||||
|
if (!regexec(&unit_l_rx, line.c_str(), 4, allMatch, 0))
|
||||||
|
{
|
||||||
|
uint32_t start0 = allMatch[1].rm_so, end0 = allMatch[1].rm_eo;
|
||||||
|
uint32_t start1 = allMatch[2].rm_so, end1 = allMatch[2].rm_eo;
|
||||||
|
|
||||||
|
string keyword = line.substr(start0, end0-start0);
|
||||||
|
istringstream iss(line.substr(start1, end1-start1));
|
||||||
|
double unitLength;
|
||||||
|
|
||||||
|
iss >> unitLength;
|
||||||
|
|
||||||
|
infoMap[keyword] = unitLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
regfree(&unit_l_rx);
|
||||||
|
|
||||||
|
|
||||||
|
num_files = infoMap["ncpu"];
|
||||||
|
|
||||||
|
|
||||||
return new RamsesLoader(snapshot, baseid, double_precision, header, flags, num_files, p);
|
return new RamsesLoader(snapshot, baseid, double_precision, header, flags, num_files, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,8 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
||||||
dataFileLine = "gadget " + datafile
|
dataFileLine = "gadget " + datafile
|
||||||
elif sample.dataFormat == "sdf":
|
elif sample.dataFormat == "sdf":
|
||||||
dataFileLine = "sdf " + datafile
|
dataFileLine = "sdf " + datafile
|
||||||
|
elif sample.dataFormat == "ramses":
|
||||||
|
dataFileLine = "ramses " + os.path.split(datafile)[0] # just want the output directory
|
||||||
else:
|
else:
|
||||||
raise ValueError("unknown dataFormat '%s'" % sample.dataFormat)
|
raise ValueError("unknown dataFormat '%s'" % sample.dataFormat)
|
||||||
|
|
||||||
|
@ -183,13 +185,19 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
||||||
reshiftFlag = ""
|
reshiftFlag = ""
|
||||||
if not sample.shiftSimZ: reshiftFlag = "preReShift"
|
if not sample.shiftSimZ: reshiftFlag = "preReShift"
|
||||||
|
|
||||||
|
if sample.dataFormat == "ramses":
|
||||||
|
ramsesId = int((os.path.split(datafile)[1])[5:10]) # picks out the particle file (should be the part_NNNNN.outXXXXX, then extracts the output id "NNNNN" as an integer)
|
||||||
|
ramsesIdLine = "ramsesId " + ramsesId
|
||||||
|
else:
|
||||||
|
ramsesIdLine = ""
|
||||||
|
|
||||||
conf="""
|
conf="""
|
||||||
%s
|
%s
|
||||||
output %s
|
output %s
|
||||||
outputParameter %s
|
outputParameter %s
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
gadgetUnit %g
|
%s
|
||||||
rangeX_min %g
|
rangeX_min %g
|
||||||
rangeX_max %g
|
rangeX_max %g
|
||||||
rangeY_min %g
|
rangeY_min %g
|
||||||
|
@ -200,11 +208,11 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
""" % (dataFileLine, outputFile,
|
""" % ((dataFileLine + "/"), outputFile,
|
||||||
outputFile+".par",
|
outputFile+".par",
|
||||||
includePecVelString,
|
includePecVelString,
|
||||||
useLightConeString,
|
useLightConeString,
|
||||||
sample.dataUnit,
|
ramsesIdLine,
|
||||||
xMin, xMax, yMin, yMax,
|
xMin, xMax, yMin, yMax,
|
||||||
sample.zBoundaryMpc[0], sample.zBoundaryMpc[1],
|
sample.zBoundaryMpc[0], sample.zBoundaryMpc[1],
|
||||||
subSampleLine,resubSampleLine,inputParameterFlag,reshiftFlag)
|
subSampleLine,resubSampleLine,inputParameterFlag,reshiftFlag)
|
||||||
|
@ -220,6 +228,8 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
||||||
cmd = "%s --configFile=%s" % (binPath,parmFile)
|
cmd = "%s --configFile=%s" % (binPath,parmFile)
|
||||||
log = open(logFile, 'a')
|
log = open(logFile, 'a')
|
||||||
arg1 = "--configFile=%s" % parmFile
|
arg1 = "--configFile=%s" % parmFile
|
||||||
|
|
||||||
|
|
||||||
subprocess.call(cmd, stdout=log, stderr=log, shell=True)
|
subprocess.call(cmd, stdout=log, stderr=log, shell=True)
|
||||||
log.close()
|
log.close()
|
||||||
|
|
||||||
|
@ -230,7 +240,7 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
||||||
|
|
||||||
doneLine = "Done! %5.2e\n" % keepFraction
|
doneLine = "Done! %5.2e\n" % keepFraction
|
||||||
if not jobSuccessful(logFile, doneLine):
|
if not jobSuccessful(logFile, doneLine):
|
||||||
print "FAILED!"
|
print "FAILED!" ### dies here for now
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
prevSubSample = thisSubSample
|
prevSubSample = thisSubSample
|
||||||
|
@ -312,6 +322,8 @@ def launchZobov(sample, binPath, zobovDir=None, logDir=None, continueRun=None,
|
||||||
|
|
||||||
datafile = zobovDir+"zobov_slice_"+sampleName
|
datafile = zobovDir+"zobov_slice_"+sampleName
|
||||||
|
|
||||||
|
print "zobovDir ", zobovDir
|
||||||
|
|
||||||
logFile = logDir+"/zobov_"+sampleName+".out"
|
logFile = logDir+"/zobov_"+sampleName+".out"
|
||||||
|
|
||||||
vozScript = "./scr_"+sampleName
|
vozScript = "./scr_"+sampleName
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue