0

2 つの netcdf ファイル (2 年間の気候データ) を読み取り、1 つのグリッド (lon [15] と lat[15]) のデータを配列 (prec_year という名前) に結合します。スクリプトは以下のとおりです。

エラーが発生しました:

"Error in R_nc_get_vara_double: NetCDF: Index exceeds dimension bound
Var: precip  Ndims: 3   Start: 0,4294967284,59Count: 366,1,1Error in get.var.ncdf   (ex.nc, "precip", start = c(lon[1], lat[15], 1),  : 

C 関数 R_nc_get_vara_double がエラーを返しました"

しかし、lat[] を指定しない場合、たとえば「start = c(lon[1], 1,1)」と言うと、問題なく動作します。(1)なぜこのエラーが発生したのか、(2)修正方法を教えてください。

どうもありがとう!--------------------

setwd ("D://Historic Climate data/Aphrodyte/Prec_025/join 2 years")
Prec_origin <- c(1:2)
filenames <- list.files(pattern = NULL, all.files = FALSE)
 for(i in filenames){
filepath <- file.path("D://Historic Climate data/Aphrodyte/Prec_025/join 2 years/",paste    (i,sep=""))
    ex.nc = open.ncdf (filepath, readunlim=FALSE)
    lon = get.var.ncdf( ex.nc, "longitude")          # coordinate variable
  lat = get.var.ncdf( ex.nc, "latitude")          # coordinate variable
  day =  get.var.ncdf( ex.nc, "time")            # time variable
  #change lon[x] and lat[y] to select different files/locations for comparison
  prec_year = get.var.ncdf(ex.nc, "precip", start = c(lon[1],lat[15],1), count = c(1,1,-1))
    Prec_origin <- c(Prec_origin, prec_year)  #combine all data into one array
  close.ncdf (ex.nc)
 }
 Prec_origin <- Prec_origin[-(1:2)] # delete first two rows-
--------------
[1] "file D://Historic Climate data/Aphrodyte/Prec_025/join 2     years//APHRO_MA_025deg_V1003R1.1952.nc has 3 dimensions:"
[1] "time   Size: 366"
[1] "longitude   Size: 360"
[1] "latitude   Size: 280"
[1] "------------------------"
[1] "file D://Historic Climate data/Aphrodyte/Prec_025/join 2 years//APHRO_MA_025deg_V1003R1.1952.nc has 2 variables:"
[1] "float precip[longitude,latitude,time]  Longname:daily precipitation analysis interpolated onto 0.25deg grids [mm/day] Missval:-99.9000015258789"
[1] "float rstn[longitude,latitude,time]  Longname:ratio of 0.05deg-grids with station [%]     Missval:-99.9000015258789"
4

1 に答える 1