简体   繁体   中英

Combining NetCDF files using Xarray

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?

I combined the files by time using.netcdf-python and numpy.

The code for copying one dataset to another is similar to Xavier Ho's solution here: python.netcdf: making a copy of all variables and attributes but one

Variables that I didn't want to repeat I copied directly. For the time dimension and variable altering with time, I altered the copy expression using numpy slices.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM