Search code examples
pythonpython-3.xattributeerroryt

AttributeError: 'DatasetSeries' object has no attribute 'all_data'


import glob
from os.path import join
import yt
from yt.config import ytcfg
path = ytcfg.get("yt", "test_data_dir")

from mpl_toolkits.mplot3d import Axes3D
my_fns = glob.glob(join(path, "Orbit", "puredef_hdf5_chk_000000"))
my_fns.sort()
fields = ["particle_velocity_x", "particle_velocity_y", "particle_velocity_z"]
ds = yt.load(my_fns[:])
dd = ds.all_data()
indices = dd["particle_index"].astype("int")
print (indices)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-27-1bae40a7b7ba> in <module>
      1 ds = yt.load(my_fns[:])
----> 2 dd = ds.all_data()
      3 indices = dd["particle_index"].astype("int")
      4 print (indices)

AttributeError: 'DatasetSeries' object has no attribute 'all_data'

I have looked at other posts on here, but many of them deal with different aspects of this error that deals with lens or other statements.


Solution

  • I had exactly the same error recently, with a very similar code. First of all, a mistake I did was giving the code the symbolic links to the real data files, while it should work directly with the data. Another issue was a problem with the installation of the yt library, version 3.6.1. I had installed it using the pip command, but it wasn't working well, so I uninstalled it and I used the "all-in-one" script they provide on their homepage.

    Fixing these two things together solved completely this problem.