Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(snapshot_utils) 'coord_dtype' not defined error in openSnapshot #2

Closed
isulta opened this issue Apr 25, 2022 · 4 comments
Closed

(snapshot_utils) 'coord_dtype' not defined error in openSnapshot #2

isulta opened this issue Apr 25, 2022 · 4 comments

Comments

@isulta
Copy link

isulta commented Apr 25, 2022

The error message is

UnboundLocalError                         Traceback (most recent call last)
<ipython-input-27-453fc46f293a> in <module>
----> 1 openSnapshot('/projects/b1026/anglesd/FIRE/h206_HR_sn1dy300ro100ss', 153, ptype=5, keys_to_extract=['Coordinates'])

~/tools/abg_python/src/abg_python/snapshot_utils.py in openSnapshot(snapdir, snapnum, ptype, cosmological, header_only, keys_to_extract, fnames, chimes_keys, abg_subsnap, snapdir_name, loud, no_header_keys)
    218                             ## handle potentially double precision coordinates
    219                             if pkey == 'Coordinates':
--> 220                                 value = np.array(handle['PartType%d/%s'%(ptype,pkey)],dtype=coord_dtype)*unit_fact
    221                             else: value = np.array(handle['PartType%d/%s'%(ptype,pkey)])*unit_fact
    222 

UnboundLocalError: local variable 'coord_dtype' referenced before assignment

The error can be duplicated on Quest using
openSnapshot('/projects/b1026/anglesd/FIRE/h206_HR_sn1dy300ro100ss', 153, ptype=5, keys_to_extract=['Coordinates']).

In snapshot 153 of the simulation, particle type 5 is not defined in snapshot_153.0.hdf5, but it is defined in the other three subfiles. I think this may be causing the issue.

@agurvich
Copy link
Owner

does 5c18c97 fix it?

@isulta
Copy link
Author

isulta commented Apr 25, 2022

Getting a numpy error:

In [2]: openSnapshot('/projects/b1026/anglesd/FIRE/h206_HR_sn1dy300ro100ss', 153, ptype=5, keys_to_extract=['Coordinates'], loud=1)
/projects/b1026/anglesd/FIRE/h206_HR_sn1dy300ro100ss/snapdir_153/snapshot_153.0.hdf5
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-645c4d6d9b88> in <module>
----> 1 openSnapshot('/projects/b1026/anglesd/FIRE/h206_HR_sn1dy300ro100ss', 153, ptype=5, keys_to_extract=['Coordinates'], loud=1)

~/tools/abg_python/src/abg_python/snapshot_utils.py in openSnapshot(snapdir, snapnum, ptype, cosmological, header_only, keys_to_extract, fnames, chimes_keys, abg_subsnap, snapdir_name, loud, no_header_keys)
    149             ## determine if the coordinates are in double precision, by default they are not
    150             if ('Flag_DoublePrecision' in handle['Header'].attrs and 
--> 151                 'Flag_DoublePrecision' in handle['Header'].attrs['Flag_DoublePrecision']): 
    152                 coord_dtype = np.float64
    153             else: coord_dtype = np.float32

TypeError: argument of type 'numpy.int32' is not iterable

@agurvich
Copy link
Owner

oh duh sorry i copied the line above and went too quickly. try 2375a47

@isulta
Copy link
Author

isulta commented Apr 25, 2022

looks like that did the trick-- thanks for the quick update!

@isulta isulta closed this as completed Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants