我想合并两个netcdf文件。问题是第一个文件中的所有变量都包含在第二个文件中(具有不同的数据),而第二个文件有一些额外的变量。因此,我想获得一个netcdf文件,其中包含第二个文件的所有变量和第一个变量的数据(在定义时)。谢谢你们所有人。
发布于 2021-06-09 21:00:04
您应该能够使用nctoolkit (https://nctoolkit.readthedocs.io/en/latest/)轻松处理此问题,如下所示:
import nctoolkit as nc
# read in the files
ds = nc.open_data("infile1.nc")
ds2 = nc.open_data("infile2.nc")
# remove the 1st netcdf files variables from the second's
ds2.drop(ds.variables)
# merge the files
ds.append(ds2)
ds.merge()
# save the files as a netcdf file
ds.to_nc("merged.nc")https://stackoverflow.com/questions/67903696
复制相似问题