Last active
July 25, 2019 01:55
-
-
Save ccarouge/88406146883fab7bb9569acb3d7e3ce6 to your computer and use it in GitHub Desktop.
Correlation and p-value between 2 arrays of 3 dimensions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added
sample = sample.where(np.isfinite(sample),drop=True)
. But it's not doing the trick as the NaN's do not occur at the same time steps in each file.For example:
x1 = np.asarray([ 5., np.nan, 5., 5., 4., np.nan, 6., 8., 1., 7.,np.nan])
x2 = np.asarray([ 5., 3., 5., np.nan, 5., 4., 6., 8., 1., np.nan, 7.])
y1 = xr.DataArray(x1,dims='c',coords={'c':np.arange(0,11)})
y2 = xr.DataArray(x2,dims='c',coords={'c':np.arange(0,11)})
yy = xr.concat([y1,y2],pd.Index(['a','b'],name='n'))
yy.where(np.isfinite(yy),drop=True)
As a result, NaNs are still contained:
<xarray.DataArray (n: 2, c: 11)>
array([[ 5., nan, 5., 5., 4., nan, 6., 8., 1., 7., nan],
[ 5., 3., 5., nan, 5., 4., 6., 8., 1., nan, 7.]])
Coordinates:
* c (c) int64 0 1 2 3 4 5 6 7 8 9 10
* n (n) object 'a' 'b'