home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 241714748

This data as json

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
241714748 MDU6SXNzdWUyNDE3MTQ3NDg= 1474 Selecting time with different variable and dimensions names 8699967 closed 0     10 2017-07-10T13:37:31Z 2017-07-10T16:53:25Z 2017-07-10T16:25:20Z CONTRIBUTOR      

I am having trouble selecting time from this DataArray (Notice that the dimension is 'Time' and the variable/coordinate is 'Times': <xarray.DataArray 'RAINC' (Time: 16, south_north: 5, west_east: 5)> dask.array<getitem, shape=(16, 5, 5), dtype=float32, chunksize=(1, 5, 5)> Coordinates: XLAT (south_north, west_east) float32 40.3474 40.3502 40.3529 ... XLONG (south_north, west_east) float32 -111.749 -111.679 -111.608 ... Times (Time) datetime64[ns] 2016-08-23T22:00:00 2016-08-23T23:00:00 ... Dimensions without coordinates: Time, south_north, west_east Attributes: FieldType: 104 MemoryOrder: XY description: ACCUMULATED TOTAL CUMULUS PRECIPITATION units: mm stagger: coordinates: XLONG XLAT XTIME I have tried several different methods: python data = data[{self.lsm_time_dim: [pd.to_datetime(time_step)]}] python data = data[{self.lsm_time_dim: pd.to_datetime(time_step)}] python data = data[{self.lsm_time_dim: str(time_step)}] And they all end with a similar error: ``` ../gsshapy/grid/grid_to_gssha.py:634: in _load_lsm_data data = data[{self.lsm_time_dim: [pd.to_datetime(time_step)]}] ../../../tethys/miniconda/envs/gssha/lib/python3.6/site-packages/xarray/core/dataarray.py:472: in getitem return self.isel(self._item_key_to_dict(key)) ../../../tethys/miniconda/envs/gssha/lib/python3.6/site-packages/xarray/core/dataarray.py:679: in isel ds = self._to_temp_dataset().isel(drop=drop, indexers) ../../../tethys/miniconda/envs/gssha/lib/python3.6/site-packages/xarray/core/dataset.py:1143: in isel new_var = var.isel(**var_indexers) ../../../tethys/miniconda/envs/gssha/lib/python3.6/site-packages/xarray/core/variable.py:570: in isel return self[tuple(key)] ../../../tethys/miniconda/envs/gssha/lib/python3.6/site-packages/xarray/core/variable.py:400: in getitem values = self._indexable_data[key] ../../../tethys/miniconda/envs/gssha/lib/python3.6/site-packages/xarray/core/indexing.py:545: in getitem result = self.array[key]


self = DatetimeIndex(['2016-08-23 22:00:00', '2016-08-23 23:00:00', '2016-08-24 00:00:00', '2016-08-24 01:00:0...:00:00', '2016-08-24 12:00:00', '2016-08-24 13:00:00'], dtype='datetime64[ns]', freq=None) key = array([Timestamp('2016-08-23 22:00:00')], dtype=object)

def __getitem__(self, key):
    """
        This getitem defers to the underlying array, which by-definition can
        only handle list-likes, slices, and integer scalars
        """

    is_int = is_integer(key)
    if is_scalar(key) and not is_int:
        raise ValueError

    getitem = self._data.__getitem__
    if is_int:
        val = getitem(key)
        return self._box_func(val)
    else:
        if com.is_bool_indexer(key):
            key = np.asarray(key)
            if key.all():
                key = slice(0, None, None)
            else:
                key = lib.maybe_booleans_to_slice(key.view(np.uint8))

        attribs = self._get_attributes_dict()

        is_period = isinstance(self, ABCPeriodIndex)
        if is_period:
            freq = self.freq
        else:
            freq = None
            if isinstance(key, slice):
                if self.freq is not None and key.step is not None:
                    freq = key.step * self.freq
                else:
                    freq = self.freq

        attribs['freq'] = freq
      result = getitem(key)

E IndexError: arrays used as indices must be of integer (or boolean) type ```

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

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 10 rows from issue in issue_comments
Powered by Datasette · Queries took 0.868ms · About: xarray-datasette