我对XArray库很陌生,并且在concat / merge函数方面遇到困难。


Dimensions:        (latitude: 721, longitude: 1440)
    number         int64 0
    time           datetime64[ns] 2019-09-01
    step           timedelta64[ns] 00:00:00
    isobaricInhPa  int64 1000
  * latitude       (latitude) float64 90.0 89.75 89.5 ... -89.5 -89.75 -90.0
  * longitude      (longitude) float64 0.0 0.25 0.5 0.75 ... 359.2 359.5 359.8
    valid_time     datetime64[ns] 2019-09-01
Data variables:
    t              (latitude, longitude) float32 ...

Each describes the atmospheric temperature for a different pressure level (isobaricInhPa) and a date (time) different. I would like to merge then in one unique. For instance, I keep only the ones describing for a unique pressure level but at different dates. I collect the different Dataset matching dates and pressures from grib files and when to merge then based on their latitude, longitude, isobaricInhPa and time.

To do so, I tried to turn time and isobaricInhPa to dimensions. But, since they have only 1 value, numpy.ndarray decide it's a 0-d array. In other situations, I would use np.atleast_1d(time) or np.atleast_1d(isobaricInhPa). But in this case, the following code does not work.

ds = ds.set_index({entry: entry})


Exception has occurred: TypeError
DatetimeIndex() must be called with a collection of some kind, numpy.datetime64('2019-11-01T00:00:00.000000000') was passed