home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 58553935

This data as json

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/214#issuecomment-58553935 https://api.github.com/repos/pydata/xarray/issues/214 58553935 MDEyOklzc3VlQ29tbWVudDU4NTUzOTM1 291576 2014-10-09T18:21:16Z 2014-10-09T18:21:16Z CONTRIBUTOR

And, actually, the example I gave above has a bug in the dependent dimension case. This one should be much better (not fully tested yet, though):

``` def grid_to_points2(grid, points, coord_names): if not coord_names: raise ValueError("No coordinate names provided") not_spatial = set(grid.dims) - set(coord_names) spatial_selection = {n:0 for n in not_spatial} spat_only = grid.isel(*spatial_selection) coords = [] for i, n in enumerate(spat_only.dims): if spat_only[n].ndim != len(spat_only.dims): # Needs new axes slices = [np.newaxis] * len(spat_only.dims) slices[i] = slice(None) else: slices = [slice(None)] * len(spat_only.dims) coords.append(spat_only[n].values[slices]) coords = np.broadcast_arrays(coords)

kd = KDTree(zip(*[c.flatten() for c in coords]))
_, indx = kd.query(zip(*[points[n].values for n in spat_only.dims]))
indx = np.unravel_index(indx, coords[0].shape)

return xray.concat(
        (grid.sel(**{n:c[i] for n, c in zip(spat_only.dims, coords)})
         for i in zip(*indx)),
        dim='station')

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  40395257
Powered by Datasette · Queries took 3.685ms · About: xarray-datasette