White phase exporter (for mpgrafic e.g.)
This commit is contained in:
parent
1aaf5f4a13
commit
ddb66ab436
@ -1,5 +1,5 @@
|
|||||||
from _cosmotool import *
|
from _cosmotool import *
|
||||||
from grafic import writeGrafic
|
from grafic import writeGrafic, writeWhitePhase
|
||||||
from borg import read_borg_vol
|
from borg import read_borg_vol
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,3 +22,18 @@ def writeGrafic(filename, field, BoxSize, scalefac, **cosmo):
|
|||||||
f.write(field[i].astype(np.float32).tostring())
|
f.write(field[i].astype(np.float32).tostring())
|
||||||
f.write(struct.pack("I", checkPoint))
|
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)
|
||||||
|
|
||||||
|
@ -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_velc%s" % c, vel[i].reshape((N,N,N)), L, a_ic, **cosmo)
|
||||||
|
|
||||||
ct.writeGrafic("ic_deltab", density, L, a_ic, **cosmo)
|
ct.writeGrafic("ic_deltab", density, L, a_ic, **cosmo)
|
||||||
|
ct.writeWhitePhase("white.dat", density)
|
||||||
|
Loading…
Reference in New Issue
Block a user