home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 206028154

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
206028154 MDU6SXNzdWUyMDYwMjgxNTQ= 1253 Slice on netcdf dataset has transient lazy indexing problem 5498387 closed 0     4 2017-02-07T21:55:10Z 2017-02-07T23:17:28Z 2017-02-07T23:17:28Z NONE      

I am trying to open a netcdf dataset off an ERDDAP server, slice out a subset of times, and run further manipulations on the result. This snippet:

``` import xarray as xr

remote_ds=xr.open_dataset("http://sfbaynutrients.sfei.org/erddap/tabledap/usgs_sfb_nutrients")

Doesn't break if the slice is [10:20], [10:9000], [183039:183049]

Only get the behavior when the slice is large-ish and far from the beginning

sliced_ds=remote_ds.isel(s=slice(183039, 191509, None))

print(sliced_ds['s.Distance_from_station_36'][:10]) print(sliced_ds['s.Distance_from_station_36'][:10]) print(remote_ds['s.Distance_from_station_36'][:10]) print(xr.version.version) ```

Yields the following output: <xarray.DataArray 's.Distance_from_station_36' (s: 10)> array([ 119.080002, 119.080002, 119.080002, 119.080002, 114.93 , 114.93 , 114.93 , 114.93 , 110.07 , 110.07 ], dtype=float32) Dimensions without coordinates: s <xarray.DataArray 's.Distance_from_station_36' (s: 10)> array([ 0. , 0. , 0. , 0. , 0. , 0. , 1.66, 1.66, 1.66, 1.66], dtype=float32) Dimensions without coordinates: s <xarray.DataArray 's.Distance_from_station_36' (s: 10)> array([ 119.080002, 119.080002, 119.080002, 119.080002, 114.93 , 114.93 , 114.93 , 114.93 , 110.07 , 110.07 ], dtype=float32) Dimensions without coordinates: s 0.9.1

(I've omitted attributes for brevity - the printed attributes are identical for all 3).

The issue is that the first time I print or copy data from sliced_ds, it ignores the slice and displays the un-sliced data. The exact same print statement, a second time, gives the correct values. For reference, I've also printed the first 10 elements of the unsliced data, to show that they agree with the first, erroneous, print result. The behavior is not limited to print statements -- a deep copy sliced_ds will also show this issue.

System: linux, kubuntu. python=anaconda 3.5.1. numpy=1.10.4, xarray 0.9.1.

As a workaround, I can call sliced_ds.copy(deep=True) twice and the second time around it's okay.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1253/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
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 76.171ms · About: xarray-datasette