home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 605525025

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/3656#issuecomment-605525025 https://api.github.com/repos/pydata/xarray/issues/3656 605525025 MDEyOklzc3VlQ29tbWVudDYwNTUyNTAyNQ== 14808389 2020-03-28T21:58:40Z 2020-03-28T21:58:40Z MEMBER

is this still an issue, @mada0007? If it is, I tried a bit more (it is still incomplete since I don't really understand what happens, especially with the last groupby-agg) python In [7]: def get_grps(s, axis, thresh=-1, Nmin=2): ...: s = xr.DataArray(s, dims=("time", "lon", "lat", "window")) ...: m = ( ...: xr.concat( ...: [ ...: s.shift(window=-i).pipe(lambda arr: arr <= thresh) ...: for i in range(Nmin) ...: ], ...: dim="shifted", ...: ) ...: .reduce(lambda arr, axis: np.logical_and.reduce(arr, axis=axis), dim="shifted") ...: ) ...: if Nmin > 1: ...: m = ( ...: m.where(lambda arr: arr == False, np.nan) ...: .ffill(limit=Nmin - 1, dim="window") ...: .fillna(False) ...: ) ...: ...: gps = (m != m.shift(window=1)).cumsum(dim="window").where(m) ...: ...: groups = s.groupby(gps.rename("gps_groups")) ...: return xr.where( ...: gps.isnull().all(dim="window"), ...: 0, ...: 1, # use `groups` here once it has the same size as `gps` ...: ) ...: ...: spi = xr.DataArray(dims=("time", "lon", "lat"), data=np.random.randn(118, 18, 36)) ...: spi.rolling(time=59).reduce(get_grps) which mirrors your function except it does the calculation for all points in your space-time-grid at once.

Of course, once again I can't really check for errors since I don't understand what I'm computing :grin:

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