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 option to subset field values in to_numpy() method #406

Closed
sandorkertesz opened this issue Jun 18, 2024 · 0 comments · Fixed by #407
Closed

Add option to subset field values in to_numpy() method #406

sandorkertesz opened this issue Jun 18, 2024 · 0 comments · Fixed by #407
Assignees
Labels
enhancement New feature or request

Comments

@sandorkertesz
Copy link
Collaborator

sandorkertesz commented Jun 18, 2024

Is your feature request related to a problem? Please describe.

If we have a fieldlist to_numpy() gives back a 2D numpy array containing all the field values per field. We can slice this array according to the second (per field axis) like that:

ds = from_source("file", "my.grib")
v = ds.to_numpy(flatten=True)[:, :4]

This could be done in a more memory efficient way if we performed the slicing on the field level and to_numpy() returned the already sliced 2D array. This could be done e.g. by implementing the following interface:

ds = from_source("file", "my.grib")
v = ds.to_numpy(flatten=True, index=slice(None, 4))

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Organisation

ECMWF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant