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/475#issuecomment-121790688,https://api.github.com/repos/pydata/xarray/issues/475,121790688,MDEyOklzc3VlQ29tbWVudDEyMTc5MDY4OA==,4383303,2015-07-16T00:42:08Z,2015-07-16T00:42:08Z,NONE,"Unidata also has a [blog post](http://www.unidata.ucar.edu/blogs/developer/en/entry/accessing_netcdf_data_by_coordinates) benchmarking cKDTree and other methods and concludes ""Your Mileage May Vary"". I'd probably just go with a KDTree, but something to aware of. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,95114700 https://github.com/pydata/xarray/issues/475#issuecomment-121701139,https://api.github.com/repos/pydata/xarray/issues/475,121701139,MDEyOklzc3VlQ29tbWVudDEyMTcwMTEzOQ==,4383303,2015-07-15T18:15:49Z,2015-07-15T18:15:49Z,NONE,"Seems like if your method is going to be named `sel_points` then `points` is a reasonable dimension name. Maybe support a `name` kwarg? One thing to keep in mind is that for many of us the ""nearest-neighbor"" part isn't really `method='nearest'`, but instead more like, `method='ingridcell'` where the grid cell might be roughly square or might be something pretty different. At least that's how I think of my data. Maybe what I really want is some other kind of more explicit support for gridded data, although my thoughts on this are too half-baked to clearly write down. I thought there was another issue related to this, but I couldn't find it. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,95114700 https://github.com/pydata/xarray/issues/214#issuecomment-119036789,https://api.github.com/repos/pydata/xarray/issues/214,119036789,MDEyOklzc3VlQ29tbWVudDExOTAzNjc4OQ==,4383303,2015-07-07T00:51:04Z,2015-07-07T00:51:04Z,NONE,"+1 for this proposal. I made a slight modification to @WeatherGod's code so that I could use string indices for the ""station"" coordinate, though I'm sure there is a better way to implement this. Also note the addition of a few `list` calls for Python 3 compat. ``` python def grid_to_points2(grid, points, coord_names): if not coord_names: raise ValueError(""No coordinate names provided"") spat_dims = {d for n in coord_names for d in grid[n].dims} not_spatial = set(grid.dims) - spat_dims spatial_selection = {n:0 for n in not_spatial} spat_only = grid.isel(**spatial_selection) coords = bcast(spat_only, coord_names) kd = KDTree(list(zip(*[c.ravel() for c in coords]))) _, indx = kd.query(list(zip(*[points[n].values for n in coord_names]))) indx = np.unravel_index(indx, coords[0].shape) station_da = xray.DataArray(name='station', dims='station', data=stations.index.values) return xray.concat( (grid.isel(**{n:j for n, j in zip(spat_only.dims, i)}) for i in zip(*indx)), dim=station_da) In [97]: stations = pd.DataFrame({'XLAT':[32.13, 32.43], 'XLONG':[-110.95, -112.02]}, index=['KTUS', 'KPHX']) stations Out[97]: XLAT XLONG KTUS 32.13 -110.95 KPHX 32.43 -112.02 In [98]: station_ds = grid_to_points2(ds, stations, ('XLAT', 'XLONG')) station_ds Out[98]: Dimensions: (Times: 1681, station: 2) Coordinates: * Times (Times) datetime64[ns] 2015-07-02T06:00:00 ... XLAT (station) float32 32.1239 32.4337 * station (station) object 'KTUS' 'KPHX' west_east (station) int64 220 164 XLONG (station) float32 -110.947 -112.012 south_north (station) int64 116 134 Data variables: SWDNBRH (station, Times) float32 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... V10 (station, Times) float32 -2.09897 -1.94047 -1.55494 ... V80 (station, Times) float32 0.0 -1.95921 -1.87583 -1.86289 ... SWDNB (station, Times) float32 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... U10 (station, Times) float32 2.22951 1.89406 1.39955 1.04277 ... SWDDNI (station, Times) float32 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... SWDNBC (station, Times) float32 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... T2 (station, Times) float32 301.419 303.905 304.155 304.296 ... SWDDNIRH (station, Times) float32 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... U80 (station, Times) float32 0.0 1.93936 1.7901 1.63011 1.69481 ... In [100]: station_ds.sel(station='KTUS')[['U10','V10']] Out[100]: Dimensions: (Times: 1681) Coordinates: west_east int64 220 south_north int64 116 XLONG float32 -110.947 * Times (Times) datetime64[ns] 2015-07-02T06:00:00 ... station object 'KTUS' XLAT float32 32.1239 Data variables: U10 (Times) float32 2.22951 1.89406 1.39955 1.04277 1.16338 ... V10 (Times) float32 -2.09897 -1.94047 -1.55494 -1.34216 ... ``` ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,40395257 https://github.com/pydata/xarray/issues/453#issuecomment-118437972,https://api.github.com/repos/pydata/xarray/issues/453,118437972,MDEyOklzc3VlQ29tbWVudDExODQzNzk3Mg==,4383303,2015-07-03T23:40:50Z,2015-07-03T23:40:50Z,NONE,"Thanks for the tips. This may be Python 3 specific, but I needed to convert to convert to strings first ``` python times_strings = list(map(lambda x: x.decode('utf-8'), ds['Times'].values)) ds['Times'] = ('Time', pd.to_datetime(times_strings, format='%Y-%m-%d_%H:%M:%S')) ``` Is there a reason why you don't use `numeric_only=True` for the min and max functions? I was just recommending more consistency across the min/max/mean/std/etc functions. Might also be good to be explicit about that in the doc strings. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,92762200