I am trying to combine multiple NetCDF files using xarray.
Here are my dimensions:
Dimensions: (Time: 1, XCells: 2000, YCells: 1000)
Coordinates:
longitude (YCells, XCells) float32
latitude (YCells, XCells) float32
* Time (Time) datetime64[ns]
Dimensions without coordinates: XCells, YCells
Combine by_coords only works for 1-dimensional coordinates. combining spatial netcdf files using xarray python
However, when I use combine="nested", It repeats latitude and longitude for Time.
float longitude(Time, YCells, XCells);
longitude:_FillValue = NaNf;
float latitude(Time, YCells, XCells);
latitude:_FillValue = NaNf;
Latitude and Longitude are 2-D, but the same across the time. Does Xarray have a way of combining this data?
xr.concat([file1, file2], concat_dim='time')should work.concatwill repeat the original the original dims in this way. Maybe xarray has a easier way to handle this, but I would also approach it by assigning new lon and lat coordinates. Great that it worked for you, and please post your answer so that it might be of use to someone in the future :)