Skip to content

Multiplying data arrays of same dimensions fails #7915

Answered by andersy005
e5k asked this question in Q&A
Discussion options

You must be logged in to vote

@e5k,

a minor discrepancy in the coordinate values might exist, even though the dimensions and the coordinate labels are the same for both DataArray objects. this might happen due to a slight difference in the floating point precision for the latitude or longitude values in data1 and data2. you might want to inspect the coordinate values of both arrays and see if there is any such discrepancy.

import xarray as xr 

xr.testing.assert_equal(data1.lon, data2.lon)
xr.testing.assert_equal(data1.lat, data2.lat)

or

xr.testing.assert_allclose(data1.lon, data2.lon)
xr.testing.assert_allclose(data1.lat, data2.lat)

The only way I found to achieve this multiplication was to get the underlying np data:

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by andersy005
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
4 participants
Converted from issue

This discussion was converted from issue #7896 on June 12, 2023 23:52.