;+ ; NAME gif2srf.pro ; ; PURPOSE Convert GIF images to Sun Rasterfile format. ; ; SYNTAX gif2srf, 'giflist' ; ; HISTORY Andrew L. Stanger HAO/NCAR 21 January 2000 ;- pro gif2srf, gif_list smonth = strarr (12) smonth [0] = 'Jan' smonth [1] = 'Feb' smonth [2] = 'Mar' smonth [3] = 'Apr' smonth [4] = 'May' smonth [5] = 'Jun' smonth [6] = 'Jul' smonth [7] = 'Aug' smonth [8] = 'Sep' smonth [9] = 'Oct' smonth [10] = 'Nov' smonth [11] = 'Dec' red = bindgen (256) green = red blue = red gif_name = '' ;lct,'/home/stanger/color/bwy.lut' ; color table. ;tvlct, red, green, blue, /get ;--- File list loop. loop = 0 CLOSE, 1 OPENR, 1, gif_list WHILE (NOT EOF (1)) DO $ BEGIN ;{ loop = loop + 1 ;--- Read GIF image. READF, 1, gif_name ; Get file name. print, 'gif_name: ', gif_name READ_GIF, gif_name, gif_img, red, green, blue ; Read GIF image. new_img = reverse (gif_img, 2) ;--- Find dimensions of image. ;--- Set label location as 10% up and centered horizontally. sizimg = size (gif_img) xdim = sizimg [1] ydim = sizimg [2] xloc = xdim / 2 yloc = ydim / 20 print, 'xloc, yloc: ', xloc, yloc IF (loop EQ 1) THEN $ BEGIN window, xsize=xdim, ysize=ydim tvlct, red, green, blue ; Write color map. END ;--- Find intensity min/max. GIF_min = MIN (gif_img, max=gif_max) print, FORMAT = '("gif_min/max: ", E10.3, E10.3)', gif_min, gif_max ;--- Compute square root of image. ; new_img = sqrt (gif_img) ; Compute square root. ; new_min = min (new_img, max=new_max) ; Get image min/max. ; print, FORMAT = '("new_min/max: ", E10.3, E10.3)', new_min, new_max ; IF (new_min LT 0.0) THEN $ ; Symmetric about zero. ; IF (-new_min LT new_max) THEN new_min = -new_max ELSE new_max = -new_min ; print, FORMAT = '("new_min/max: ", E10.3, E10.3)', new_min, new_max ; new_min = -5.00e-8 ; new_max = 5.00e-8 ; print, FORMAT = '("new_min/max: ", E10.3, E10.3)', new_min, new_max ;--- Convert to byte pixels. ;--- Display image. ; byt_img = bytscl (new_img, min=new_min, max=new_max, top=249) ; tv, byt_img ; Display image. tv, gif_img ; year = strmid (gif_name, 0, 2) ; month = strmid (gif_name, 2, 2) ; day = strmid (gif_name, 4, 2) ; hour = strmid (gif_name, 7, 2) ; minute = strmid (gif_name, 9, 2) ; second = strmid (gif_name, 11, 2) ; monthname = smonth [fix (month) - 1] ; date = day + ' ' + monthname + ' ' + '19' + year ; time = hour + ':' + minute + ':' + second + ' ' + 'UT' ; datetime = date + ' ' + time ; print, 'date: ', date ; print, 'time: ', time ; print, 'datetime: ', datetime ; xyouts, xloc, yloc, datetime, charthick=2.0, /device, alignment=0.5 ; new_img = tvrd () ;--- Write newference image to disk. sloc = RSTRPOS (gif_name, '.gif') new_name = strmid (gif_name, 0, sloc) + '.sun' print, 'Write output image : ', new_name write_srf, new_name, new_img, red, green, blue ; Write new image. END ;} CLOSE, 1 END