This commit is contained in:
Guilhem Lavaux 2014-12-07 22:07:10 +01:00
parent e6068c0aa0
commit 7a27dae025
2 changed files with 19 additions and 1 deletions

View File

@ -30,6 +30,11 @@ The simulation loaders
.. autofunction:: loadGadget
.. autofunction:: loadParallelGadget
Grafic Input and Output
-----------------------
.. autofunction:: readGrafic
Timing
------

View File

@ -2,7 +2,20 @@ import struct
import numpy as np
def readGrafic(filename):
"""This function reads a grafic file.
Arguments:
filename (str): the path to the grafic file
Returns:
a tuple containing:
* the array held in the grafic file
* the size of the box
* the scale factor
* the mean matter density :math:`\Omega_\mathrm{m}`
* the dark energy density :math:`\Omega_\Lambda`
* the hubble constant, relative to 100 km/s/Mpc
"""
with file(filename, mode="rb") as f:
p = struct.unpack("IIIIffffffffI", f.read(4*11 + 2*4))
checkPoint0, Nx, Ny, Nz, delta, _, _, _, scalefac, omega0, omegalambda0, h, checkPoint1 = p