当前位置: 首页 > 工具软件 > OPeNDAP > 使用案例 >

matlab opendap,导入 NetCDF 文件和 OPeNDAP 数据

郑帅
2023-12-01

显示示例 NetCDF 文件 example.nc 的内容。

ncdisp('example.nc')

Source:

\\matlabroot\toolbox\matlab\demos\example.nc

Format:

netcdf4

Global Attributes:

creation_date = '29-Mar-2010'

Dimensions:

x = 50

y = 50

z = 5

Variables:

avagadros_number

Size: 1x1

Dimensions:

Datatype: double

Attributes:

description = 'this variable has no dimensions'

temperature

Size: 50x1

Dimensions: x

Datatype: int16

Attributes:

scale_factor = 1.8

add_offset = 32

units = 'degrees_fahrenheight'

peaks

Size: 50x50

Dimensions: x,y

Datatype: int16

Attributes:

description = 'z = peaks(50);'

Groups:

/grid1/

Attributes:

description = 'This is a group attribute.'

Dimensions:

x = 360

y = 180

time = 0 (UNLIMITED)

Variables:

temp

Size: []

Dimensions: x,y,time

Datatype: int16

/grid2/

Attributes:

description = 'This is another group attribute.'

Dimensions:

x = 360

y = 180

time = 0 (UNLIMITED)

Variables:

temp

Size: []

Dimensions: x,y,time

Datatype: int16

ncdisp 显示文件中的所有组、维度和变量定义。无限维度用标签 UNLIMITED 标识。

从 peaks 变量中读取数据。

peaksData = ncread('example.nc','peaks');

显示有关 peaksData 输出的信息。

whos peaksData

Name Size Bytes Class Attributes

peaksData 50x50 5000 int16

读取与变量相关联的 description 属性。

peaksDesc = ncreadatt('example.nc','peaks','description')

peaksDesc =

z = peaks(50);

创建变量数据的三维曲面图。用 description 属性的值作为图标题。

surf(double(peaksData))

title(peaksDesc);

读取与 /grid1/ 组相关联的 description 属性。将组名指定为 ncreadatt 函数的第二个输入。

g = ncreadatt('example.nc','/grid1/','description')

g =

This is a group attribute.

读取全局属性 creation_date。对于全局属性,将 ncreadatt 的第二个输入参数指定为 '/'。

creation_date = ncreadatt('example.nc','/','creation_date')

creation_date =

29-Mar-2010

 类似资料: