PRO imgcateg,paths,filtlist,typelist,texplist ; Set up OS-specific details @isitdos ; Make sure supplied array of paths is legitimate. fsize=SIZE(paths) IF fsize(0) GT 0 THEN BEGIN ; Truncate input array string lengths as needed to simplify ; file name extraction pathslen=StrLen(paths) pmin=0 pmax=0 ; What lengths do the available paths have? phist=Histogram(pathslen,OMIN=pmin,OMAX=pmax) ; For each length, truncate the paths with this length files=paths FOR i=pmin,pmax DO BEGIN wp=Where(pathslen EQ i,nwp) IF nwp GT 0 THEN files(wp)=StrMid(paths(wp),i-pmin,pmin) ENDFOR ; Now extract the last 12 characters of each path to get file names files=StrMid(files,pmin-12,12) fc=StrMid(files,0,1) ; extract only first characters filt=StrMid(files,4,1) ; extract filter numbers texp=StrMid(files,5,3) ; extract exposure times ; Correct entries for cases where no image found wno=Where(StrPos(files,'___') NE -1,nwno) IF nwno GT 0 THEN BEGIN fc(wno)='_' filt(wno)='-1' texp(wno)='-1' ENDIF ; Make output array dimensions match the input dimensions ; Default entry is -1 => no image found CASE fsize(0) OF 1: typelist=IntArr(fsize(1))-1 2: typelist=IntArr(fsize(1),fsize(2))-1 ENDCASE ; Store the image type codes in typelist FOR i=0,N_Elements(firstchars)-1 DO BEGIN wfc=Where(StrUpCase(fc) EQ StrUpCase(firstchars(i)),nwfc) IF nwfc GT 0 THEN typelist(wfc)=i ENDFOR ; Store the filter numbers in filtlist filtlist=FIX(filt) ; Store the exposure times in texplist texplist=FIX(texp) ENDIF ELSE BEGIN ; Warn the user that the input was degenerate MESSAGE,'"paths" must be at least a 1-d array',/INFORMATIONAL filtlist=-1 typelist=-1 texplist=-1 ENDELSE RETURN END