Error in streamline plotting
Dear Nathan:
Thanks that worked. Also could you let me know the difference between the
normal vector and north vector in offaxissliceplot. I had done it earlier
but seemed to have forgotten.
What choice of normal vector and north vector do I use if I want for
example an xz plot inclined at 60 degrees?
On Sun, Feb 4, 2018 at 11:00 AM,
Send yt-users mailing list submissions to yt-users@python.org
To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mm3/mailman3/lists/yt-users.python.org/ or, via email, send a message with subject or body 'help' to yt-users-request@python.org
You can reach the person managing the list at yt-users-owner@python.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of yt-users digest..."
Today's Topics:
1. Re: Error in streamline plotting (Nathan Goldbaum)
----------------------------------------------------------------------
Date: Sat, 03 Feb 2018 20:51:42 -0000 From: "Nathan Goldbaum"
Subject: [yt-users] Re: Error in streamline plotting To: yt-users@python.org Message-ID: <20180203205142.6944.23743@mail.python.org> Content-Type: text/plain; charset="utf-8" Dear Nathan:
Here is tracebin of the error in streamline plotting. Thanks in advance
yt : [WARNING ] 2018-02-03 14:39:03,549 Switching to symlog colorbar scaling unless linear scaling is specified later /cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site-packages/ matplotlib/colors.py:1114: RuntimeWarning: invalid value encountered in greater masked = np.abs(a) > self.linthresh /cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site-packages/ matplotlib/colors.py:1126: RuntimeWarning: invalid value encountered in greater masked = np.abs(a) > (self.linthresh * self._linscale_adj) /cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site-packages/ yt/units/yt_array.py:985: RuntimeWarning: invalid value encountered in divide np.divide(self, oth, out=self) Traceback (most recent call last): File "yt_frb_offaxes.py", line 61, in <module> plt.streamplot(X,Y,U,V,norm='True')
Here's the line in your script that's triggering the error you're seeing.
The issue is that you're passing data with units to matplotlib. Matplotlib doesn't know anything about yt's unit system, so you need to strip the units before passing to matplotlib.
The following modification should fix things:
plt.streamplot(np.array(X),np.array(Y),np.array(U),np.array( V),norm='True')
File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site- packages/matplotlib/pyplot.py", line 3542, in streamplot data=data) File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site- packages/matplotlib/__init__.py", line 1717, in inner return func(ax, *args, **kwargs) File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site- packages/matplotlib/axes/_axes.py", line 4624, in streamplot integration_direction=integration_direction) File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site-packages/matplotlib/ streamplot.py", line 83, in streamplot grid = Grid(x, y) File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site-packages/matplotlib/ streamplot.py", line 315, in __init__ if not np.allclose(x_row, x): File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site- packages/numpy/core/numeric.py", line 2459, in allclose res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan)) File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site- packages/numpy/core/numeric.py", line 2541, in isclose return within_tol(x, y, atol, rtol) File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site- packages/numpy/core/numeric.py", line 2524, in within_tol result = less_equal(abs(x-y), atol + rtol * abs(y)) File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site- packages/yt/units/yt_array.py", line 912, in __radd__ lo = sanitize_units_add(self, left_object, "addition") File "/cm/shared/apps/anaconda2/4.3.1/lib/python2.7/site- packages/yt/units/yt_array.py", line 163, in sanitize_units_add raise YTUnitOperationError(op_string, inp.units, dimensionless) yt.utilities.exceptions.YTUnitOperationError: The addition operator for YTArrays with units (km) and (1) is not well defined.
On Tue, Jan 30, 2018 at 10:57 AM,
------------------------------
Subject: Digest Footer
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
------------------------------
End of yt-users Digest, Vol 120, Issue 1 ****************************************
-- *SK2* *"**Claiming that something can move faster than light is a good conversation-stopper in physics. People edge away from you in cocktail parties; friends never return phone calls. You just don’t mess with Albert Einstein.**"*
On Tue, Feb 6, 2018 at 10:02 AM, Sushilkumar
Dear Nathan:
Thanks that worked. Also could you let me know the difference between the normal vector and north vector in offaxissliceplot. I had done it earlier but seemed to have forgotten.
What choice of normal vector and north vector do I use if I want for example an xz plot inclined at 60 degrees?
The normal vector is normal to the slice plane. That leaves the rotation of the slice image as a free parameter. The north vector determines the rotation. For an xz plot, the normal vector is [0, 1, 0]. By default the north vector in that case is [0, 0, 1]. If you want to rotate the plot by 60 degrees, you need to rotate the north_vector by 60 degrees, giving [sqrt(3)/2, 0, 1/2] or [-sqrt(3)/2, 0, 1/2] depending on which way you want to rotate. Hope that helps, Nathan
participants (2)
-
Nathan Goldbaum
-
Sushilkumar