cftime.\u cftime.DatetimeGregorian对象没有属性“ndim”

2024-04-29 11:56:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我的问题:

cftime._cftime.DatetimeGregorian' object has no attribute 'ndim'.

我使用netCDF4读取NC数据集(时间坐标、纬度、经度)。带有以下内容的时间戳

information:double ddm_timestamp_utc(sample=3568, x=50, y=50);
:long_name = "DDM sample timestamp - UTC";
:standard_name = "time";
:calendar = "gregorian";
:comment = "DDM sample time. The number of seconds since time_coverage_start with nanosecond resolution. Its position relative to the DDM sampling period is determined by ddm_time_type_selector. Some metadata required for DDM calibration are generated relative to pvt_timestamp_utc or att_timestamp_utc. These metadata are interpolated to ddm_timestamp_utc before being used for DDM calibration. Note that the DDM sampling period is not synchronized with the UTC change of second and can occur at any time relative to the UTC change of second.";
:units = "seconds since 2016-01-01 00:00:00.0"

我尝试使用以下代码阅读:

nc_time = nc.variables['ddm_timestamp_utc'][:, i, j]
units = nc.variables['ddm_timestamp_utc'].units
calendar = nc.variables['ddm_timestamp_utc'].calendar
tt =[np.datetime64(num2date(t, units, calendar=calendar)).astype(datetime)
for t in nc_time] time = np.ma.array(tt, mask=nc_time.mask)

我得到一个属性错误:

cftime._cftime.DatetimeGregorian' object has no attribute 'ndim'

在以下方面:

tt =[np.datetime64(num2date(t, units, calendar=calendar)).astype(datetime) for t in nc_time].

我猜这个问题可能是由netCDF(1.5.3)或python(我试过3.7和3.8)的版本引起的


Tags: ofthetosamplefortimecalendartimestamp