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 grid_coordinates to return 1D coordinate arrays #382

Closed
leouieda opened this issue Sep 21, 2022 · 4 comments · Fixed by #388
Closed

Add option to grid_coordinates to return 1D coordinate arrays #382

leouieda opened this issue Sep 21, 2022 · 4 comments · Fixed by #388
Labels
enhancement Idea or request for a new feature

Comments

@leouieda
Copy link
Member

Description of the desired feature:

Currently, verde.grid_coordinates always calls np.meshgrid to produce 2D coordinate arrays. However, when building xarray objects we usually have to undo. That's a bit wasteful can creates problems for very large grids. To counteract this, I propose adding a new meshgrid=True option to grid_coordinates. By default, the behaviour is unchanged. But passing meshgrid=False will return the 1D coordinate arrays instead.

Are you willing to help implement and maintain this feature?

Always but happy for someone else to do this 🙂

@leouieda leouieda added the enhancement Idea or request for a new feature label Sep 21, 2022
@leouieda leouieda changed the title Add option to grid_coordinates to disable calling meshgrid Add option to grid_coordinates to return 1D coordinate arrays Sep 21, 2022
@santisoler
Copy link
Member

I agree with this! We would need to think what to do with the extra_coords. Any thoughts?

@leouieda
Copy link
Member Author

leouieda commented Sep 24, 2022

Good point! It doesn't make sense to use extra_coords and meshgrid=False together since the whole point of extra_coords is to get a meshgrid with constant values. So maybe we just return it as is (i.e. a single value)?

@santisoler
Copy link
Member

I agree that if we want to avoid allocating large coordinate arrays it doesn't make sense to generate huge extra_coords arrays with constant values. But it doesn't make any sense either to pass a single float (or list of floats) to extra_coords and get the same ones as output. What if we just avoid the trouble by ignoring extra_coords if we pass meshgrid=False?

@leouieda
Copy link
Member Author

Sounds OK to me. Probably doesn’t matter too much which way we go since using both options together is extremely unlikely (famous last words 🥲).

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

Successfully merging a pull request may close this issue.

2 participants