diff --git a/doc/source/pythonmodule.rst b/doc/source/pythonmodule.rst index 58a309e..bc5e42a 100644 --- a/doc/source/pythonmodule.rst +++ b/doc/source/pythonmodule.rst @@ -30,6 +30,11 @@ The simulation loaders .. autofunction:: loadGadget .. autofunction:: loadParallelGadget +Grafic Input and Output +----------------------- + +.. autofunction:: readGrafic + Timing ------ diff --git a/python/cosmotool/grafic.py b/python/cosmotool/grafic.py index 65ac6c1..4ea6f9b 100644 --- a/python/cosmotool/grafic.py +++ b/python/cosmotool/grafic.py @@ -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