【IDL代码库】IDL实现MODIS数据云检测(气溶胶系统)

一、介绍

系统采用的云检测算法是多光谱综合去云法。该算法从可见光反射率、红外波段亮温值以及亮温差等方面综合考虑,逐步建立一个云检测掩膜。对于预测的MODIS数据必须是经过了辐射定标的,热辐射强度转换成了亮温的。多光谱综合去云算法用到的波段以及算法流程见下图。


二、IDL源码

;+

;:Description:

;    Describe the procedure.

;

;:Author: tiands@esrichina.com.cn

;

;:Date: 2013-9-5 11:10:27

;-

;;=======================================================================

 ;;;  该程序对几何校正后的科学数据进行去除云处理

 ;;;======================================================================

 PRO MODIS_CLOUD,filename,out_name,outname_cloud

  COMPILE_OPT idl2

  ENVI, /RESTORE_BASE_SAVE_FILES

  ENVI_BATCH_INIT, LOG_FILE = 'batch_log.txt'

   ;  filename='C:\Users\tiandeshan\Desktop\idl\scaledata.img'

   ;  out_name='C:\Users\tiandeshan\Desktop\idl\scaledata_cloud.img'

  ;数据读取

  IF (ENVI_IS_GDB(filename)) THEN BEGIN

    ENVI_OPEN_GDB,filename,r_fid=data_fid

  ENDIF ELSE BEGIN

    ENVI_OPEN_FILE,filename,r_fid=data_fid

  ENDELSE   

  ;envi_open_file, filename, r_fid=data_fid 

  ENVI_FILE_QUERY, data_fid, dims=dims, nb=nb,ns=ns,nl=nl,data_type =data_type

  data = MAKE_ARRAY(ns,nl,nb,type=data_type)

  FOR i=0,nb-1 DO BEGIN

    data[*,*,i]=ENVI_GET_DATA(fid=data_fid,pos=i,dims=dims)

  ENDFOR

  ;不同波段不同条件多次判断出各种云

  cloud_1=data[*,*,0] GT 0.3

  cloud_2=data[*,*,8] GT 0.008 AND [data[*,*,9]-data[*,*,10]] GT -0.012

  cloud_3=data[*,*,8] GT 0.02 AND data[*,*,0] LE 0.2

  cloud_4=data[*,*,8] LT 0.02 AND data[*,*,0] GT 0.2

  cloud_5=data[*,*,6] GT 0.17 AND (-0.0009) LT (data[*,*,0]-data[*,*,4])/(data[*,*,0]+data[*,*,4]) LT 0.002 AND data[*,*,0] GT 0.2

  cloud_all=cloud_1 OR cloud_2 OR cloud_3 OR cloud_4 OR cloud_5

  cloud_data=(cloud_all EQ 0)*1

  map_info=ENVI_GET_MAP_INFO(fid=data_fid)

  ENVI_WRITE_ENVI_FILE, cloud_data,r_fid=mask_fid,out_name=outname_cloud,map_info=map_info

  CLOUD_MASK,data_fid,mask_fid,out_name

  ENVI_BATCH_EXIT

 END

 

 PRO CLOUD_MASK,data_fid,mask_fid,out_name

  COMPILE_OPT IDL2

  ENVI_FILE_QUERY,data_fid,nb=nb,dims=dims

  pos = [0,1,2,3,4,5,7,10,11]

  m_pos = [0]

  ;判断是否传入了out_name

  IF (not KEYWORD_SET(out_name)) THEN BEGIN

    IN_MEMORY=1

  ENDIF ELSE BEGIN

    IN_MEMORY=0

  ENDELSE

  OUT_BNAME=['cloud_mask(1KM Reflectance (band1) [250 Aggr])','cloud_mask(1KM Reflectance (band2) [250 Aggr])',$

    'cloud_mask(1KM Reflectance (band3) [500 Aggr])','cloud_mask(1KM Reflectance (band4) [500 Aggr])','cloud_mask(1KM Reflectance (band6)[500 Aggr]',$

    'cloud_mask(1KM Reflectance (band7)[500 Aggr]','cloud_mask(1KM Reflectance (band19))',$

    'cloud_mask(1KM Emissive (band31))','cloud_mask(1KM Emissive (band32))']

  ENVI_MASK_APPLY_DOIT, FID = data_fid, POS = pos, DIMS = dims, $

  

    M_FID = mask_fid, M_POS = m_pos, VALUE =0, $

    out_bname=OUT_BNAME,$

    IN_MEMORY = IN_MEMORY, R_FID =m_fid , OUT_NAME = out_name

 END

posted @ 2022-05-27 12:29  ENVI-IDL技术殿堂  阅读(777)  评论(0编辑  收藏  举报