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/364#issuecomment-751259037,https://api.github.com/repos/pydata/xarray/issues/364,751259037,MDEyOklzc3VlQ29tbWVudDc1MTI1OTAzNw==,26384082,2020-12-25T14:49:52Z,2020-12-25T14:49:52Z,NONE,"In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the `stale` label; otherwise it will be marked as closed automatically ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-347735817,https://api.github.com/repos/pydata/xarray/issues/364,347735817,MDEyOklzc3VlQ29tbWVudDM0NzczNTgxNw==,410907,2017-11-29T02:47:44Z,2017-11-29T02:47:44Z,NONE,"pd.TimeGrouper is deprecated in latest pandas release, so I imagine this bug should be closed.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-231021167,https://api.github.com/repos/pydata/xarray/issues/364,231021167,MDEyOklzc3VlQ29tbWVudDIzMTAyMTE2Nw==,7504461,2016-07-07T08:54:46Z,2016-07-07T08:59:15Z,NONE,"Thanks, @shoyer ! Here is an example of how I circumvented the problem: `data = np.random.rand(24*5)` `times = pd.date_range('2000-01-01', periods=24*5, freq='H')` `foo = xray.DataArray(data, coords=[times], dims=['time'])` `foo = foo.to_dataset(dim=foo.dims,name='foo')` `T = time.mktime( dt.datetime(1970,1,1,12+1,25,12).timetuple() ) # 12.42 hours` `Tint = [ int( time.mktime( t.timetuple() ) / T ) for t in foo.time.values.astype('datetime64[s]').tolist()]` `foo2 = xray.DataArray( Tint, coords=foo.time.coords, dims=foo.time.dims)` `foo.merge(foo2.to_dataset(name='Tint'), inplace=True)` `foo_grp = foo.groupby('Tint')` `foo_grp.group.plot.line()` In my case, the `dataset` is quite large then it costed a lot of computational time to merge the new variable `Tint`. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-228723336,https://api.github.com/repos/pydata/xarray/issues/364,228723336,MDEyOklzc3VlQ29tbWVudDIyODcyMzMzNg==,7504461,2016-06-27T11:45:09Z,2016-06-27T11:45:09Z,NONE,"This is a very useful functionality. I am wondering if I can specify the time window, for example, like `ds.groupby(time=pd.TimeGrouper('12.42H'))`. Is there a way to do that in `xarray`? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-78239807,https://api.github.com/repos/pydata/xarray/issues/364,78239807,MDEyOklzc3VlQ29tbWVudDc4MjM5ODA3,167164,2015-03-11T10:38:05Z,2015-03-11T10:38:05Z,NONE,"Ah, yep, making the dimension using `data.coords['timeofday'] = ('time', [np.timedelta64(60 * int(h) + int(m), 'm') for h,m in zip(data['time.hour'], data['time.minute'])])` works. Thanks for all the help :) ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-78211171,https://api.github.com/repos/pydata/xarray/issues/364,78211171,MDEyOklzc3VlQ29tbWVudDc4MjExMTcx,167164,2015-03-11T06:17:10Z,2015-03-11T06:17:10Z,NONE,"Ok, weird. That example works for me, but even if I take a really short slice of my data set, the same thing won't work: ``` In [61]: d = data.sel(time=slice('2002-01-01','2002-01-03')) d Out[61]: Dimensions: (time: 143, timeofday: 70128, x: 1, y: 1, z: 1) Coordinates: * x (x) >f8 1.0 * y (y) >f8 1.0 * z (z) >f8 1.0 * time (time) datetime64[ns] 2002-01-01T00:30:00 ... * timeofday (timeofday) timedelta64[ns] 1800000000000 nanoseconds ... Data variables: SWdown (time, y, x) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 14.58 ... Rainf_qc (time, y, x) float64 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ... SWdown_qc (time, y, x) float64 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ... Tair (time, z, y, x) float64 282.9 282.9 282.7 282.6 282.4 281.7 281.0 ... Tair_qc (time, y, x) float64 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ... LWdown (time, y, x) float64 296.7 297.3 297.3 297.3 297.2 295.9 294.5 ... PSurf_qc (time, y, x) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... latitude (y, x) float64 -35.66 Wind (time, z, y, x) float64 2.2 2.188 1.9 2.2 2.5 2.5 2.5 2.25 2.0 2.35 ... LWdown_qc (time, y, x) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... Rainf (time, y, x) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... Qair_qc (time, y, x) float64 1.0 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ... longitude (y, x) float64 148.2 PSurf (time, y, x) float64 8.783e+04 8.783e+04 8.782e+04 8.781e+04 ... reference_height (y, x) float64 70.0 elevation (y, x) float64 1.2e+03 Qair (time, z, y, x) float64 0.00448 0.004608 0.004692 0.004781 ... Wind_qc (time, y, x) float64 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ... Attributes: Production_time: 2012-09-27 12:44:42 Production_source: PALS automated netcdf conversion Contact: palshelp@gmail.com PALS_fluxtower_template_version: 1.0.2 PALS_dataset_name: TumbaFluxnet PALS_dataset_version: 1.4 In [62]: d.groupby('timeofday').mean('time') ``` That last command will not complete - it will run for minutes. Not really sure how to debug that behaviour. Perhaps it's to do with the long/lat/height variables that really should be coordinates (I'm just using the data as it came, but I can clean that, if necessary) ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-78191526,https://api.github.com/repos/pydata/xarray/issues/364,78191526,MDEyOklzc3VlQ29tbWVudDc4MTkxNTI2,167164,2015-03-11T03:00:03Z,2015-03-11T03:00:03Z,NONE,"same problem with `numpy.timedelta64` too. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-78036587,https://api.github.com/repos/pydata/xarray/issues/364,78036587,MDEyOklzc3VlQ29tbWVudDc4MDM2NTg3,167164,2015-03-10T11:30:10Z,2015-03-10T11:30:10Z,NONE,"Dunno if this is related to the `ds['time.time']` problem, but I tried creating the daily_cycle using a `pandas.Timedelta` as the index (`timeofday`), but it also appeared to just hang indefinitely when doing the `data.groupby('timeofday').mean('time')` call.. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-78008962,https://api.github.com/repos/pydata/xarray/issues/364,78008962,MDEyOklzc3VlQ29tbWVudDc4MDA4OTYy,167164,2015-03-10T07:51:45Z,2015-03-10T07:51:45Z,NONE,"Nice. Ok, I have hit a stumbling block, and this is much more of a support request, so feel free to direct me else where, but since we're on the topic, I want to do something like: ``` start = 2002 n_years = 4 new_data = [] for year in range(start, start + n_years): days = 365 if year%4 else 365 for d in range(days): day_data = mean + annual_cycle.isel(dayofyear=d) + daily_cycle day_data.coords['time'] = datetime.datetime(year,1,1) + datetime.timedelta(day=d, hour=day_data.timeofday.hour, minute=day_data.timeofday.minute) new_data.append(day_data) xray.concat(new_data) ``` where `mean`, `annual_cycle`, and `daily_cycle` are overall mean, annual cycle at daily resolution, and daily cycle at 30 minute resolution (the latter two bias corrected by subtracting the mean). I'm trying to make a synthetic dataset 4 years long that only includes the mean, seasonal, and daily cycles, but no other variability. The assignment of `day_data['time']` fails because the `day_data.timeofday.hour` (and `.minute`) don't work. These are `datetime.time`s, is there an efficient way of converting these to `datetime.timedelta`s, without first manually taking them out of the DataArray? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-77978458,https://api.github.com/repos/pydata/xarray/issues/364,77978458,MDEyOklzc3VlQ29tbWVudDc3OTc4NDU4,167164,2015-03-10T01:16:25Z,2015-03-10T01:16:25Z,NONE,"Ah, cool, thanks for that link, I missed that in the docs. One thing that would be nice (in both pandas and xray) is a `time.timeofday`. I can't figure out how to do it with `time.hour` and `time.minute` - I need half-hourly resolution averaging. `time.time` does something in xray, but it seems to never complete, and it doesn't work at all in pandas. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-77824657,https://api.github.com/repos/pydata/xarray/issues/364,77824657,MDEyOklzc3VlQ29tbWVudDc3ODI0NjU3,167164,2015-03-09T09:46:15Z,2015-03-09T09:46:15Z,NONE,"Heh, I meant the pandas docs - they don't specify the `rule` argument format either `time.month` and `time.hour` do exactly what I need. They aren't mentioned in the docs at http://xray.readthedocs.org/en/stable/groupby.html, and I'm not sure how I'd guess that they exist, so perhaps they should be added to that page? It doesn't appear to be something that exists in pandas.. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-77810787,https://api.github.com/repos/pydata/xarray/issues/364,77810787,MDEyOklzc3VlQ29tbWVudDc3ODEwNzg3,167164,2015-03-09T07:34:49Z,2015-03-09T07:34:49Z,NONE,"Unfortunately I'm not familiar enough with pd.resample and pd.TeimGrouper to know the difference in what they can do. `resample` looks like it would cover my use-cases, although the docs are pretty limited, and don't actually specify the format of the `rule` format... One thing that I would like to be able to do that is not covered by resample, and _might_ be covered by TimeGrouper is to group over month only (not month and year), in order to create a plot of mean seasonal cycle (at monthly resolution), or similarly, a daily cycle at hourly resolution. I haven't figured out if I can do that with TimeGrouper yet though. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760 https://github.com/pydata/xarray/issues/364#issuecomment-77807590,https://api.github.com/repos/pydata/xarray/issues/364,77807590,MDEyOklzc3VlQ29tbWVudDc3ODA3NTkw,167164,2015-03-09T06:49:55Z,2015-03-09T06:49:55Z,NONE,"Looks good to me. I don't know enough to be able to comment on the API question. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,60303760