汪帮主卫星遥感空间分享 http://blog.sciencenet.cn/u/zjwang 湖北鄂州人,2011年博士毕业于吉林大学。现从事卫星遥感技术工作。

博文

基于MATLAB创建HDF之Vgroup及向存在Vgroup中追加数据

已有 7006 次阅读 2010-9-20 14:53 |个人分类:计算程序|系统分类:科研笔记| 创建, HDF, Vgroup, 追加

下面的两个例子,

1,展示了如何往HDF文件中新建一个Vgroup并加入数据,
2,展示了如何往Vgroup中追加数据

 process 1

%% insert a Vgroup to a exist HDF file
% open a hdf file
% written by WANG Zijun, 2010.09.20
% Jilin University, Email: wzj08@mails.jlu.edu.cn
fId = hdfh('open', 'LimbRad.hdf','rdwr', 0);
% init Vgroup and SD Interfaces
stat = hdfv('start', fId);
sdId = hdfsd('start', 'LimbRad.hdf', 'write');

%create a Vgroup and SDS
sdsId = hdfsd('create',  sdId, 'lat_sat', 'double', 2, [21 14]);
stat = hdfsd('writedata', sdsId, [0 0], [], [21 14], lat_sat);
vgId = hdfv('attach', fId, -1, 'w');
stat = hdfv('setname', vgId, 'SatGeom');
stat = hdfv('setclass', vgId, 'class1');

% insert SDS in Vgroup
sRef = hdfsd('idtoref', sdsId);
stat = hdfv('addtagref', vgId, 720 , sRef);
stat = hdfsd('endaccess', sdsId);
stat = hdfsd('end', sdId);

% detach Vgroup, close Vgroup interface and file
stat = hdfv('detach', vgId);
stat = hdfv('end', fId);
stat = hdfh('close', fId);
hdfml('closeall');

process 2

%% reopen a hdf and insert SDS to a Vgroup
% open a hdf file
fId = hdfh('open', 'LimbRad.hdf','rdwr', 0);

% init Vgroup and SD Interfaces
stat = hdfv('start', fId);
sdId = hdfsd('start', 'LimbRad.hdf', 'write');

%create a SDS
sdsId = hdfsd('create',  sdId, 'lon_sat', 'double', 2, [21 14]);
stat = hdfsd('writedata', sdsId, [0 0], [], [21 14], lon_sat);

%get the reference number of the target Vgroup
vgRef = hdfv('find', fId, 'SatGeom');
% Attach to the target vGroup
vgId = hdfv('attach', fId, vgRef, 'w');

% insert SDS to Vgroup
sRef = hdfsd('idtoref', sdsId);
stat = hdfv('addtagref', vgId, 720 , sRef);
stat = hdfsd('endaccess', sdsId);
stat = hdfsd('end', sdId);

% detach Vgroup, close Vgroup interface and file
stat = hdfv('detach', vgId);
stat = hdfv('end', fId);
stat = hdfh('close', fId);
hdfml('closeall');





https://wap.sciencenet.cn/blog-43777-364934.html

上一篇:基于MATLAB创建HDF文件及向存在HDF中追加数据
下一篇:SCIA_JLU-our trace gas retrieval program from limb radiance
收藏 IP: .*| 热度|

0

发表评论 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-12-27 14:04

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部