我有多个 netCDF 文件,其中包含不同年份的降水气候数据。我想将这些文件合并为一个。所有文件都具有相同的尺寸和变量,只是日期不同。
我使用 NCO 使用以下代码来执行此操作:
# Set working directory
setwd("C:/Users/Admin/Documents/MASTERTHESIS/thesis_data/ISIMIP2b hadgem2-es future/rcp60/pr")
# Define file paths
input_file1 <- "pr_day_rcp60_20060101_20101231.nc"
input_file2 <- "pr_day_rcp60_20110101_20201231.nc"
output_file <- file.path("C:/Users/Admin/Documents/MASTERTHESIS/thesis_data/ISIMIP2b hadgem2-es future/rcp60/pr", "combined_rcp60_pr.nc")
# Define the command as a character string
command <- paste("ncrcat", input_file1, input_file2, output_file)
# Execute the command
system(command)
没有生成任何输出,但也没有任何错误。我收到的唯一消息如下。
`> system(command)
[1] 127`
我错过了什么?
首先在命令行上执行是个好主意。不知道 R,但
system()
应该接收如下命令(确保空格分隔参数):
ncrcat -O in1.nc in2.nc out.nc
-O
确保输出文件(如果已存在)被覆盖而不提示。否则命令会提示并等待确认。这很容易成为问题......