簡體   English   中英

在 python 上合並 Netcdf 文件

[英]Merging Netcdf files on python

我想合並兩個 netcdf 文件。 問題是第一個文件中的所有變量都包含在第二個文件中(具有不同的數據),而第二個文件有一些額外的變量。 所以,我想獲得一個 netcdf 文件,其中包含第二個文件的所有變量以及第一個文件的數據(定義時)。 謝謝你們。

您應該能夠使用 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")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM