Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy iteration over slices of a DataArray #266

Closed
andreas-h opened this issue Oct 24, 2014 · 2 comments
Closed

Easy iteration over slices of a DataArray #266

andreas-h opened this issue Oct 24, 2014 · 2 comments
Milestone

Comments

@andreas-h
Copy link
Contributor

The DataArray object would benefit from functionality similar to iris.cube.Cube.slices. Given an array

 [23]: data.coords 
Out[23]: 
Coordinates:
  * sza      (sza) float64 0.0 36.87 53.13 60.0 72.54 75.52 81.37 87.13 88.28
  * vza      (vza) float64 0.0 72.54
  * raa      (raa) float64 0.0 60.0 90.0 120.0 180.0
  * wl       (wl) float64 360.0 380.0 400.0 420.0 440.0

it would be nice to be able to do

for sl in data.slices(["raa", "wl"]):
    # do magic with a DataArray of coordinates (sza, vza)
@shoyer
Copy link
Member

shoyer commented Oct 24, 2014

Right now we have the 1d version of slices with groupby, e.g.,

for _, sl in data.groupby('raa'):
    # work with DataArray with coordinates (wl, sza, vza)

(though the code does sort of implicitly assume that the values along the index are unique)

I agree, something like this would be nice. I think Iris now also has slices_over, e.g., data.slices_over(['sza', 'vza']) would be equivalent to your example, and it would be good to cover that case as well.

@shoyer shoyer added this to the before 1.0 milestone Dec 19, 2014
@max-sixty
Copy link
Collaborator

Closing as stale, please reopen if still relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants