2016-04-30 38 views
1
提取變量

我的目標是提取溫度,從每個緯度和經度從這個時代的臨時數據文件的日期(見鏈接https://www.dropbox.com/s/lnxetoy1911q5sg/_grib2netcdf-atls17-95e2cf679cd58ee9b4db4dd119a05a8d-vMTGKo.nc?dl=0年代中期數據來自RNetCDF

我使用RNetCDF包中的R,但是當我用var.get.nc函數我的值都是負數。我被困在這一步。當我打開ArcMap時,我知道netcdf中有數據。我的代碼如下所示

require(RNetCDF) 
nc_in1 = open.nc("_grib2netcdf-atls17-95e2cf679cd58ee9b4db4dd119a05a8d-vMTGKo.nc") 
# get all Air temperature data data: 
temp  <- var.get.nc(nc_in1, "t2m") 
head(temp) 

-8355 -8399 -8444 -8487 -8531 -8576

#DATA結構圖如下

print.nc(nc_in1) 
    dimensions: 
    longitude = 561 ; 
    latitude = 321 ; 
    time = UNLIMITED ; // (8 currently) 
    variables: 
    float longitude(longitude) ; 
      longitude:units = "degrees_east" ; 
      longitude:long_name = "longitude" ; 
    float latitude(latitude) ; 
      latitude:units = "degrees_north" ; 
      latitude:long_name = "latitude" ; 
    int time(time) ; 
      time:units = "hours since 1900-01-01 00:00:0.0" ; 
      time:long_name = "time" ; 
      time:calendar = "gregorian" ; 
    short t2m(longitude, latitude, time) ; 
      t2m:scale_factor = 0.001140245 ; 
      t2m:add_offset = 264.0577 ; 
      t2m:_FillValue = -32767 ; 
      t2m:missing_value = -32767 ; 
      t2m:units = "K" ; 
      t2m:long_name = "2 metre temperature" ; 

      // global attributes: 
      :Conventions = "CF-1.6" ; 
      :history = "2016-04-30 18:18:33 GMT by grib_to_netcdf-1.14.5: grib_to_netcdf /data/data01/scratch/_mars-atls02-95e2cf679cd58ee9b4db4dd119a05a8d-E36dti.grib -o /data/data01/scratch/_grib2netcdf-atls17-95e2cf679cd58ee9b4db4dd119a05a8d-vMTGKo.nc -uti 

我能夠使用相同的封裝和代碼使用MERRA數據實現相同,但我似乎無法在此ERA臨時數據集中找到我的錯誤。在RNetCDF中解決這個問題的任何幫助都會很有幫助,因爲我對這個軟件包並不熟悉,並且仍然在學習.nc文件。

+0

只是一個快速評論:用於處理R中格點資料,我強烈建議'raster'包。 – AF7

+0

感謝您的評論我在R的技能不夠尖銳。但是,柵格包允許我將數據轉換爲數據幀提取日期和相應的經緯度在同一行? – nee

+0

我不知道我明白。柵格包定義了R柵格數據的路徑,它非常靈活且易於使用。但是,如果您只需執行非常簡單的任務,那麼您可能會比使用ncdf4或RNetCDF更好。 – AF7

回答

2

的解決您的問題是,你需要解壓數據

temp  <- var.get.nc(nc_in1, "t2m", unpack= TRUE) 
+0

謝謝它的工作! – nee

相關問題