upgraded python to support gadget format type 2

This commit is contained in:
Guilhem Lavaux 2016-01-29 10:24:50 +01:00
parent f2e015b1fb
commit 450a9a4185
2 changed files with 10 additions and 10 deletions

View File

@ -36,11 +36,11 @@ cdef extern from "loadSimu.hpp" namespace "CosmoTool":
cdef extern from "loadGadget.hpp" namespace "CosmoTool":
SimuData *loadGadgetMulti(const char *fname, int id, int flags) nogil except +
SimuData *loadGadgetMulti(const char *fname, int id, int flags, int gformat) nogil except +
void cxx_writeGadget "CosmoTool::writeGadget" (const char * s, SimuData *data) except +
cdef extern from "safe_gadget.hpp":
SimuData *loadGadgetMulti_safe(cppstring.string s, int flags) nogil
SimuData *loadGadgetMulti_safe(cppstring.string s, int flags, int gformat) nogil
SimuData **alloc_simudata(int num) nogil
void del_simudata(SimuData **d) nogil
@ -361,8 +361,8 @@ cdef object wrap_simudata(SimuData *data, int flags):
return simu
def loadGadget(str filename, int snapshot_id, bool loadPosition = True, bool loadVelocity = False, bool loadId = False, bool loadType = False, bool loadMass=False):
"""loadGadget(filename, snapshot_id, loadPosition=True, loadVelocity=False, loadId=False, loadType=False)
def loadGadget(str filename, int snapshot_id, int gadgetFormat = 1, bool loadPosition = True, bool loadVelocity = False, bool loadId = False, bool loadType = False, bool loadMass=False):
"""loadGadget(filename, snapshot_id, gadgetFormat = 1, loadPosition=True, loadVelocity=False, loadId=False, loadType=False)
This function loads Gadget-1 snapshot format.
@ -401,14 +401,14 @@ def loadGadget(str filename, int snapshot_id, bool loadPosition = True, bool loa
if loadMass:
flags |= NEED_MASS
data = loadGadgetMulti(filename, snapshot_id, flags)
data = loadGadgetMulti(filename, snapshot_id, flags, gadgetFormat)
if data == <SimuData*>0:
return None
return PySimulationAdaptor(wrap_simudata(data, flags))
def loadParallelGadget(object filename_list, bool loadPosition = True, bool loadVelocity = False, bool loadId = False, bool loadType = False, bool loadMass=False):
"""loadParallelGadget(filename list, loadPosition=True, loadVelocity=False, loadId=False, loadType=False)
def loadParallelGadget(object filename_list, int gadgetFormat = 1, bool loadPosition = True, bool loadVelocity = False, bool loadId = False, bool loadType = False, bool loadMass=False):
"""loadParallelGadget(filename list, gadgetFormat=1, loadPosition=True, loadVelocity=False, loadId=False, loadType=False)
Arguments:
filename (list): a list or tuple of filenames to load in parallel
@ -449,7 +449,7 @@ def loadParallelGadget(object filename_list, bool loadPosition = True, bool load
with nogil:
for i in prange(num_files):
local_data = loadGadgetMulti_safe(filenames[i], flags)
local_data = loadGadgetMulti_safe(filenames[i], flags, gadgetFormat)
data[i] = local_data
# data[i] = loadGadgetMulti(filenames[i].c_str(), -1, flags)

View File

@ -3,11 +3,11 @@
#include <string>
static inline
CosmoTool::SimuData *loadGadgetMulti_safe(const std::string& fname, int flags)
CosmoTool::SimuData *loadGadgetMulti_safe(const std::string& fname, int flags, int gadgetFormat)
{
try
{
return CosmoTool::loadGadgetMulti(fname.c_str(), -1, flags);
return CosmoTool::loadGadgetMulti(fname.c_str(), -1, flags, gadgetFormat);
}
catch (const CosmoTool::Exception& e)
{