White phase exporter (for mpgrafic e.g.)
This commit is contained in:
parent
1aaf5f4a13
commit
ddb66ab436
3 changed files with 17 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
from _cosmotool import *
|
||||
from grafic import writeGrafic
|
||||
from grafic import writeGrafic, writeWhitePhase
|
||||
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(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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue