⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 read_hdf5_sdn_data.pro

📁 浏览MODIS遥感数据的HDF格式数据的IDL程序
💻 PRO
字号:
;--------------------------------------------------------------------------------pro read_hdf5_sdn_data, index, filename,infopro_name = 'read_hdf5_sdn_data'@getinfo;; Get the dimensions for this simple dataset; Initial the variable typesds_dims = info.sds.dimssds_rank = info.sds.ranksds_type = info.sds.typeinfo.ssf.key = 0info.ssf.select = 0info.ssf.layer = 0nlayer = info.hdf5.nlayerdata_name = info.name_list_sds(index)data_name = data_name(0)current_data_name = ''for j = 1, nlayer do begin    if strlen(info.hdf5.name_string[j]) gt 0 then begin	current_data_name = current_data_name + '/' + info.hdf5.name_string[j]    endifendforcurrent_data_name = current_data_name + '/' + data_name;  Open a HDF5 filefileid = open_hdf5_file(filename)if fileid eq -1 then begin    result=dialog_message('Problem open HDF5 file!',$        title='View HDF Warning!')    returnendif;  Open the datasetdataset_id = H5D_OPEN(fileid, current_data_name);  Get the dataspace iddataspace_id = H5D_GET_SPACE(dataset_id);  Get the dimension sizes and ranksds_rank = H5S_GET_SIMPLE_EXTENT_NDIMS(dataspace_id)sds_dims = H5S_GET_SIMPLE_EXTENT_DIMS(dataspace_id, MAX_DIMENSIONS=max_dims); Get the datatype iddatatype_id = H5D_GET_TYPE(dataset_id);  Get the data typedataclass = H5T_GET_CLASS(datatype_id)datasize = H5T_GET_SIZE(datatype_id)datasign = H5T_GET_SIGN(datatype_id)sds_type = get_hdf5_datatype(dataclass, datasize, datasign)if sds_type lt 0 then begin    result=dialog_message('The type data cannot convert to idl type!',$	title='View HDF Warning!')    returnendifinfo.sds.index = indexinfo.sds.rank = sds_rank info.sds.dims = reverse(sds_dims)info.sds.type = sds_type print,'dataset name = ',current_data_nameprint,'rank = ',sds_rankprint,'dimension = ',sds_dimsprint,'sds_type = ', sds_typeinfo.sds.ref = dataset_idinfo.rangetype.dim_name(*) = ''for i = 0 , sds_rank-1 do begin    info.rangetype.dim_name(i) = 'Dimension ' + strcompress(string(i+1),/REMOVE_ALL)endforunit_list = [ 'None' ]num_attr = H5A_GET_NUM_ATTRS(dataset_id)if num_attr gt 0 then begin    for i = 0, num_attr-1 do begin	attribute_id = H5A_OPEN_IDX(dataset_id, i)	attribute_name = H5A_GET_NAME(attribute_id)	attribute_value = read_hdf5_attribute(attribute_id)	attribute_name =strlowcase(attribute_name)	if strpos(attribute_name,"unit") ne -1 then unit_list = [attribute_value]	H5A_CLOSE, attribute_id    endforendifif info.show_attr gt 0 then begin    get_data_attr,filename,current_data_name, -1, 2, info    ;num_attr = H5A_GET_NUM_ATTRS(dataset_id)    ;if num_attr gt 0 then begin;	for i = 0, num_attr-1 do begin;	    attribute_id = H5A_OPEN_IDX(dataset_id, i);	    attribute_name = H5A_GET_NAME(attribute_id);	    attribute_value = read_hdf5_attribute(attribute_id);	    print,'i = ',i,': attribute = name: ',attribute_name,', value = ',attribute_value;	    H5A_CLOSE, attribute_id;	endfor;    endif    if info.show_attr eq 2 then begin	H5T_CLOSE, datatype_id	close_hdf5_dataspace, dataspace_id	H5D_CLOSE, dataset_id	return    endifendifif unit_list[0] ne 'None' then info.unitname = ', '+unit_list[0] else info.unitname = ''info = redefine_info( info, unit_list, 7);if info.rangetype.type eq 2 then begin;    read_sds_multiple_files, filename, data_name, sds_ref, info;    return;endifH5T_CLOSE, datatype_idclose_hdf5_dataspace, dataspace_idH5D_CLOSE, dataset_idhdf5_sdn_range_dialogue, infoend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -