Hi Daniel,

What is your version of NumPy? There is an issue with NumPy 1.18 which causes this:


This is fixed in yt 3.6 but not yet in 4.0. The temporary solution is to downgrade to NumPy 1.17. 

Also, the problem with TNG halos is that yt won’t recognize them as Arepo datasets. In order to make them work, you have to hack them like this:

# Now we have to open up the file we downloaded and fix the header
# in the file to include info yt needs to read this as an Arepo file 
f = h5py.File(saved_filename, "r+")
f["Header"].attrs["NumPart_Total"] = np.array(f["Header"].attrs["NumPart_ThisFile"])
f["/Config"].attrs["VORONOI"] = 1

We should fix this in the future. 



On Apr 24, 2020, at 10:11 AM, Daniel DeFelippis <dad2183@columbia.edu> wrote:


I'm trying to create a projection plot of velocity (e.g. velocity_x) for a halo from IllustrisTNG ('cutout_478037.hdf5' below). I'm using the demeshened version of yt (yt-4.0). When I try to do this it fails with the following error message. This only seems to occur when I try to make a projection of a quantity with positive and negative values. If I instead use 'density' or 'temperature' for example, it works fine. Any suggestions?

Thank you,

ds = yt.load('cutout_478037.hdf5')

TypeError                                 Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
   116     try:
--> 117         num = operator.index(num)
   118     except TypeError:

TypeError: 'numpy.float64' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-21-7770240b54f8> in <module>
     1 ds = yt.load('cutout_478037.hdf5')
----> 2 yt.ProjectionPlot(ds,'x',('gas','velocity_x'),width=(400,'kpc'))
     3 #slc.save('testplot.pdf')
     4 #slc.set_zlim(('gas','radial_velocity'),-200,200)
     5 #slc.annotate_title(title)

~/yt/yt/visualization/plot_window.py in __init__(self, ds, axis, fields, center, width, axes_unit, weight_field, max_level, origin, right_handed, fontsize, field_parameters, data_source, method, proj_style, window_size, buff_size, aspect)
  1609         PWViewerMPL.__init__(self, proj, bounds, fields=fields, origin=origin,
  1610                              right_handed=right_handed, fontsize=fontsize, window_size=window_size,
-> 1611                              aspect=aspect, buff_size=buff_size)
  1612         if axes_unit is None:
  1613             axes_unit = get_axes_unit(width, ds)

~/yt/yt/visualization/plot_window.py in __init__(self, *args, **kwargs)
   780             self._plot_type = kwargs.pop("plot_type")
   781         self._splat_color = kwargs.pop("splat_color", None)
--> 782         PlotWindow.__init__(self, *args, **kwargs)
   784     def _setup_origin(self):

~/yt/yt/visualization/plot_window.py in __init__(self, data_source, bounds, buff_size, antialias, periodic, origin, oblique, right_handed, window_size, fields, fontsize, aspect, setup)
   215                 self._field_transform[field] = linear_transform
   216         self.setup_callbacks()
--> 217         self._setup_plots()
   219     def __iter__(self):

~/yt/yt/visualization/plot_window.py in _setup_plots(self)
  1066                     else: # symlog_transform
  1067                         flinthresh = 10**np.floor( np.log10( self.plots[f].cb.norm.linthresh ) )
-> 1068                         mticks = self.plots[f].image.norm( get_symlog_minorticks(flinthresh, vmin, vmax) )
  1069                     self.plots[f].cax.yaxis.set_ticks(mticks, minor=True)
  1070             else:

~/yt/yt/visualization/plot_container.py in get_symlog_minorticks(linthresh, vmin, vmax)
   129         return np.hstack((-get_log_minorticks(linthresh,-vmin)[::-1], 0) )
   130     else:
--> 131         return np.hstack((-get_log_minorticks(linthresh,-vmin)[::-1], 0,
   132                           get_log_minorticks(linthresh, vmax)))

~/yt/yt/visualization/plot_container.py in get_log_minorticks(vmin, vmax)
   105             expA += 1
   106         else:
--> 107             lmticks = np.hstack( (lmticks, np.linspace(cofA, cofB, cofB-cofA+1)*10**expA) )
   108             expA += 1
   109     return np.array(lmticks)

<__array_function__ internals> in linspace(*args, **kwargs)

~/anaconda3/lib/python3.6/site-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
   119         raise TypeError(
   120             "object of type {} cannot be safely interpreted as an integer."
--> 121                 .format(type(num)))
   123     if num < 0:

TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org