'Merge / Concat seem running both very slow

I have several netCDF files which do no cover the same time periods and I have to complete each one with a bunch of data from the previous one. I stored the required data in a xarray dataset variable (DATASET1 below) I want to merge with the newly opened dataset (DATASET2 below).

I tried both:

  • ds2 = xr.merge([ds1,ds2])
  • ds2 = xr.concat([ds1,ds2], dim="time")

Both take a lot of time and I have to perform this operation multiple times.

I previously used merge a few time ago and I didn't remember this was so long. Below, you can see what my data looks like (I just removed the attributes part). The amount of information do not seems too big to me and I don't understand what is happening. The version of xarray is 0.20.2 against python 3.7.

What can explain it runs so slow? What could I do in order to speed up these processings?

DATASET 1
KeysView(<xarray.Dataset>
Dimensions: (time: 6, gid: 99)
Coordinates:
    time (time) datetime64[ns] 1959-08-01 ... 1959-08-01T05:00:00
    gid (gid) int64 6822 6823 6824 6825 6826 ... 7642 7643 7644 7645 7646
Data variables:
    lat (gid) float64 ...
    lon (gid) float64 ...
    tair (time, gid) float64 ...

DATASET2
KeysView(<xarray.Dataset>
Dimensions: (time: 8784, gid: 99)
Coordinates:    
    time (time) datetime64[ns] 1959-08-01T06:00:00 ... 1960-08-01T05:00:00
    gid (gid) int64 6822 6823 6824 6825 6826 ... 7642 7643 7644 7645 7646
Data variables:
    lat (gid) float64 ...
    lon (gid) float64 ...
    tair (time, gid) float64 ...


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source