home / github

Menu
  • Search all tables
  • GraphQL API

issues

Table actions
  • GraphQL API for issues

2 rows where state = "open", type = "issue" and user = 5659125 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

type 1

  • issue · 2 ✖

state 1

  • open · 2 ✖

repo 1

  • xarray 2
id node_id number title user state locked assignee milestone comments created_at updated_at ▲ closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1498255931 I_kwDOAMm_X85ZTZI7 7381 Document cftime arithmetic limitations larsbuntemeyer 5659125 open 0     3 2022-12-15T11:24:04Z 2023-07-17T09:34:12Z   NONE      

What is your issue?

Hey all, i have quick use case where i am unsure if that's related to xarray. I just want to do simple arithmetics with a cftime time axis, e.g.

python import xarray as xr import numpy as np time = xr.DataArray(xr.cftime_range(start="2000", periods=6, freq="1MS", calendar="noleap"), dims='time') and then, e.g., compute mid of those timesteps: python time[:-1] + 0.5 * time.diff('time') which results in ```


UFuncTypeError Traceback (most recent call last) Input In [72], in <cell line: 1>() ----> 1 time[1:] + 0.5 * time.diff('time')

File /work/ch0636/g300046/conda_envs/pyremo-dev/lib/python3.9/site-packages/xarray/core/_typed_ops.py:206, in DataArrayOpsMixin.add(self, other) 205 def add(self, other): --> 206 return self._binary_op(other, operator.add)

File /work/ch0636/g300046/conda_envs/pyremo-dev/lib/python3.9/site-packages/xarray/core/dataarray.py:3530, in DataArray._binary_op(self, other, f, reflexive) 3526 other_variable = getattr(other, "variable", other) 3527 other_coords = getattr(other, "coords", None) 3529 variable = ( -> 3530 f(self.variable, other_variable) 3531 if not reflexive 3532 else f(other_variable, self.variable) 3533 ) 3534 coords, indexes = self.coords._merge_raw(other_coords, reflexive) 3535 name = self._result_name(other)

File /work/ch0636/g300046/conda_envs/pyremo-dev/lib/python3.9/site-packages/xarray/core/_typed_ops.py:396, in VariableOpsMixin.add(self, other) 395 def add(self, other): --> 396 return self._binary_op(other, operator.add)

File /work/ch0636/g300046/conda_envs/pyremo-dev/lib/python3.9/site-packages/xarray/core/variable.py:2519, in Variable._binary_op(self, other, f, reflexive) 2516 attrs = self._attrs if keep_attrs else None 2517 with np.errstate(all="ignore"): 2518 new_data = ( -> 2519 f(self_data, other_data) if not reflexive else f(other_data, self_data) 2520 ) 2521 result = Variable(dims, new_data, attrs=attrs) 2522 return result

UFuncTypeError: ufunc 'add' cannot use operands with types dtype('O') and dtype('<m8[ns]') The problem is the differentiation results in `np.timedelta64` objects:python time.diff('time') ![grafik](https://user-images.githubusercontent.com/5659125/207844626-76adf571-92f7-4645-9e9d-5ba01d08afa3.png) with which the arithmetics are not implemented in `cftime`. However, differentiation with `datetime.timdelta` (which is wrapped by `np.timedelta64`) works in this case since it's implemented in cftime, e.g., when i do `np.diff`, it works:python time[:-1] + 0.5 * np.diff(time) ```

i get the expected result. I am not sure what to expect from xarray and if this might be an issue of cftime (e.g., implement differentiation with np.timedelta64). I was wondering why the differentiation with cftime objects results in np.timedelta64 and not datetime.timedelta objects (like in the pure numpy differentation).

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7381/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 issue
1507705136 I_kwDOAMm_X85Z3cEw 7398 convert_calendar adds time coordinate to static variables larsbuntemeyer 5659125 open 0     1 2022-12-22T11:27:11Z 2023-01-15T15:51:21Z   NONE      

What is your issue?

I just recognized that convert_calendar adds a time coordinate to variables that have been static before, e.g.,

```python import numpy as np import pandas as pd import xarray as xr

np.random.seed(0) temperature = 15 + 8 * np.random.randn(2, 2, 3) precipitation = 10 * np.random.rand(2, 2, 3) orog = 0 + 100 * np.random.randn(2, 2) lon = [[-99.83, -99.32], [-99.79, -99.23]] lat = [[42.25, 42.21], [42.63, 42.59]] time = pd.date_range("2014-09-06", periods=3) reference_time = pd.Timestamp("2014-09-05")

ds = xr.Dataset( data_vars=dict( temperature=(["x", "y", "time"], temperature), precipitation=(["x", "y", "time"], precipitation), orog = (["x", "y"], orog) ), coords=dict( lon=(["x", "y"], lon), lat=(["x", "y"], lat), time=time, reference_time=reference_time, ), attrs=dict(description="Weather related data."), ) ds ![grafik](https://user-images.githubusercontent.com/5659125/209124247-4d6bb64f-8396-4a90-bcce-c420b022b0cf.png) I would like to convert the time axis to cftime objects usingpython ds.convert_calendar(ds.time.dt.calendar, use_cftime=True) ds `` ![grafik](https://user-images.githubusercontent.com/5659125/209124475-2ca60508-2d39-432b-816d-0f2718cda5b4.png) However, this results in an unexpected time coordinate in theorog` variable...

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7398/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 issue

Advanced export

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

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 22.425ms · About: xarray-datasette