【问题标题】:Merge netCDF files: various unsuccessful attempts合并 netCDF 文件:各种不成功的尝试
【发布时间】:2021-08-16 07:49:48
【问题描述】:

我正在尝试为一个变量合并 3 个数据集(1981-1990、1991-2000、2001-2010)。 以 Jupyter (Python) 为例,1981-1990 年期间的特征是:

每个数据集包含一个 10 年的周期,其大小约为 4 GB。

看了一些帖子后,我在 Windows 10 中尝试了 4 种解决方案:

Jupyter (Python)

1.第一个建议

 import xarray as xr
    t2m_81_90 = xr.open_dataset('era5land_2m_temperature_hourly_ene-dic_1981-1990.nc')
    t2m_91_00 = xr.open_dataset('era5land_2m_temperature_hourly_ene-dic_1991-2000.nc')
    t2m_81_00 = xr.merge([t2m_1981_1990,t2m_1991_2000])

结果表明:

C:\Users\eleph\anaconda3\lib\site-packages\xarray\core\alignment.py:307: FutureWarning: Index.__or__ 
operating as a set operation is deprecated, in the future this will be a logical operation matching 
Series.__or__.  Use index.union(other) instead index = joiner(matching_indexes)

MemoryError: Unable to allocate 15.5 GiB for an array with shape (175319, 184, 129) and data type float32

2.第二个建议

ncrcat era5land_2m_temperature_hourly_ene-dic_1981-1990.nc era5land_2m_temperature_hourly_ene-dic_1991-2000.nc temper_all.nc

结果:

SyntaxError: invalid syntax

3.第三个建议

import netCDF4
from netCDF4 import Dataset

dataset = netCDF4.MFDataset(['era5land_2m_temperature_hourly_ene-dic_1981-1990.nc','era5land_2m_temperature_hourly_ene-dic_1991-2000.nc'])

结果:

ModuleNotFoundError: No module named 'netCDF4'

我以为错误是因为没有安装“netCDF4”,但在尝试安装后,显示:

Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort. failed

CDO (Cygwin)

4.第四条建议

$ cdo mergetime era5land_2m_temperature_hourly_ene-dic_1981-1990.nc era5land_2m_temperature_hourly_ene-dic_1991-2000.nc 2m_tempmerature_1981-2000.nc

结果:

cdf_put_vara_double: name=t2m  type=NC_SHORT  minval=-32767.000000  maxval=33531.000000

Error (cdf_put_vara_double): NetCDF: Numeric conversion not representable

我知道这篇文章很长,但我想展示我所做的试验。也许其中一些可以修复。 对合并这些数据集的任何帮助将不胜感激!

【问题讨论】:

  • 我们在哪里可以找到数据?没有它们,很难复制你的任何试探性。
  • 您可能需要更改 CDO 中的输出精度。没有数据,我无法提供解决方案。但是请阅读此线程并尝试此处给出的答案code.mpimet.mpg.de/boards/1/topics/7764
  • @matzeri 我是通过气候数据存储中的 API 下载的,因为它可以让我自定义特定区域,但您可以尝试使用 this

标签: python cygwin netcdf


【解决方案1】:

使用

xarray.open_mfdataset([
    'era5land_2m_temperature_hourly_ene-dic_1981-1990.nc',
    'era5land_2m_temperature_hourly_ene-dic_1991-2000.nc'
]) 

并定义参数concat_dim。我想它应该是一个时间维度,您可以将数据集连接起来。

提示:使用打开多个文件时打开并行模式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-28
    • 2018-06-04
    • 2015-05-11
    • 2018-10-10
    • 2019-07-31
    • 1970-01-01
    • 2017-12-19
    • 1970-01-01
    相关资源
    最近更新 更多