Skip to content

hard to understand behavior of concat #5072

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

You must be logged in to vote

@DanCodigaMWRA

Why would this happen?

You want to treat Lat and Lon as coordinates during the concatenation, however with your current setup, xarray isn't aware of this fact. There are two remedies to this.

  • Specify data_vars i.e. xr.concat(...., data_vars=['v10m, 'u10m', ...])
In [13]: ds
Out[13]: 
<xarray.Dataset>
Dimensions:  (Xind: 2, Yind: 3, tZ: 3)
Coordinates:
  * Xind     (Xind) int64 0 1
  * Yind     (Yind) int64 0 1 2
  * tZ       (tZ) datetime64[ns] 2021-01-01 2021-02-01 2021-03-01
Data variables:
    Lat      (Xind, Yind) int64 0 1 2 3 4 5
    u10m     (tZ, Xind, Yind) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17


In [15]: xr.concat([ds, ds], dim='tZ', data_vars=['u10m'

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

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