upgraded python to support gadget format type 2
This commit is contained in:
parent
f2e015b1fb
commit
450a9a4185
@ -36,11 +36,11 @@ cdef extern from "loadSimu.hpp" namespace "CosmoTool":
|
|||||||
|
|
||||||
cdef extern from "loadGadget.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 +
|
void cxx_writeGadget "CosmoTool::writeGadget" (const char * s, SimuData *data) except +
|
||||||
|
|
||||||
cdef extern from "safe_gadget.hpp":
|
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
|
SimuData **alloc_simudata(int num) nogil
|
||||||
void del_simudata(SimuData **d) nogil
|
void del_simudata(SimuData **d) nogil
|
||||||
|
|
||||||
@ -361,8 +361,8 @@ cdef object wrap_simudata(SimuData *data, int flags):
|
|||||||
|
|
||||||
return simu
|
return simu
|
||||||
|
|
||||||
def loadGadget(str filename, int snapshot_id, bool loadPosition = True, bool loadVelocity = False, bool loadId = False, bool loadType = False, bool loadMass=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, loadPosition=True, loadVelocity=False, loadId=False, loadType=False)
|
"""loadGadget(filename, snapshot_id, gadgetFormat = 1, loadPosition=True, loadVelocity=False, loadId=False, loadType=False)
|
||||||
|
|
||||||
This function loads Gadget-1 snapshot format.
|
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:
|
if loadMass:
|
||||||
flags |= NEED_MASS
|
flags |= NEED_MASS
|
||||||
|
|
||||||
data = loadGadgetMulti(filename, snapshot_id, flags)
|
data = loadGadgetMulti(filename, snapshot_id, flags, gadgetFormat)
|
||||||
if data == <SimuData*>0:
|
if data == <SimuData*>0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return PySimulationAdaptor(wrap_simudata(data, flags))
|
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):
|
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, loadPosition=True, loadVelocity=False, loadId=False, loadType=False)
|
"""loadParallelGadget(filename list, gadgetFormat=1, loadPosition=True, loadVelocity=False, loadId=False, loadType=False)
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
filename (list): a list or tuple of filenames to load in parallel
|
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:
|
with nogil:
|
||||||
for i in prange(num_files):
|
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] = local_data
|
||||||
# data[i] = loadGadgetMulti(filenames[i].c_str(), -1, flags)
|
# data[i] = loadGadgetMulti(filenames[i].c_str(), -1, flags)
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
static inline
|
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
|
try
|
||||||
{
|
{
|
||||||
return CosmoTool::loadGadgetMulti(fname.c_str(), -1, flags);
|
return CosmoTool::loadGadgetMulti(fname.c_str(), -1, flags, gadgetFormat);
|
||||||
}
|
}
|
||||||
catch (const CosmoTool::Exception& e)
|
catch (const CosmoTool::Exception& e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user