Skip to content

Commit

Permalink
move double precision check to outside i==0 conditional.
Browse files Browse the repository at this point in the history
also look directly at the header rather than the new dictionary.
  • Loading branch information
agurvich committed Apr 25, 2022
1 parent d314f76 commit 5c18c97
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/abg_python/snapshot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ def openSnapshot(
## let the user know what snapshot file we're trying to open
if loud: print(fname)
with h5py.File(fname,'r') as handle:
## determine if the coordinates are in double precision, by default they are not
if ('Flag_DoublePrecision' in handle['Header'].attrs and
'Flag_DoublePrecision' in handle['Header'].attrs['Flag_DoublePrecision']):
coord_dtype = np.float64
else: coord_dtype = np.float32

if i == 0:
## read header once
if not no_header_keys: fillHeader(new_dictionary,handle)
Expand All @@ -171,11 +177,6 @@ def openSnapshot(
if 'PartType%d'%ptype not in handle: continue
## load snapshot data
if not header_only:
## decide if the coordinates are in double precision, by default they are not
if ('Flag_DoublePrecision' in new_dictionary and
new_dictionary['Flag_DoublePrecision']): coord_dtype = np.float64
else: coord_dtype = np.float32

## initialize particle arrays
for pkey in handle['PartType%d'%ptype].keys():
if (
Expand Down

0 comments on commit 5c18c97

Please sign in to comment.