简体   繁体   中英

Merge 70 netCDF files with xarray

I want to merge 70 netCDF files into one. For that I use the.to_netcdf() function of xarray:

    ds = xarray.open_mfdataset('*.nc')
    ds.to_netcdf('SST_2021-10_timeseries.nc')

My problem is that my jupyter notebook always hangs up because the number of files is too high. Is there a more efficient way to merge the files?

An alternative would be to use nctoolkit. Commands would be as follows:

import nctoolkit as nc
ds = nc.open_data('*.nc')
ds.merge("time")
ds.to_nc('SST_2021-10_timeseries.nc')

Or you could do it on the command line with CDO:

cdo -mergetime *.nc SST_2021-10_timeseries.nc

Those options should get around any RAM issues.

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