Ashwin,
Glad you were able to figure it out. Happy plotting!
Ryan
On Fri, Oct 14, 2016 at 5:45 AM, ashwinD12 . <winash12@xxxxxxxxx> wrote:
> Ryan,
> I was able to fix and I am able to see a wonderful plot using
> matplotlib and cartopy ! I had a older version of cartopy and when I
> upgraded to the latest version all errors were resolved and a beautiful
> plot was generated.
>
> Best,
> Ashwin.
>
> On Fri, Oct 14, 2016 at 1:16 PM, ashwinD12 . <winash12@xxxxxxxxx> wrote:
>
>> Ryan,
>> I was able to fix those errors. Essentially I forgot to add
>> these three lines of errors and the problem goes away. But another problem
>> arises with Tkinter errors and the matplotlib interaction.
>>
>> temp = temp[:].squeeze()
>> u_wind = u_wind[:].squeeze() * units('m/s')
>> v_wind = v_wind[:].squeeze() * units('m/s')
>>
>> I am not sure but maybe the code needs to include matplotlib.use('TkAgg').
>> It doesn't solve the lack of display though.
>>
>> I get a blank window which when I close the long trace below arises.
>>
>> The dependencies are quite involved. In order for this code to run you need
>> to install apart from cartopy the other two Python
>>
>> packages - Shapely and pyshp.
>>
>>
>>
>>
>> File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py",
>> line 474, in draw
>> self.figure.draw(self.renderer)File
>> "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 61, in
>> draw_wrapper
>> draw(artist, renderer, *args, **kwargs)File
>> "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1159, in draw
>> func(*args)
>> File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 61, in
>> draw_wrapper
>> draw(artist, renderer, *args, **kwargs)
>> File "/usr/local/lib/python3.5/dist-packages/cartopy/mpl/geoaxes.py", line
>> 355, in draw
>> inframe=inframe)File "/usr/lib/python3/dist-packages/matplotlib/artist.py",
>> line 61, in draw_wrapper
>> draw(artist, renderer, *args, **kwargs)File
>> "/usr/lib/python3/dist-packages/matplotlib/axes/_base.py", line 2324, in draw
>> a.draw(renderer)File "/usr/lib/python3/dist-packages/matplotlib/artist.py",
>> line 61, in draw_wrapper
>> draw(artist, renderer, *args, **kwargs)
>> File
>> "/usr/local/lib/python3.5/dist-packages/cartopy/mpl/feature_artist.py", line
>> 103, in draw
>> geoms = self._feature.intersecting_geometries(extent)File
>> "/usr/local/lib/python3.5/dist-packages/cartopy/feature.py", line 113, in
>> intersecting_geometriesreturn (geom for geom in self.geometries() if
>> File "/usr/local/lib/python3.5/dist-packages/cartopy/feature.py", line 180,
>> in geometries
>> name=self.name)
>> File "/usr/local/lib/python3.5/dist-packages/cartopy/io/shapereader.py",
>> line 246, in natural_earthreturn ne_downloader.path(format_dict)File
>> "/usr/local/lib/python3.5/dist-packages/cartopy/io/__init__.py", line 223,
>> in path
>> result_path = self.acquire_resource(target_path, format_dict)File
>> "/usr/local/lib/python3.5/dist-packages/cartopy/io/shapereader.py", line
>> 301, in acquire_resource
>> shapefile_online = self._urlopen(url)File
>> "/usr/local/lib/python3.5/dist-packages/cartopy/io/__init__.py", line 262,
>> in _urlopenreturn urlopen(url)File "/usr/lib/python3.5/urllib/request.py",
>> line 163, in urlopenreturn opener.open(url, data, timeout)File
>> "/usr/lib/python3.5/urllib/request.py", line 472, in open
>> response = meth(req, response)File "/usr/lib/python3.5/urllib/request.py",
>> line 582, in http_response'http', request, response, code, msg, hdrs)File
>> "/usr/lib/python3.5/urllib/request.py", line 504, in error
>> result = self._call_chain(*args)File "/usr/lib/python3.5/urllib/request.py",
>> line 444, in _call_chain
>> result = func(*args)File "/usr/lib/python3.5/urllib/request.py", line 696,
>> in http_error_302return self.parent.open(new, timeout=req.timeout)File
>> "/usr/lib/python3.5/urllib/request.py", line 472, in open
>> response = meth(req, response)
>> File "/usr/lib/python3.5/urllib/request.py", line 582, in
>> http_response'http', request, response, code, msg, hdrs)
>> File "/usr/lib/python3.5/urllib/request.py", line 510, in errorreturn
>> self._call_chain(*args)File "/usr/lib/python3.5/urllib/request.py", line
>> 444, in _call_chain
>> result = func(*args)
>> File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
>> raise HTTPError(req.full_url, code, msg, hdrs, fp)
>> urllib.error.HTTPError: HTTP Error 404: Not FoundTraceback (most recent
>> call last):
>> File "tempAdv.py", line 72, in <module>
>> plt.show()
>> File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 244, in
>> showreturn _show(*args, **kw)
>> File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line
>> 192, in __call__
>> self.mainloop()
>>
>>
>> File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py",
>> line 74, in mainloop
>>
>> Tk.mainloop()
>>
>> File "/usr/lib/python3.5/tkinter/__init__.py", line 408, in mainloop
>> _default_root.tk.mainloop(n)
>>
>> AttributeError: 'NoneType' object has no attribute 'tk
>>
>>
>>
>>
>>
>> On Fri, Oct 14, 2016 at 7:39 AM, ashwinD12 . <winash12@xxxxxxxxx> wrote:
>>
>>> Ryan,
>>> Those files are just reanalysis 2 data files that are
>>> downloaded from NCEP NCAR. The shape of the three data sets is identical
>>>
>>> (1,1,73,144). If you wish I can send you those files offline.
>>> Regards,
>>> Ashwin.
>>>
>>> On Fri, Oct 14, 2016 at 3:47 AM, Ryan May <rmay@xxxxxxxx> wrote:
>>>
>>>> Ashwin,
>>>>
>>>> I'm responsible chiefly for MetPy so that's fine. For future reference,
>>>> though, I prefer public channels in general, either Unidata's python-users
>>>> email list or issues over at http://github.com/metpy/MetPy/issues so
>>>> that the rest of the community can chime in with answers or benefit from
>>>> the information. I'm cc'ing the python-users list so we can take the
>>>> conversation there.
>>>>
>>>> That error message implies that something is off with the size of one
>>>> of your arrays. What are the sizes of temp, u_wind, and v_wind?
>>>>
>>>> Ryan
>>>>
>>>>
>>>>
>>>> On Thu, Oct 13, 2016 at 9:53 AM, ashwinD12 . <winash12@xxxxxxxxx>
>>>> wrote:
>>>>
>>>>> Hello Ryan,
>>>>> I am not sure if I should be contacting you
>>>>> regarding MetPy errors. But I ran a slightly modified example of this
>>>>> cookbook -http://nbviewer.jupyter.org/github/unidata/notebook-gallery
>>>>> /blob/master/notebooks/850mb_Temperature_Advection.ipynb and I am
>>>>> getting this runtime error -
>>>>> Any idea what that means ?
>>>>> Traceback (most recent call last):
>>>>> File "tempAdv.py", line 38, in <module>
>>>>> adv = advection(temp * units.kelvin, [u_wind,
>>>>> v_wind],(42583.44283066879 * units.meter, 55588.7366760194 * units.meter))
>>>>> * units('degF/sec')
>>>>> File
>>>>> "/usr/local/lib/python3.5/dist-packages/MetPy-0.3.1-py3.5.egg/metpy/calc/kinematics.py",
>>>>> line 166, in advection
>>>>> grad = _stack(_gradient(scalar, *deltas))
>>>>> File
>>>>> "/usr/local/lib/python3.5/dist-packages/MetPy-0.3.1-py3.5.egg/metpy/calc/kinematics.py",
>>>>> line 18, in _gradient
>>>>> grad = np.gradient(f, *args, **kwargs)
>>>>> File "/usr/lib/python3/dist-packages/numpy/lib/function_base.py",
>>>>> line 1440, in gradient
>>>>> "Shape of array too small to calculate a numerical gradient, "
>>>>> ValueError: Shape of array too small to calculate a numerical
>>>>> gradient, at least two elements are required.
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Ryan May, Ph.D.
>>>> Software Engineer
>>>> UCAR/Unidata
>>>> Boulder, CO
>>>>
>>>
>>>
>>
>
--
Ryan May, Ph.D.
Software Engineer
UCAR/Unidata
Boulder, CO