Created
July 8, 2020 09:24
-
-
Save smutch/23d1200c1d4c44b72c5d2bb32dc98abb to your computer and use it in GitHub Desktop.
py: read postprocess grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import xarray as xa | |
import h5py as h5 | |
PATH_IN = "/fred/oz078/smutch/intensity_mapping/baseline/imapping_testrun/HIMass_grids.h5" | |
SNAPSHOT = 250 # z=0 | |
with h5.File(PATH_IN, "r") as fp: | |
ds = fp[f"Snap{SNAPSHOT:03d}"] | |
box_size = ds.attrs["box_size"][:] | |
dim = ds.attrs["dim"][:] | |
grid = xa.DataArray( | |
ds[:], | |
coords=[np.linspace(0, bs, d) for bs, d in zip(box_size, dim)], | |
dims=list("xyz"), | |
name="HIMass", | |
) | |
grid = grid.where(np.isfinite(grid), np.nan) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment