计算netcdf文件中的变量数

时间:2019-11-19 15:55:40

标签: matlab netcdf

我有一个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文件大得多,我再也无法手工计算它们了。

1 个答案:

答案 0 :(得分:3)

@obchardon是正确的。

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