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

Add subsetting option to data access methods #407

Merged
merged 3 commits into from
Jul 4, 2024

Conversation

sandorkertesz
Copy link
Collaborator

@sandorkertesz sandorkertesz commented Jun 18, 2024

Fixes #406

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

  • to_numpy()
  • to_array()
  • data()
  • to_latlon()
  • to_points()

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
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@             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              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sandorkertesz
Copy link
Collaborator Author

@iainrussell, if it is fine with you I merge and close this PR

Copy link
Member

@iainrussell iainrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@sandorkertesz sandorkertesz merged commit 045d5d7 into develop Jul 4, 2024
88 checks passed
@sandorkertesz sandorkertesz deleted the feature/subset-to-numpy branch July 4, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to subset field values in to_numpy() method
3 participants