首页 > 解决方案 > 将时间指定为“base_time”的偏移量时合并 netCDF 文件

问题描述

我想使用时间维度合并多个 netCDF 文件。这些文件是相同的,但时间由“base_time”中的“time_offset”指定,其中每个文件中的“base_time”不同。

特别是在我的情况下,我每天都有一个文件,“base_time”是那天的开始,即:

    <class 'netCDF4._netCDF4.Variable'>
int32 base_time()
    string: 1-Jan-2019, 00:00:00 GMT
    long_name: Base time in Epoch
    units: seconds since 1970-1-1 0:00:00 0:00
    unlimited dimensions: 
    current shape = ()
    filling on, default _FillValue of -2147483647 used

'time_offset' 是以秒为单位的基准时间的偏移量,即:

<class 'netCDF4._netCDF4.Variable'>
float64 time_offset(time)
    long_name: Time offset from base_time
    units: seconds since 2019-1-1 00:00:00 0:00
unlimited dimensions: time
current shape = (826,)
filling on, default _FillValue of 9.969209968386869e+36 used

所以'time_offset'的单位每天都不同,因为'base_time'不同。

我尝试了以下方法:

test = xarray.open_mfdataset(all_files,decode_cf=True,concat_dim='time')

但我收到以下错误:

ValueError: Could not find any dimension coordinates to use to order the datasets for concatenation

我是 xarray 的新手,不太确定如何解决这个问题,任何建议都会有所帮助:)

标签: pythonnetcdfpython-xarray

解决方案


推荐阅读