【问题标题】:Count number of variables in netcdf file计算 netcdf 文件中的变量数
【发布时间】:2019-11-20 17:41:34
【问题描述】:

我有一个 netcdf 文件

ncdisp('F:\Data\Coriolis\ArgoProfiles\ArgoProfiles\DataSelection_20191119_093255_9342316/argo-profiles-2902636.nc')
Source:
           F:\Data\Coriolis\ArgoProfiles\ArgoProfiles\DataSelection_20191119_093255_9342316\argo-profiles-2902636.nc
Format:
           classic
Global Attributes:
           title               = 'Argo float vertical profile'
           institution         = 'CSIO'
           source              = 'Argo float'
           history             = '2019-11-19T09:33:19Z creation'
           references          = 'http://www.argodatamgt.org/Documentation'
           comment             = ''
           user_manual_version = '3.03'
           Conventions         = 'Argo-3.0 CF-1.6'
           featureType         = 'trajectoryProfile'
Dimensions:
           DATE_TIME = 14
           STRING256 = 256
           STRING64  = 64
           STRING32  = 32
           STRING16  = 16
           STRING8   = 8
           STRING4   = 4
           STRING2   = 2
           N_PROF    = 2
           N_PARAM   = 3
           N_LEVELS  = 71
           N_CALIB   = 1
           N_HISTORY = 6     (UNLIMITED)
Variables:
    DATA_TYPE                   
           Size:       16x1
           Dimensions: STRING16
           Datatype:   char
           Attributes:
                       long_name  = 'Data type'
                       _FillValue = ' '
    FORMAT_VERSION              
           Size:       4x1
           Dimensions: STRING4
           Datatype:   char
           Attributes:
                       long_name  = 'File format version'
                       _FillValue = ' '
    HANDBOOK_VERSION            
           Size:       4x1
           Dimensions: STRING4
           Datatype:   char
           Attributes:
                       long_name  = 'Data handbook version'
                       _FillValue = ' '

我想计算变量的数量。在这种情况下,答案是 3。

我尝试使用

info=ncinfo(FilePath);
numel(info.Variables.Name)

但这给了我

2.6413e+96
Warning: Number of elements exceeds maximum flint 2^53-1.
The result may be inaccurate. 

这是不正确的。 如何在我的 netcdf 文件中找到变量的数量?我原来的 netcdf 文件要大得多,我不能再用手数了。

【问题讨论】:

  • 实际上,您正在计算变量名称中的字符数。请改用numel(info.Variables)

标签: matlab netcdf


【解决方案1】:

@obchardon 是对的。

numel(info.Variables)统计netcdf文件中的变量个数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-04
    • 1970-01-01
    • 2014-04-21
    • 1970-01-01
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 2021-12-06
    相关资源
    最近更新 更多