当前位置: 首页 > 知识库问答 >
问题:

将4维netCDF数据导入R

邢曦
2023-03-14

我一直在寻找退出来解决我的问题,但我仍然无法解决它。我想将一个 nedCDF 文件导入 R 中。喜欢这个:

ncdata <- nc_open("prec_daily_2005-2005.nc")
print(ncdata)

我得到以下内容

File prec_daily_2005-2005.nc (NC_FORMAT_CLASSIC):

 1 variables (excluding dimension variables):
    float prec[longitude,latitude,z,time]   
        source: Reanalysis daily precipitation, statistically corrected for number of raindays, monthly amounts and diurnal cycle at 1.0deg; interpolated to 0.1deg; available GHCN/GSOD daily station data assimilated into gridded data
        name: prec
        title: Daily bias corrected precipitation
        date: 01/01/05
        time: 00:00
        long_name: Precipitation
        units: kg m-2 s-1
        missing_value: 2.00000004008175e+20
        _FillValue: 2.00000004008175e+20
        valid_min: 0
        valid_max: 0.0045476695522666

 4 dimensions:
    longitude  Size:800
        units: degrees_east
        point_spacing: even
    latitude  Size:300
        units: degrees_north
        point_spacing: even
    z  Size:1
        units: level
        positive: up
    time  Size:365   *** is unlimited ***
        units: days since 2005-01-01 00:00:00
        time_origin: 01-JAN-2005:00:00:00

6 global attributes:
    history: Thu May 22 10:21:12 EDT 2014: created by JS using convert2alma.sh
    title: Princeton University Hydroclimatology Group Bias Corrected African (1979-2005) Meteorological Forcing Dataset V1.0
    institution: Princeton University
    contact: Justin Sheffield (justin@princeton.edu)
    source: Forcings are a hybrid of NCEP/NCAR reanalysis and observations
    comment: This dataset is described in Chaney and Sheffield (2012) (Chaney, N., and J. Sheffield, 2012: High Resolution Gridded Daily Meteorological Data for Africa: Dataset Development and Analysis of Trends in Means and Extremes, J. Climate, to be submitted) and is related to the original global version reported in Sheffield et al., J. Climate (2006). Updates/changes include: i) African continent domain; ii) extension to 2005; iii) assimilation of available GHCN/GSOD daily station observations; iv) step change detection and correction for observational datasets; v) improved sampling procedure for correction of rain day statistics; vi) use of latest versions of CRU, SRB and TRMM products; vii) improved consistency between specific and relative humidity and air temperature. See Sheffield et al., J. Climate (2006) for details of the observations used and the bias correction and downscaling methodology.

然后我想提取降水数据,例如一天中的一个网格单元:

n_prec <- ncvar_get(ncdata, 'prec')
print(n_prec[1, 1, 1, 1])

但是我收到错误消息,例如:n_prec[1, 1, 1, 1]中的错误:错误的尺寸数

我不明白,因为数据集有维度。但是我可能误解了一些东西,因为我对r很陌生。

我很高兴得到任何帮助。曼纽尔

暂时还没有答案

 类似资料:
  • 我有一个 netcdf 数据文件,其中包含以下变量,显示在下面的 ncdump 代码段中: 我正在尝试从此文件中消除时间坐标变量,以便获得三维 netcdf 数据文件。基本上在netcdf文件中第一次拥有数据数据值,仅此而已。我试图用 ncks 完成此操作,这就是他们在进行谷歌搜索时显示我应该做的事情。我用 ncks 尝试了以下命令: 但我无法删除时间维度。我应该怎么做才能调整此命令以获得仅显示初

  • 我正在尝试将mysql数据库导入新版本的xampp(v7.1.8)。按下导入按钮后,我收到数百条此错误消息: 请注意.\vendor\phpmyadmin\sql parser\src\UtfString.php#128未初始化字符串偏移量:516 回溯 .\vendor\phpmyadmin\sql parser\src\Lexer.php\823:phpmyadmin\SqlParser\Ut

  • 本文向大家介绍MySQL 4种导入数据的方法,包括了MySQL 4种导入数据的方法的使用技巧和注意事项,需要的朋友参考一下 1、mysql 命令导入 使用 mysql 命令导入语法格式为: 实例: 以上命令将将备份的整个数据库 runoob.sql 导入。 2、source 命令导入 source 命令导入数据库需要先登录到数库终端: 3、使用 LOAD DATA 导入数据 MySQL 中提供了L

  • 学习如何使用xarray从DFs生成netCDF文件。在几个教程和SO问题之后,我向xarray数据集添加了“常量”维度,并向xarray数据集添加了“常量”维度,但仍然存在一些问题,因为我无法将日期、时间、纬度和经度作为维度。当我进行nc转储时,它们是不正确的。 最初的方法是将txt文件导入熊猫df,然后将xr导入netCDF: 其中df2= 这工作正常,但尺寸不正确(见下文): 如果我将日期或

  • 我已经搜索了很长时间,但仍然无法弄清楚这一点。似乎光栅包是要提取的,但只能从二维数据中提取。 这个四维数据的例子,一个netCDF文件包含连续三天(72小时)的每小时压力水平(4级)气温。https://drive.google.com/file/d/1UIiX9-xHrtH2FT1torg53iPxyzLxSYQu/view?usp=sharing。 我只想提取一些点位置(xy)的温度,以及相应

  • 尝试将数据库备份(.sql)从docker容器MySQL:5.6导入到我的本地MySQL(MariaDB)中。 下面是我使用的命令: 也想试试mysqlimport,但我总是遇到同样的错误。 第1行错误1064(42000):您的SQL语法中有错误;查看与您的MariaDB服务器版本相对应的手册,以了解在第1行“MySQL Ver 14.14 Distrib 5.6.33,for Linux(x8