Hi Sam,

This is very strange.  I believe that it's likely a conflict between our implementation of clip in yt 3.x and the numpy version, and my guess is that it has been fixed in unyt or in newer versions of yt.  Which version of yt are you using?

On Wed, Sep 16, 2020 at 5:26 AM Sam Patrick via yt-users <yt-users@python.org> wrote:
Hi all,

I'm trying to do a volume render of the temperature field inside a
sphere with the following code:

val, loc = ds.find_max('density')
sp = ds.sphere(loc, SP_DIST)
source = VolumeSource(sp, 'temperature')
scene = Scene()
scene.add_source(source)

# v is calculated based on angular momentum
camera = scene.add_camera(sp, lens_type= 'perspective')
cam_position = loc + v * CAM_DIST
camera.set_position(cam_position)
camera.set_focus(loc)

source.set_field('temperature')
source.set_log(True)
bounds = (UPPER, LOWER)
tf = yt.ColorTransferFunction(np.log10(bounds))
tf.add_layers(12, colormap='jet')
source.tfh.tf = tf
source.tfh.bounds = bounds
source.tfh.plot('transfer_function.png', profile_field='temperature')
scene.save("render_t={:.3f}".format(times[i]), sigma_clip= 1)

Upon saving though I encounter the error:

Traceback (most recent call last):
   File "plot_3d.py", line 51, in <module>
     scene.save("render_t={:.3f}".format(times[i]), sigma_clip= 1)      
#last sigma = 2
   File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/yt/visualization/volume_rendering/scene.py",
line 310, in save
yt : [INFO     ] 2020-09-15 10:34:02,783 Saving render render_t=0.000.png
     self._last_render.write_png(fname, sigma_clip=sigma_clip)
   File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/yt/data_objects/image_array.py",
line 289, in write_png
     scaled = self.rescale(inline=False)
   File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/yt/data_objects/image_array.py",
line 242, in rescale
     np.clip(out, 0.0, 1.0, out)
   File "<__array_function__ internals>", line 6, in clip
   File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/numpy/core/fromnumeric.py",
line 2084, in clip
     return _wrapfunc(a, 'clip', a_min, a_max, out=out, **kwargs)
   File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/numpy/core/fromnumeric.py",
line 61, in _wrapfunc
     return bound(*args, **kwds)
   File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/numpy/core/_methods.py",
line 132, in _clip
     um.clip, a, min, max, out=out, casting=casting, **kwargs)
   File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/numpy/core/_methods.py",
line 85, in _clip_dep_invoke_with_casting
     return ufunc(*args, out=out, **kwargs)
   File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/yt/units/yt_array.py",
line 1401, in __array_ufunc__
     "added to YTArray." % (str(ufunc), len(inputs)))
RuntimeError: Support for the <ufunc 'clip'> ufunc with 3 inputs has not
beenadded to YTArray.

I would also like to eventually add a colorbar to the side of the
created image which represents the transfer function and annotate text
as well. Does the render functionality allow me to do this? Any help on
these topics would be much appreciated.

Many thanks,
Sam Patrick
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
https://mail.python.org/mailman3/lists/yt-users.python.org/
Member address: matthewturk@gmail.com