;***************************************************** ; Find the layers ;find_layer_idx,cutoff,mask_profile,idxb,idxt,numlayer ;***************************************************** pro find_layer_idx,nocloud,reflect_profile,idxs,idxe,numlayers ; Get the indexes of cloudy volumes result=where(reflect_profile gt nocloud,count) ; If this is a clear profile if count eq 0 then begin numlayers=0 idxs=-1 idxe=-1 ; If this is a cloudy profile endif else begin ; Start with the first layer base idxs=result[0] ; Loop through and get bases and tops j=0 for i=0,count-2 do begin if result[i+1] gt result[i]+1 then begin if j eq 0 then idxe=result[i] else idxe=[idxe,result[i]] idxs=[idxs,result[i+1]] j=j+1 endif endfor if j eq 0 then idxe=result[count-1] else idxe=[idxe,result[count-1]] ; Number of layers numlayers=n_elements(idxs) ;print,result ;print,idxs ;print,idxe endelse ;end of this is a cloudy profile return end