Closed MatthieuSchaller closed 10 months ago
This might be the better code snippet to refer to as it includes the read of the file
import swiftsimio as sw
import numpy as np
from unyt import Mpc
filename = "/cosma8/data/dp004/flamingo/Runs/L1000N1800/HYDRO_FIDUCIAL/snapshots/flamingo_0077/flamingo_0077.0.hdf5"
mask = sw.mask(filename)
load_region = [[10*Mpc, 15*Mpc], [100*Mpc, 110*Mpc], [200*Mpc, 210*Mpc]]
print(load_region)
# Constrain the mask
mask.constrain_spatial(load_region)
# Now load the snapshot with this mask
data = sw.load(filename, mask=mask)
print(np.min(data.gas.coordinates, axis = 0))
print(np.max(data.gas.coordinates, axis = 0))
Seems like there is no information in the snapshot that it is partial. Could we add this to SWIFT for future runs? I guess we can also check if NumPart_ThisFile != NumPart_Total, and also say if Virtual then we're good? Tricky.
Update: There is NumFilesPerSnapshot
and ThisFile
saying which index it is. The virtual files seem to have NumFilesPerSnapshot
= 1 and ThisFile
= 1 as well as Virtual
= 1.
/Header/NumFilesPerSnapshot
tells you whether you need to read more than one thing.
The virtual file says num_file=1 since you only need to read that one. But it sets /Header/Virtual
to 1
.
So I can check if NumFilesPerSnapshot is > 1 and say "no partial loading for you"?
Yes.
Fixed by #170.
Bug reported on Slack by @Joeybraspenning.
Code snippet running on a flamingo box and reading the
.0
file rather than the virtual file:leads to
The code should either use the meta-data to open the correct sub-file or throw an error about trying to access a region not present in the file.