Skip to content

Simple numpy operations with xarray dataarray #6254

Discussion options

You must be logged in to vote

Hi @TomNicholas, thanks for your reply. Here you go!

da = xr.DataArray(np.random.rand(10,10,10),[("x", np.arange(10)),("y", np.arange(10)),("z", np.arange(10))])

dvdy = np.empty_like(da)

dvdy[:,1:-2,:] = (da[:, 2:-1,:] - da[:, 1:-2,:])

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@TomNicholas
Comment options

@gewitterblitz
Comment options

@TomNicholas
Comment options

@gewitterblitz
Comment options

Answer selected by TomNicholas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants