White phase exporter (for mpgrafic e.g.)

This commit is contained in:
Guilhem Lavaux 2014-06-02 10:41:39 +02:00
parent 1aaf5f4a13
commit ddb66ab436
3 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,5 @@
from _cosmotool import *
from grafic import writeGrafic
from grafic import writeGrafic, writeWhitePhase
from borg import read_borg_vol

View File

@ -22,3 +22,18 @@ def writeGrafic(filename, field, BoxSize, scalefac, **cosmo):
f.write(field[i].astype(np.float32).tostring())
f.write(struct.pack("I", checkPoint))
def writeWhitePhase(filename, field):
with file(filename, mode="wb") as f:
Nx,Ny,Nz = field.shape
checkPoint = 4*4
f.write(struct.pack("IIIIII", checkPoint, Nx, Ny, Nz, 0, checkPoint))
checkPoint = struct.pack("I", 4*Ny*Nz)
for i in xrange(Nx):
f.write(checkPoint)
f.write(field[i].astype(np.float32).tostring())
f.write(checkPoint)

View File

@ -62,3 +62,4 @@ def write_icfiles(*generated_ic, **cosmo):
ct.writeGrafic("ic_velc%s" % c, vel[i].reshape((N,N,N)), L, a_ic, **cosmo)
ct.writeGrafic("ic_deltab", density, L, a_ic, **cosmo)
ct.writeWhitePhase("white.dat", density)