home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where issue = 1037814301 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: reactions, created_at (date), updated_at (date)

user 5

  • zxdawn 4
  • QuLogic 1
  • jklymak 1
  • mathause 1
  • TomNicholas 1

author_association 3

  • NONE 4
  • CONTRIBUTOR 2
  • MEMBER 2

issue 1

  • Spurious lines of the pcolormesh example · 8 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
953852124 https://github.com/pydata/xarray/issues/5901#issuecomment-953852124 https://api.github.com/repos/pydata/xarray/issues/5901 IC_kwDOAMm_X8442qDc zxdawn 30388627 2021-10-28T13:35:59Z 2021-10-28T13:51:24Z NONE

@jklymak Thanks for the explanation.

To get the old behaviour you simply need to do pcolormesh(x, y, Z[:-1, :-1], shading='flat') or make x and y one larger than Z in each dimension and specify the the corners of the quadrilaterals.

Method1: Subset value

This method works for the xarray tutorial data, but not for the TROPOMI polar-orbiting satellite data.

``` %matplotlib inline

import xarray as xr import cartopy.crs as ccrs import matplotlib.pyplot as plt

plt.figure(figsize=(14,6)) ax = plt.axes(projection=ccrs.PlateCarree())

ds = xr.open_dataset('./S5P_OFFL_L2__NO2____20190810T212136_20190810T230306_09456_01_010302_20190816T233944.nc', group='PRODUCT').isel(time=0)

m = ax.pcolormesh(ds['longitude'], ds['latitude'], ds['nitrogendioxide_tropospheric_column'][:-1, :-1], # ds['nitrogendioxide_tropospheric_column'], # shading='auto', transform=ccrs.PlateCarree(), vmin=0, vmax=1e-4, cmap='Spectral_r') ```

(The TROPOMI example data is uploaded to Google Drive)

Method2: bounds

This issue still exists with bounds data: ``` %matplotlib inline import numpy as np import xarray as xr import cartopy.crs as ccrs import matplotlib.pyplot as plt

def prepare_geo(bounds_data): """Prepare lat/lon bounds for pcolormesh. lat/lon bounds are ordered in the following way:: 3----2 | | 0----1 Extend longitudes and latitudes with one element to support "pcolormesh":: (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1]) +--------+ | C[i,j] | +--------+ (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1]) """ # Create the left array left = np.vstack([bounds_data[:, :, 0], bounds_data[-1:, :, 3]]) # Create the right array right = np.vstack([bounds_data[:, -1:, 1], bounds_data[-1:, -1:, 2]]) # Stack horizontally dest = np.hstack([left, right]) # Convert to DataArray dest = xr.DataArray(dest, dims=('y_bounds', 'x_bounds'), attrs=bounds_data.attrs ) return dest

ds = xr.open_dataset('./S5P_OFFL_L2__NO2_20190810T21213620190810T230306_09456_01_010302_20190816T233944.nc', group='PRODUCT').isel(time=0) ds_geo = xr.open_dataset('./S5P_OFFL_L2NO2____20190810T212136_20190810T230306_09456_01_010302_20190816T233944.nc', group='/PRODUCT/SUPPORT_DATA/GEOLOCATIONS').isel(time=0)

lon_bounds = prepare_geo(ds_geo['longitude_bounds']) lat_bounds = prepare_geo(ds_geo['latitude_bounds'])

plt.figure(figsize=(14,6)) ax = plt.axes(projection=ccrs.PlateCarree())

m = ax.pcolormesh(lon_bounds, lat_bounds, ds['nitrogendioxide_tropospheric_column'], # shading='auto', transform=ccrs.PlateCarree(), vmin=0, vmax=1e-4, cmap='Spectral_r') ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Spurious lines of the pcolormesh example 1037814301
953641308 https://github.com/pydata/xarray/issues/5901#issuecomment-953641308 https://api.github.com/repos/pydata/xarray/issues/5901 IC_kwDOAMm_X84412lc jklymak 1562854 2021-10-28T08:48:55Z 2021-10-28T08:48:55Z CONTRIBUTOR

Just to explain the issue a bit: pcolormesh(x, y, Z, shading='flat') was the default. If shape(Z) used to be (len(y), len(x)) matplotlib would drop, without warning, the last row and column of Z so that y and x were one larger than Z.

The new default is 'auto' where in the case above it uses shading='nearest' to create new x and y co-ordinates with the dumbest algorithm possible of placing them in the midpoints, and adding two new points on the outside. So rather than drop data from Z, we add to the x and y co-ordinates.

That is usually fine, except the midpoint between 0 and 360 is 180, and we get a weird wrap. Cartopy (xarray) accounted for this with the old shading by adding a NaN. I've not followed what they are doing now.

To get the old behaviour you simply need to do pcolormesh(x, y, Z[:-1, :-1], shading='flat') or make x and y one larger than Z in each dimension and specify the the corners of the quadrilaterals.

Sorry this is a pain, but the old behaviour of silently dropping data, while having a long lineage going back to Matlab, was deemed unacceptable. However, if this continues to be a nuisance to folks, I'm sure matplotlib would consider a new shading argument, something like 'flat-drop', or somesuch that would do the data dropping for you.

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Spurious lines of the pcolormesh example 1037814301
953609410 https://github.com/pydata/xarray/issues/5901#issuecomment-953609410 https://api.github.com/repos/pydata/xarray/issues/5901 IC_kwDOAMm_X8441uzC mathause 10194086 2021-10-28T08:17:08Z 2021-10-28T08:17:08Z MEMBER

Thanks for the report. This is related to #4364 https://github.com/SciTools/cartopy/issues/1638 and https://github.com/matplotlib/matplotlib/issues/18317.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Spurious lines of the pcolormesh example 1037814301
953350140 https://github.com/pydata/xarray/issues/5901#issuecomment-953350140 https://api.github.com/repos/pydata/xarray/issues/5901 IC_kwDOAMm_X8440vf8 zxdawn 30388627 2021-10-27T22:13:44Z 2021-10-27T22:13:44Z NONE

@QuLogic Ha, it looks well with the latest cartopy (0.20.1). Thanks a lot.

@TomNicholas So, is it better to keep this open until the doc is updated?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Spurious lines of the pcolormesh example 1037814301
953335057 https://github.com/pydata/xarray/issues/5901#issuecomment-953335057 https://api.github.com/repos/pydata/xarray/issues/5901 IC_kwDOAMm_X8440r0R QuLogic 302469 2021-10-27T21:45:41Z 2021-10-27T21:45:41Z CONTRIBUTOR

Have you tried with the latest Cartopy?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Spurious lines of the pcolormesh example 1037814301
953298464 https://github.com/pydata/xarray/issues/5901#issuecomment-953298464 https://api.github.com/repos/pydata/xarray/issues/5901 IC_kwDOAMm_X8440i4g zxdawn 30388627 2021-10-27T20:47:18Z 2021-10-27T21:00:46Z NONE

@TomNicholas I checked the doc and this issue begins from v0.16.1. Note that there're also small spurious lines after v0.10.9. Before v0.10.9, the figure looks fine. It's may be also related to matplotlib ... CC @jklymak and @timhoffm.

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 1,
    "rocket": 0,
    "eyes": 0
}
  Spurious lines of the pcolormesh example 1037814301
953295655 https://github.com/pydata/xarray/issues/5901#issuecomment-953295655 https://api.github.com/repos/pydata/xarray/issues/5901 IC_kwDOAMm_X8440iMn zxdawn 30388627 2021-10-27T20:42:58Z 2021-10-27T20:42:58Z NONE

BTW, the question on StackOverflow, which was raised by @gerritholl a long time ago, looks similar. I'm not sure whether this is the cartopy issue, CC @QuLogic, and @greglucas.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Spurious lines of the pcolormesh example 1037814301
953295349 https://github.com/pydata/xarray/issues/5901#issuecomment-953295349 https://api.github.com/repos/pydata/xarray/issues/5901 IC_kwDOAMm_X8440iH1 TomNicholas 35968931 2021-10-27T20:42:32Z 2021-10-27T20:42:52Z MEMBER

Thanks for flagging this @zxdawn!

:confused: We should probably work out whether this is happening because of something we did or something cartopy/matplotlib did...

When did this start? I wonder if there is an easy way to see all the previous editions of xarray's documentation - might help us quickly narrow down which version first had this issue?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Spurious lines of the pcolormesh example 1037814301

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 15.531ms · About: xarray-datasette