cbyrohl / scida

scida is an out-of-the-box analysis tool for large scientific datasets. It primarily supports the astrophysics community, focusing on cosmological and galaxy formation simulations using particles or unstructured meshes, as well as large observational datasets. This tool uses dask, allowing analysis to scale.
https://scida.io
MIT License
28 stars 4 forks source link

Title: TypeError when Indexing Halo Object with Dask Array #59

Closed astronerdF closed 1 year ago

astronerdF commented 1 year ago
from scida import load

ds = load(basePath+"/snapdir_099")

data = ds.return_data(subhaloID=42)

The above code is taken from the website https://cbyrohl.github.io/scida/halocatalogs/ and it gives the following error:

TypeError                                 Traceback (most recent call last)
Cell In[132], line 4
      1 from scida import load
      2 ds = load(basePath+"[/snapdir_099](https://vscode-remote+ssh-002dremote-002bvera2.vscode-resource.vscode-cdn.net/snapdir_099)")
----> 4 data = ds.return_data(haloID=42)

File [~/conda-envs/myenv/lib/python3.10/site-packages/scida/interface.py:385](https://vscode-remote+ssh-002dremote-002bvera2.vscode-resource.vscode-cdn.net/u/fahma/Test/Metallicity/~/conda-envs/myenv/lib/python3.10/site-packages/scida/interface.py:385), in Selector.__call__..newfn(*args, **kwargs)
    382 self.data = FieldContainer()
    383 deepdictkeycopy(self.data_backup, self.data)
--> 385 self.prepare(*args, **kwargs)
    386 if self.keys is None:
    387     raise NotImplementedError(
    388         "Subclass implementation needed for self.keys!"
    389     )

File [~/conda-envs/myenv/lib/python3.10/site-packages/scida/customs/arepo/dataset.py:56](https://vscode-remote+ssh-002dremote-002bvera2.vscode-resource.vscode-cdn.net/u/fahma/Test/Metallicity/~/conda-envs/myenv/lib/python3.10/site-packages/scida/customs/arepo/dataset.py:56), in ArepoSelector.prepare(self, *args, **kwargs)
     54         length = lengths[pnum]
     55         for k, v in self.data_backup[p].items():
---> 56             self.data[p][k] = v[offset : offset + length]
     57 snap.data = self.data

File [~/conda-envs/myenv/lib/python3.10/site-packages/pint/facets/numpy/quantity.py:242](https://vscode-remote+ssh-002dremote-002bvera2.vscode-resource.vscode-cdn.net/u/fahma/Test/Metallicity/~/conda-envs/myenv/lib/python3.10/site-packages/pint/facets/numpy/quantity.py:242), in NumpyQuantity.__getitem__(self, key)
    240     raise
    241 except TypeError:
--> 242     raise TypeError(
    243         "Neither Quantity object nor its magnitude ({})"
    244         "supports indexing".format(self._magnitude)
    245     )

TypeError: Neither Quantity object nor its magnitude (dask.array)supports indexing
dnelson86 commented 1 year ago

If you include your value of basePath then this could be reproduced for testing.

cbyrohl commented 1 year ago

Sorry about that. I think this should be fixed now. Could you check?

Just to make sure: Do you mean subhaloID or haloID in above call? Only latter should work.

astronerdF commented 1 year ago

Thank you! It works now. (I had meant haloID) Is there an option to load the subHalos?

cbyrohl commented 1 year ago

Is there an option to load the subHalos?

there is with the next minor release with the argument called subhaloID

cbyrohl commented 1 year ago

halo selection now working with units. Additionally subhaloID attribute added.