简体   繁体   English

合并 R 中的多个 NetCDF 文件

[英]Merging multiple NetCDF files in R

Discretion: I'm fairly new to using NetCDF files and R.谨慎:我对使用 NetCDF 文件和 R 相当陌生。 I have 96 individual.nc4 files for monthly global air temperature from 1901 to 2010. They have the same dimensions for lon, lat, and time, and the variable is monthly air temperature.从 1901 年到 2010 年,我有 96 个 individual.nc4 文件,用于记录每月全球气温。它们的 lon、lat 和 time 尺寸相同,变量是每月气温。 I would like to merge all 96 files into a singular.nc4 file so that I could use it as driver data in a model I am running.我想将所有 96 个文件合并到一个单一的.nc4 文件中,以便我可以将它用作我正在运行的 model 中的驱动程序数据。 I have written the following code:我写了以下代码:

enter image description here在此处输入图像描述

However, it keeps returning the following error message:但是,它不断返回以下错误消息:

Error in ncvar_def("Tair_monthly", "k", "time") : 
  This dim has class: character

Not sure how to get around this so would love any advice on 1) what this error means and how to solve and 2) generally how to merge multiple NetCDF files in R不知道如何解决这个问题,所以会喜欢关于 1)这个错误意味着什么以及如何解决以及 2)一般如何在 R 中合并多个 NetCDF 文件的任何建议

If you are new to netCDF it is possibly better to learn the command line tool CDO.如果您是 netCDF 的新手,学习命令行工具 CDO 可能会更好。 It will be able to merge files much more easily than anything available in R.它将能够比 R 中的任何东西更容易地合并文件。 To merge your files you would just need to do:要合并您的文件,您只需执行以下操作:

cdo mergetime *.nc merged_tai.nc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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