本帖最后由 gaorui123 于 2024-4-27 21:02 编辑
我有CMA的预报数据,现在想将特定成员、特定预报时刻、特定预报步长的数据提取出来。 代码如下: 打印数据信息为:
数据信息
打印的时间信息为:
打印的时间信息
。 存在的问题是当我取特定time的索引大于25时,存在问题。当我time的索引是27的时候,d_data = data2.data能取到也不会报错 代码:
27取data时
结果: 但是当我想取出此时的values值时,就会报错 代码: 报错内容如下: Traceback (most recent call last): File "<input>", line 25, in <module> File"D:\anaconda3\envs\NWF\lib\site-packages\xarray\core\dataarray.py",line 733, in values return self.variable.values File"D:\anaconda3\envs\NWF\lib\site-packages\xarray\core\variable.py",line 614, in values return _as_array_or_item(self._data) File"D:\anaconda3\envs\NWF\lib\site-packages\xarray\core\variable.py",line 314, in _as_array_or_item data = np.asarray(data) File"D:\anaconda3\envs\NWF\lib\site-packages\dask\array\core.py", line1700, in __array__ x= self.compute() File "D:\anaconda3\envs\NWF\lib\site-packages\dask\base.py",line 342, in compute (result,) = compute(self, traverse=False, **kwargs) File "D:\anaconda3\envs\NWF\lib\site-packages\dask\base.py",line 628, in compute results = schedule(dsk, keys, **kwargs) File"D:\anaconda3\envs\NWF\lib\site-packages\xarray\core\indexing.py",line 484, in __array__ return np.asarray(self.get_duck_array(), dtype=dtype) File"D:\anaconda3\envs\NWF\lib\site-packages\xarray\core\indexing.py",line 487, in get_duck_array return self.array.get_duck_array() File"D:\anaconda3\envs\NWF\lib\site-packages\xarray\core\indexing.py",line 664, in get_duck_array return self.array.get_duck_array() File"D:\anaconda3\envs\NWF\lib\site-packages\xarray\core\indexing.py",line 551, in get_duck_array array = self.array[self.key] File "D:\anaconda3\envs\NWF\lib\site-packages\cfgrib\xarray_plugin.py",line 157, in __getitem__ return xr.core.indexing.explicit_indexing_adapter( File"D:\anaconda3\envs\NWF\lib\site-packages\xarray\core\indexing.py",line 858, in explicit_indexing_adapter result = raw_indexing_method(raw_key.tuple) File "D:\anaconda3\envs\NWF\lib\site-packages\cfgrib\xarray_plugin.py",line 166, in _getitem return self.array[key] File"D:\anaconda3\envs\NWF\lib\site-packages\cfgrib\dataset.py", line365, in __getitem__ message = self.index.get_field(message_ids[0]) # type: ignore File"D:\anaconda3\envs\NWF\lib\site-packages\cfgrib\messages.py", line484, in get_field return ComputedKeysAdapter(self.fieldset[message_id],self.computed_keys) File"D:\anaconda3\envs\NWF\lib\site-packages\cfgrib\messages.py", line344, in __getitem__ return self.message_from_file(file, offset=item) File"D:\anaconda3\envs\NWF\lib\site-packages\cfgrib\messages.py", line340, in message_from_file return Message.from_file(file, offset, **kwargs) File"D:\anaconda3\envs\NWF\lib\site-packages\cfgrib\messages.py", line93, in from_file file.seek(offset)OSError: [Errno 22] Invalid argument
|