;+ ; NAME fts2jpg_cp.pro ; ; PURPOSE Display an SMM C/P FITS image. ; ; SYNTAX fts2jpg_cp, fits_image, cm='colormap.lut', wmin=0, wmax=5e-9 ; ; fits_image filename of SMM C/P FITS image. ; gif write displayed image as a GIF file. ; cm pathname of ASCII colormap file. ; Each line has the syntax: index red green blue ; where index = 0, 1, 2, ... 255, ; and red/green/blue are in the range [0:255]. ; wmin display minimum value. ; wmax display maximum value. ; ; EXAMPLES fts2jpg_cp, '19981101.1234.mk3.cpb.fts' ; fts2jpg_cp, '19981101.1234.mk3.rpb.fts', $ ; cm='/home/stanger/color/bwy.lut' ; fts2jpg_cp, '19981101.1234.mk3.rpb.fts', wmax=1.e-9 ; ; EXTERNAL ; PROCEDURES fits_annotate.pro ; ; HISTORY Andrew L. Stanger HAO/NCAR 19 January 2006 ;- PRO fts2jpg_cp2, fits_name, cm=cm, wmin=wmin, wmax=wmax black = 0 ; --- Load color map. IF (KEYWORD_SET (cm)) THEN $ lct, cm $ ELSE $ lct, '/home/stanger/color/quallab.lut' ; Load default color table. rtab = BYTARR (256) gtab = BYTARR (256) btab = BYTARR (256) TVLCT, rtab, gtab, btab, /GET ; Fetch RGB color look-up tables. month_name = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', $ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] ; --- Set character font size. cwidth = 8 cheight = FIX ((cwidth * 1.5) + 0.5) ; --- Define annotation borders: left & bottom. ;xb = 160 ;yb = 88 xb = 152 ; Left border width yb = 64 ; Bottom border height xdim_prev = 0 ydim_prev = 0 dispmin = 0.0 dispmax = 0.0 ; --- Extract "base name" for optional output file. ftspos = STRPOS (fits_name, '.fts') basename = STRMID (fits_name, 0, ftspos) print, 'basename: ', basename ;--- Read FITS image header & pixel data. img = readfits (fits_name, hdu) ; --- Read housekeeping extension. hk = readfits (fits_name, hdu_hk, exten_no=1) ;--- Extract information from header. xdim = fxpar (hdu, 'NAXIS1') ydim = fxpar (hdu, 'NAXIS2') xcen = fxpar (hdu, 'CRPIX1') ycen = fxpar (hdu, 'CRPIX2') oxdim = xdim + xb oydim = ydim + yb ;--- Resize window [if image size has changed]. SET_PLOT, 'X' ; window, xs=10, ys=10 ; if (xdim NE xdim_prev OR ydim NE ydim_prev) THEN $ ; WINDOW, xsize=oxdim, ys=oydim, RETAIN=2 SET_PLOT, 'Z' DEVICE, set_resolution = [oxdim, oydim], set_colors=256, z_buffering = 0 DEVICE, SET_CHARACTER_SIZE = [cwidth, cheight] ; Set character size. print, 'oxdim/oydim: ', oxdim, oydim xdim_prev = xdim ydim_prev = ydim ;--- Get information from FITS header. type_obs = fxpar (hdu, 'TYPE-OBS') telescop = fxpar (hdu, 'TELESCOP') instrume = fxpar (hdu, 'INSTRUME') dateobs = fxpar (hdu, 'DATE-OBS') timeobs = fxpar (hdu, 'TIME-OBS') datamin = fxpar (hdu, 'DATAMIN', count=cdatamin) datamax = fxpar (hdu, 'DATAMAX', count=cdatamax) dispmin = fxpar (hdu, 'DISPMIN', count=cdispmin) dispmax = fxpar (hdu, 'DISPMAX', count=cdispmax) crradius = fxpar (hdu, 'CRRADIUS') radius_occ = FIX (crradius * 1.5 + 0.5) ; Occulting disc radius. imin = MIN (img, max=imax) print, 'imin/imax: ', imin, imax ;--- "Erase" left annotation area. winleft = BYTARR (xb, ydim) winleft [*, *] = 255 TV, winleft, 0, yb ;--- "Erase" bottom annotation area. winbottom = BYTARR (xb + xdim, yb) winbottom [*, *] = 255 TV, winbottom, 0, 0 ;--- Determine min/max intensity levels to display. dmin = datamin dmax = datamax IF (dispmin NE dispmax) THEN $ BEGIN dmin = dispmin dmax = dispmax END IF (KEYWORD_SET (wmin)) THEN dmin = wmin IF (KEYWORD_SET (wmax)) THEN dmax = wmax print, 'fts2jpg_cp> dmin/dmax: ', dmin, dmax ;--- Fill occulting disc with black. imgbyt = BYTSCL (img, min=dispmin, max=dispmax, top=249) circfill, imgbyt, xdim, ydim, xcen, ycen, radius_occ, black ;--- Display image. ; TV, BYTSCL (img, min=dispmin, max=dispmax, top=249), xb, yb TV, imgbyt, xb, yb ;--- Annotate image. fits_annotate_cp2, hdu, hdu_hk, xdim, ydim, xb, yb, wmin=dmin, wmax=dmax ;--- Create JPEG image [24 bits/pixel]. byt_img = TVRD () jpg_img = BYTARR (3, oxdim, oydim) jpg_img [0, *, *] = rtab [byt_img [*, *]] jpg_img [1, *, *] = gtab [byt_img [*, *]] jpg_img [2, *, *] = btab [byt_img [*, *]] ;--- Write displayed image as a JPG file. jpg_file = basename + '.jpg' WRITE_JPEG, jpg_file, jpg_img, true=1, quality=75 ; Write jpg file. gif_file = basename + '.gif' write_gif, gif_file, byt_img, rtab, gtab, btab END