html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/657#issuecomment-226321246,https://api.github.com/repos/pydata/xarray/issues/657,226321246,MDEyOklzc3VlQ29tbWVudDIyNjMyMTI0Ng==,1217238,2016-06-15T21:10:38Z,2016-06-15T21:10:38Z,MEMBER,"Strange... thanks for checking again.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-226274164,https://api.github.com/repos/pydata/xarray/issues/657,226274164,MDEyOklzc3VlQ29tbWVudDIyNjI3NDE2NA==,10050469,2016-06-15T18:17:51Z,2016-06-15T18:17:51Z,MEMBER,"OK, on the current master and with a cartopy installed from conda-forge I am not able to reproduce the problem any more:
```
imshow xray: 3.30 s
pcolormesh xray: 13.13 s
pcolormesh cartopy: 12.85 s
```
I don't really understand what happened in between... The factor 4 between `imshow` and `pcolormesh` remains, but at least the show-killer 30sec plotting time I had before is gone. I'm closing this now, and this will remain a mystery.
(note: on my laptop I'm getting faster plotting results in a virtualenv configured with `pip install` than with pandas...)
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-170220499,https://api.github.com/repos/pydata/xarray/issues/657,170220499,MDEyOklzc3VlQ29tbWVudDE3MDIyMDQ5OQ==,10050469,2016-01-09T10:06:44Z,2016-01-09T10:06:44Z,MEMBER,"I had little time to spend on this lately but I'll try to get back to it in the next days. Any idea on where it could come from? I found it quite hard to debug because of the many decorators... From the profiling and the number of function calls above there seems to be something quite big happening in between xray and cartopy. Could it be something as trivial as a double function call or something?
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157828150,https://api.github.com/repos/pydata/xarray/issues/657,157828150,MDEyOklzc3VlQ29tbWVudDE1NzgyODE1MA==,10050469,2015-11-18T19:19:32Z,2015-11-18T19:19:32Z,MEMBER,"See the number of calls:
faster.txt:
4099953 function calls (4093947 primitive calls) in 14.571 seconds
slower.txt:
10316809 function calls (10303964 primitive calls) in 34.330 seconds
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157814683,https://api.github.com/repos/pydata/xarray/issues/657,157814683,MDEyOklzc3VlQ29tbWVudDE1NzgxNDY4Mw==,1217238,2015-11-18T18:39:45Z,2015-11-18T18:39:45Z,MEMBER,"Profiling for each version of pcolormesh: https://gist.github.com/shoyer/73e3841827fe1eb08d00
Switching a masked array doesn't seem to make the non-xray version any slower...
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157779612,https://api.github.com/repos/pydata/xarray/issues/657,157779612,MDEyOklzc3VlQ29tbWVudDE1Nzc3OTYxMg==,10050469,2015-11-18T17:04:21Z,2015-11-18T17:04:21Z,MEMBER,"Changing the input to `np.ma.asarray(l1 + l2)` did not change anything as far as I can see...
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157776055,https://api.github.com/repos/pydata/xarray/issues/657,157776055,MDEyOklzc3VlQ29tbWVudDE1Nzc3NjA1NQ==,2443309,2015-11-18T16:51:31Z,2015-11-18T16:51:31Z,MEMBER,"I can't verify right now but it may have something to do with using masked arrays under the hood. There are no nan's in your example but xray still is converting the array to a masked_array before plotting. I bet plotting with pcolormesh is slower with masked arrays than with numpy arrays.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157774815,https://api.github.com/repos/pydata/xarray/issues/657,157774815,MDEyOklzc3VlQ29tbWVudDE1Nzc3NDgxNQ==,1217238,2015-11-18T16:48:06Z,2015-11-18T16:48:06Z,MEMBER,"Yes, I'm seeing the same thing. Very weird -- I'll see if I can profile it.
On Wed, Nov 18, 2015 at 8:28 AM, Fabien Maussion notifications@github.com
wrote:
> ## Was someone able to reproduce this or is it just me?
>
> Reply to this email directly or view it on GitHub:
> https://github.com/xray/xray/issues/657#issuecomment-157768356
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157768356,https://api.github.com/repos/pydata/xarray/issues/657,157768356,MDEyOklzc3VlQ29tbWVudDE1Nzc2ODM1Ng==,10050469,2015-11-18T16:28:28Z,2015-11-18T16:28:28Z,MEMBER,"Was someone able to reproduce this or is it just me?
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157757864,https://api.github.com/repos/pydata/xarray/issues/657,157757864,MDEyOklzc3VlQ29tbWVudDE1Nzc1Nzg2NA==,5356122,2015-11-18T15:56:10Z,2015-11-18T15:56:10Z,MEMBER,"This is surprising! But good to know.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157642290,https://api.github.com/repos/pydata/xarray/issues/657,157642290,MDEyOklzc3VlQ29tbWVudDE1NzY0MjI5MA==,10050469,2015-11-18T08:24:23Z,2015-11-18T08:24:45Z,MEMBER,"Thanks @pelson ! So now this is when it becomes funny: I've been able to make three similar plots using xray's imshow, pcolormesh and cartopy's pcolormesh. Xray's pcolormesh takes twice the time as cartopy's:
``` python
import matplotlib.pyplot as plt
from matplotlib.colors import Normalize
import xray
import numpy as np
import cartopy.crs as ccrs
import time
nlats, nlons = (241, 480)
lats = np.linspace(90, -90, nlats)
lons = np.linspace(0, 360-0.75, nlons)
l1, l2 = np.meshgrid(lons, lats)
data = xray.DataArray(l1 + l2, [('latitude', lats), ('longitude', lons)])
cmap = plt.get_cmap('viridis')
norm = Normalize(vmin=0, vmax=data.max().values)
start_time = time.time()
fig = plt.figure()
ax = plt.axes(projection=ccrs.Robinson())
data.plot.imshow(ax=ax, transform=ccrs.PlateCarree(), add_colorbar=False, cmap=cmap, vmin=0)
ax.coastlines()
plt.savefig('imshow_xray.png')
print(""imshow xray: {:.2f} s"".format(time.time() - start_time))
start_time = time.time()
fig = plt.figure()
ax = plt.axes(projection=ccrs.Robinson())
data.plot.pcolormesh(ax=ax, transform=ccrs.PlateCarree(), add_colorbar=False, cmap=cmap, vmin=0)
ax.coastlines()
plt.savefig('pcolormesh_xray.png')
print(""pcolormesh xray: {:.2f} s"".format(time.time() - start_time))
start_time = time.time()
fig = plt.figure()
ax = plt.axes(projection=ccrs.Robinson())
ax.pcolormesh(lons, lats, l1 + l2, transform=ccrs.PlateCarree(), cmap=cmap, norm=norm)
ax.coastlines()
plt.savefig('pcolormesh_cartopy.png')
print(""pcolormesh cartopy: {:.2f} s"".format(time.time() - start_time))
```
imshow xray: 3.06 s
pcolormesh xray: 27.50 s
pcolormesh cartopy: 12.14 s
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-157413923,https://api.github.com/repos/pydata/xarray/issues/657,157413923,MDEyOklzc3VlQ29tbWVudDE1NzQxMzkyMw==,10050469,2015-11-17T16:02:10Z,2015-11-17T16:02:10Z,MEMBER,"Hi again,
I've made a self-contained example below. I have no clue about how cartopy works (blind xray user, sorry :-() and was not able to remove the dependency to xray without getting different plots for imshow() and pcolormesh()... If one of the xray gurus could help me to remove the xray part of the code I could open an issue in cartopy. I wonder if the problem comes from the fact that ERA-Interim lons are spanning 0-360?
``` python
import matplotlib.pyplot as plt
import xray
import numpy as np
import cartopy.crs as ccrs
import time
nlats, nlons = (241, 480)
lats = np.linspace(90, -90, nlats)
lons = np.linspace(0, 360-0.75, nlons)
l1, l2 = np.meshgrid(lons, lats)
data = xray.DataArray(l1 + l2, [('latitude', lats), ('longitude', lons)])
start_time = time.time()
fig = plt.figure()
ax = plt.axes(projection=ccrs.Robinson())
data.plot.imshow(ax=ax, transform=ccrs.PlateCarree())
ax.coastlines()
plt.savefig('imshow.png')
print(""imshow: {:.2f} s"".format(time.time() - start_time))
start_time = time.time()
fig = plt.figure()
ax = plt.axes(projection=ccrs.Robinson())
data.plot.pcolormesh(ax=ax, transform=ccrs.PlateCarree())
ax.coastlines()
plt.savefig('pcolormesh.png')
print(""pcolormesh: {:.2f} s"".format(time.time() - start_time))
```
imshow: 3.09 s
pcolormesh: 27.53 s
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-156991224,https://api.github.com/repos/pydata/xarray/issues/657,156991224,MDEyOklzc3VlQ29tbWVudDE1Njk5MTIyNA==,10050469,2015-11-16T10:55:09Z,2015-11-16T10:55:09Z,MEMBER,"I guess it's OK to leave it as is, as long as the performance loss is documented. I like the automatic `plot()` function because it hides the boring mpl internals to my students and (until now) always did what I expected it to do.
30 seconds to generate a plot in a Notebook is definitely a fun killer. Maybe I should still upgrade to 0.6.1 and explain to my students that they should use `imshow()` instead of `plot()`.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-156858837,https://api.github.com/repos/pydata/xarray/issues/657,156858837,MDEyOklzc3VlQ29tbWVudDE1Njg1ODgzNw==,1217238,2015-11-15T21:53:30Z,2015-11-15T21:53:30Z,MEMBER,"Yes, the difference in speed is definitely due to cartopy, which handles the projections. @pelson may be able to clarify whether imshow is always slower than pcolormesh when using cartopy, or if that is specific to particular projections.
We changed the default from imshow to pcolormesh in #608. I would not be opposed to changing the default back, given that we already product essentially equivalent plots with both methods. We did add a performance note to our (currently broken) docs: http://xray.readthedocs.org/en/latest/plotting.html#two-dimensions
@jhamman and/or @clarkfitzg may have some opinions here.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-156851221,https://api.github.com/repos/pydata/xarray/issues/657,156851221,MDEyOklzc3VlQ29tbWVudDE1Njg1MTIyMQ==,10050469,2015-11-15T20:33:24Z,2015-11-15T20:33:24Z,MEMBER,"If I remove the projection stuff `imshow` and `pcolormesh` are equally fast. Both functions must handle the projection differently, somehow?
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-156849447,https://api.github.com/repos/pydata/xarray/issues/657,156849447,MDEyOklzc3VlQ29tbWVudDE1Njg0OTQ0Nw==,10050469,2015-11-15T20:13:46Z,2015-11-15T20:13:46Z,MEMBER,"Thanks for the quick answer. changing to `imshow` indeed reduced the execution time back to normal. I wouldn't expect a factor 10 between `imshow` and `pcolormesh`, though...
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929
https://github.com/pydata/xarray/issues/657#issuecomment-156847805,https://api.github.com/repos/pydata/xarray/issues/657,156847805,MDEyOklzc3VlQ29tbWVudDE1Njg0NzgwNQ==,1217238,2015-11-15T19:59:27Z,2015-11-15T19:59:27Z,MEMBER,"We changed the default plot type from ""imshow"" in xray v0.6 to ""pcolormesh"" in xray v0.6.1. Does setting that manually make a difference? e.g., `t2_avg.plot.imshow`?
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929