Repository navigation
Replies: 1 comment
|
Since the time ranges don’t overlap, I’d use concat for tair and leave the fixed lat/lon out of the operation: out = xr.concat(
[ds1[['tair']], ds2[['tair']]], dim='time',
join='exact', coords='minimal',
)Here join='exact' checks the other index (gid); it doesn’t require matching time labels along the dimension you’re concatenating. I checked the equivalent with 6 and 8,784 synthetic time steps and confirmed a mismatched gid raises instead of expanding the grid. If you need lat/lon, verify once that they match, then attach one copy. If this is still slow, time opening the files, constructing out, and loading out.tair separately. Without that split it’s hard to tell alignment or repeated concat work from NetCDF reads/decompression. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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:
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:
Data variables:
lat (gid) float64 ...
lon (gid) float64 ...
tair (time, gid) float64 ...
DATASET2
KeysView(<xarray.Dataset>
Dimensions: (time: 8784, gid: 99)
Coordinates:
Data variables:
lat (gid) float64 ...
lon (gid) float64 ...
tair (time, gid) float64 ...
All reactions