IDL常用function书写归纳

检测输入路径

  if ~file_test(input_directory,/dorectory) then begin
    print,'输入路径不存在
    return'
  endif

检测输出路径

  if dir_test eq 0 then begin
    file_mkdir,out_directory
  endif

获取 hdf4

输入:
1.数据地址
2.数据集名称
得到:
数据集的数据

function hdf4_data_get,file_name,sds_name
  sd_id=hdf_sd_start(file_name,/read)
  sds_index=hdf_sd_nametoindex(sd_id,sds_name)
  sds_id=hdf_sd_select(sd_id,sds_index)
  hdf_sd_getdata,sds_id,data
  hdf_sd_endaccess,sds_id
  hdf_sd_end,sd_id
  return,data
end

获取 hdf5

输入:
1.数据地址
2.数据集名称
得到:
数据集的数据

function hdf5_data_get,file_name,dataset_name
  file_id = h5f_open(file_name)
  dataset_id = h5d_open(file_id,dataset_name) ;直接返回id 而不是index
  data = h5d_read(dataset_id)
  h5d_close,dataset_id ; h5d 关闭数据集
  h5f_close,file_id ; h5f 关闭文件
  return,data
  data = !null ;销毁data, 清空内存
 end

获取hdf4 数据集中的属性

输入:
1.数据地址
2.数据集名称
3.数据集中目标属性名称
得到:
目标属性名称

function hdf4_attdata_get,file_name,sds_name,att_name
  sd_id=hdf_sd_start(file_name,/read)
  sds_index=hdf_sd_nametoindex(sd_id,sds_name)
  sds_id=hdf_sd_select(sd_id,sds_index)
  att_index=hdf_sd_attrfind(sds_id,att_name)
  hdf_sd_attrinfo,sds_id,att_index,data=att_data
  hdf_sd_endaccess,sds_id
  hdf_sd_end,sd_id
  return,att_data
end

获取 hdf4 中数据集 并进行修正

输入:
1.数据地址
2.数据集名称
得到:
修正后的数据集数据

function hdf4_real_data,sd,sds_gindex ;输入file_list[file_i],数据
;输入数据地址,数据集名称,得到 真实数据
  sd_id = hdf_sd_start(sd,/read)
  sds_index = hdf_sd_nametoindex(sd_id, sds_gindex)
  sds_id = hdf_sd_select(sd_id,sds_index)
  hdf_sd_getdata, sds_id, data
  
  index = hdf_sd_attrfind(sds_id, 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值