首页 > 解决方案 > 从哥白尼读取 NetCDF4 LST 文件的问题

问题描述

我有一系列来自哥白尼的每小时 LST 数据。这些可以在 Panopoly(Windows 版本 4.10.6)中很好地阅读和显示,但是:

*

file1 <- nc_open('g2_BIOPAR_LST_201901140400_E114.60S35.43E119.09S30.22_GEO_V1.2.nc')
file2 <- nc_open('g2_BIOPAR_LST_201901140500_E114.60S35.43E119.09S30.22_GEO_V1.2.nc')
# attributes(file1)$names
# Just for one variable for now
dat_new <- cbind(
  ncvar_get(file1, 'LST'),
  ncvar_get(file2, 'LST'))
dim(dat_new)
print(dim(dat_new))
var <- file1$var['LST']$LST
# Create a new file
file_new <- nc_create(
  filename = 'Copernicus_LST.nc', 
  # We need to define the variables here
  vars = ncvar_def(
    name = 'LST',
    units = var$units,
    dim = dim(dat_new)))

# And write to it
ncvar_put(
  nc = file_new,
  varid = 'LST',
  vals = dat_new)
# Finally, close the file
nc_close(file_new)

回报:

[1] "Error, passed variable has a dim that is NOT of class ncdim4!"
[1] "Error occurred when processing dim number 1 of variable LST"
Error in ncvar_def(name = "LST", units = var$units, dim = dim(dat_new)) : 
  This dim has class: integer

同样,使用 python netCDF4 方法

compiled = netCDF4.MFDataset(['g2_BIOPAR_LST_201901140400_E114.60S35.43E119.09S30.22_GEO_V1.2.nc','g2_BIOPAR_LST_201901140500_E114.60S35.43E119.09S30.22_GEO_V1.2.nc'])) 

退货

ValueError: MFNetCDF4 only works with NETCDF3_* and NETCDF4_CLASSIC formatted files, not NETCDF4

我假设这是哥白尼文件格式的问题......还有其他人遇到过这个吗?将这两个示例文件放在这里

谢谢!

标签: netcdf4

解决方案


推荐阅读