ecmwf / earthkit-data

A format-agnostic Python interface for geospatial data
Apache License 2.0
47 stars 9 forks source link

Add subsetting option to data access methods #407

Open sandorkertesz opened 1 week ago

sandorkertesz commented 1 week ago

Fixes #406

This PR adds the index option to the following methods on a field/fieldlist:

With this the extracted values can be sliced on a per field level. E.g. if ds is a fieldlist we can write:

v = ds.to_numpy(flatten=True, index=slice(0, 3))

This is roughly equivalent to:

v = np.array([f.to_numpy(flatten=True)[:3] for f in ds])
codecov-commenter commented 6 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.06%. Comparing base (4973af9) to head (99e47cb).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #407 +/- ## =========================================== + Coverage 89.92% 90.06% +0.14% =========================================== Files 120 120 Lines 7764 7875 +111 Branches 675 675 =========================================== + Hits 6982 7093 +111 Misses 651 651 Partials 131 131 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.