Skip to content

Easy iteration over slices of a DataArray #266

Closed

Description

@andreas-h

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)

Activity

  1. shoyer commented on Oct 24, 2014

    @shoyer
    Member

    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.

  2. added this to the milestone on Dec 19, 2014
  3. max-sixty commented on Jan 15, 2019

    @max-sixty
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions