【问题标题】:netCDF files has no variables in python when importing with xarray使用 xarray 导入时,netCDF 文件在 python 中没有变量
【发布时间】:2021-04-27 14:49:20
【问题描述】:

我对 xarray 非常陌生,我尝试使用 xarray 将卫星 netcdf 文件导入 python 使用此文件:https://tropomi.gesdisc.eosdis.nasa.gov/data//S5P_TROPOMI_Level2/S5P_L2__NO2____HiR.1/2020/003/S5P_OFFL_L2__NO2____20200103T170946_20200103T185116_11525_01_010302_20200105T100506.nc

这是我使用的代码:

import xarray as xr
import numpy as np
import pandas as pd

tropomi = xr.open_dataset('test2.nc', engine = 'netcdf4')
tropomi 

输出:

但是输出没有显示任何变量,并且有 53 个属性 - 为什么会发生这种情况?

谢谢!

【问题讨论】:

  • 可以添加输出吗?
  • 我添加了输出的屏幕截图。
  • nudump -h test2.nc的输出怎么样?
  • 我会在哪里做呢?在终端?当我这样做时,我收到消息“找不到命令”
  • 您应该在终端中输入它。 ncdump 包含在 netcdf4 发行版中。您使用哪个命令安装 xarray?通过点子?还是康达?我使用 conda 安装它。我的ncdump${anaconda_path}/envs/${environment_name}/bin/ncdump。我想看看ncdump -h的输出和xarray的输出是否一致。

标签: python python-xarray satellite


【解决方案1】:

我想通了。当您打开未定义组的文件时,您将获得没有变量的全局属性。您需要包含一个 group='PRODUCT' 来获取数据产品,如下所示:


tropomi = xr.open_dataset('test2.nc', group='PRODUCT')

【讨论】:

    猜你喜欢
    • 2019-09-03
    • 2021-09-27
    • 2018-12-31
    • 2013-05-14
    • 2021-01-22
    • 2021-11-02
    • 2016-02-15
    • 2018-04-23
    • 1970-01-01
    相关资源
    最近更新 更多