我正在尝试使用 xarray 来追加和编写 netCDF 文件。下面是有关原始文件的一些信息。
Dimensions: (Time: 744, south_north: 289, west_east: 339)
Coordinates:
XLAT (Time, south_north, west_east) float32 ...
XLONG (Time, south_north, west_east) float32 ...
Dimensions without coordinates: Time, south_north, west_east
Data variables:
Times (Time) |S19 ...
RAINNC (Time, south_north, west_east) float32 ...
I_RAINNC (Time, south_north, west_east) int32 ...
SNOWNC (Time, south_north, west_east) float32 ...
GRAUPELNC (Time, south_north, west_east) float32 ...
HAILNC (Time, south_north, west_east) float32 ...
这是有关附加文件的一些信息(添加了两个变量)。
Dimensions: (Time: 744, south_north: 289, west_east: 339)
Coordinates:
XLAT (Time, south_north, west_east) float32 ...
XLONG (Time, south_north, west_east) float32 ...
Dimensions without coordinates: Time, south_north, west_east
Data variables:
Times (Time) |S19 ...
RAINNC (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0
I_RAINNC (Time, south_north, west_east) int32 0 0 0 0 0 0 0 0 0 0 0 0
SNOWNC (Time, south_north, west_east) float32 ...
GRAUPELNC (Time, south_north, west_east) float32 ...
HAILNC (Time, south_north, west_east) float32 ...
PRCP (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0
CUMPRCP (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0
我正在尝试使用 xarray.to_netcdf() 编写一个新文件,但收到此错误:
ValueError: cannot serialize coordinates because variable RAINNC
already has an attribute 'coordinates'
有关如何解决此错误的任何想法?
编辑:
数据是通过天气和研究预测模型 (WRF) 生成的。数据通过 open_dataset() 加载,默认为 decode_cf。两个文件的 RAINNC 属性相同,如下所列。
OrderedDict([('FieldType', 104),
('MemoryOrder', 'XY '),
('description', 'ACCUMULATED TOTAL GRID SCALE PRECIPITATION'),
('units', 'mm'),
('stagger', ''),
('coordinates', 'XLONG XLAT XTIME')])