matlab读取mls卫星.hdf数据
作者:互联网
clear
% 打开HDF文件
FILE_NAME = ‘E:\MLS DATA\O3\MLS-Aura_L2GP-O3_v04-23-c01_2017d005.SUB.he5’;
file_id = H5F.open (FILE_NAME, ‘H5F_ACC_RDONLY’, ‘H5P_DEFAULT’);
% 打开数据
DATAFIELD_NAME = ‘HDFEOS/SWATHS/O3/Data Fields/L2gpValue’;
data_id = H5D.open (file_id, DATAFIELD_NAME);
% 打开一维数组
PRESSURE_NAME=‘HDFEOS/SWATHS/O3/Geolocation Fields/Pressure’;
pre_id=H5D.open(file_id, PRESSURE_NAME);
TIME_NAME=‘HDFEOS/SWATHS/O3/Geolocation Fields/Time’;
time_id=H5D.open(file_id, TIME_NAME);
% 读入数据和维度
data1=H5D.read (data_id,‘H5T_NATIVE_DOUBLE’, ‘H5S_ALL’, ‘H5S_ALL’,‘H5P_DEFAULT’);
pressure=H5D.read(pre_id,‘H5T_NATIVE_DOUBLE’, ‘H5S_ALL’, ‘H5S_ALL’,‘H5P_DEFAULT’);
time=H5D.read(time_id,‘H5T_NATIVE_DOUBLE’, ‘H5S_ALL’, ‘H5S_ALL’,‘H5P_DEFAULT’);
% 数据时间从1993年1月1日0时0分0秒开始
time1lvl=datestr(datevec(datenum(1993,1,1,0,0,0)+time(1)/86400)); %time(k),k值依数据选取
% 将2维数据转换为1维数据
data=squeeze(data1(:,1))*(10^6);
% 读入数据的Units.
ATTRIBUTE = ‘Units’;
attr_id = H5A.open_name (data_id, ATTRIBUTE);
units = H5A.read(attr_id, ‘H5ML_DEFAULT’);
% 读入units of pressure axis.
ATTRIBUTE = ‘Units’;
attr_id = H5A.open_name (pre_id, ATTRIBUTE);
units_pre = H5A.read(attr_id, ‘H5ML_DEFAULT’);
% 读入fill value.
ATTRIBUTE = ‘_FillValue’;
attr_id = H5A.open_name (data_id, ATTRIBUTE);
fillvalue=H5A.read (attr_id, ‘H5T_NATIVE_DOUBLE’);
% 读入missing value.
ATTRIBUTE = ‘MissingValue’;
attr_id = H5A.open_name (data_id, ATTRIBUTE);
missingvalue=H5A.read (attr_id, ‘H5T_NATIVE_DOUBLE’);
% 读入 title.
ATTRIBUTE = ‘Title’;
attr_id = H5A.open_name (data_id, ATTRIBUTE);
titles = H5A.read(attr_id, ‘H5ML_DEFAULT’);
% Close and release resources.
H5A.close (attr_id)
H5D.close (data_id);
H5D.close (pre_id);
H5D.close (time_id);
H5F.close (file_id);
% Replace the fill value with NaN.
data(data==fillvalue) = NaN;
% Replace the missing value with NaN.
data(data==missingvalue) = NaN;
标签:H5D,H5A,mls,ATTRIBUTE,hdf,matlab,data,id,attr 来源: https://blog.csdn.net/qq_42010248/article/details/99988766