;+ ; NAME fvp.pro ; ; PURPOSE Display a FITS image & report cursor position. ; ; SYNTAX fvp, fits_image, /gif, cm='colormap.lut', wmin=1, wmax=240 ; ; fits_image filename of Spartan WLC 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. ; nolabel If set, do NOT display the position # label. ; ; EXAMPLES fvp, '19981101.1234.mk3.cpb.fts' ; fvp, '19981101.1234.mk3.rpb.fts',cm='/home/stanger/color/bwy.lut' ; fvp, '19981101.1234.mk3.rpb.fts', /gif ; ; EXTERNAL ; PROCEDURES ; readfits read FITS image ; headfits read FITS header ; fxpar read FITS keyword parameter ; fitsdispw ; fits_annotatew.pro ; mouse_pos_lab.pro ; pos_lab_time.pro position/label/time procedure ; ; HISTORY Andrew L. Stanger HAO/NCAR 14 September 2001 ; 26 Sep 2001: [ALS] Add cursor position. ; 17 Oct 2001: [ALS] If "CRRADIUS" not present, use "SOLAR_R". ; 14 Jan 2003: [ALS] Reverse roll direction for mouse_pos_lab. ; 19 Sep 2003: [ALS] disp_label option added. ; 7 Oct 2004: [ALS] Replace mouse_pos_lab with pos_lab_time.pro. ;- PRO fvp, fits_name, gif=gif, cm=cm, wmin=wmin, wmax=wmax, text=text, $ nolabel=nolabel disp_label = 1 ; Set display label option variable. ;--- Load color table. IF (KEYWORD_SET (cm)) THEN $ BEGIN PRINT, 'cm: ', cm dirend = -1 FOR i = 0, strlen (cm) - 1 DO $ BEGIN dirloc = STRPOS (cm, '/', i) IF (dirloc GE 0) THEN dirend = dirloc END IF (dirend NE -1) THEN $ BEGIN PRINT, 'dirend: ', dirend coldir = STRMID (cm, 0, dirend) PRINT, 'coldir: ', coldir ccm = STRMID (cm, dirend+1, strlen (cm) - dirend - 1) PRINT, 'ccm: ', ccm END IF (dirend EQ -1) THEN $ lct, '/home/cordyn/color/' + cm + '.lut' $ ELSE $ lct, cm ; Load specified colormap. END $ ELSE lct, '/home/cordyn/color/quallab.lut' ; Load greyscale colormap. red = bytarr (256) green = bytarr (256) blue = bytarr (256) tvlct, red, green, blue, /GET ; Fetch RGB color look-up tables. xb = 160 yb = 0 xdim_prev = 0 ydim_prev = 0 ;--- Read FITS image header & pixel data. ftspos = STRPOS (fits_name, '.fts') basename = STRMID (fits_name, 0, ftspos) print, 'basename: ', basename IF (KEYWORD_SET (text)) THEN $ BEGIN pfile = basename + '.pos' CLOSE, 21 OPENW, 21, pfile PRINTF, 21, fits_name, ' Position Measurement[s]' CLOSE, 21 END img = readfits (fits_name, hdu) ;--- Extract information from header. xdim = fxpar (hdu, 'NAXIS1') ydim = fxpar (hdu, 'NAXIS2') ;--- Resize window [if image size has changed]. if (xdim NE xdim_prev OR ydim NE ydim_prev) THEN $ WINDOW, xsize=xdim+xb, ys=ydim+yb, retain=2 print, 'xdim + xb: ', xdim + xb print, 'ydim + yb: ', ydim + yb xdim_prev = xdim ydim_prev = ydim ;--- Annotate image. fits_annotatew, hdu, xdim, ydim, xb, yb ;--- Get information from FITS header. orbit_id = fxpar (hdu, 'ORBIT-ID') image_id = fxpar (hdu, 'IMAGE-ID') telescop = fxpar (hdu, 'TELESCOP') instrume = fxpar (hdu, 'INSTRUME') dateobs = fxpar (hdu, 'DATE-OBS') timeobs = fxpar (hdu, 'TIME-OBS') type_obs = fxpar (hdu, 'TYPE-OBS') dataform = fxpar (hdu, 'DATAFORM') rsun = fxpar (hdu, 'RSUN') srsun = STRING (rsun, FORMAT='(F7.2)') bunit = fxpar (hdu, 'BUNIT') datamin = fxpar (hdu, 'DATAMIN') datamax = fxpar (hdu, 'DATAMAX') dispmin = fxpar (hdu, 'DISPMIN') dispmax = fxpar (hdu, 'DISPMAX') crradius = fxpar (hdu, 'CRRADIUS', count=count_crradius) print, 'count_crradius: ', count_crradius, ' crradius: ', crradius solar_r = fxpar (hdu, 'SOLAR_R', count=count_solar_r) IF (count_crradius EQ 1) THEN $ pixrs = crradius $ ELSE $ IF (count_solar_r EQ 1) THEN $ pixrs = solar_r ; print, 'count_crradius: ', crradius, ' count_solar_r: ', count_solar_r ; print, 'crradius: ', crradius ; print, 'solar_r : ', solar_r ; print, 'pixrs : ', pixrs xcen = fxpar (hdu, 'CRPIX1') + xb ycen = fxpar (hdu, 'CRPIX2') + yb roll = fxpar (hdu, 'CROTA1') revroll = -roll ; telescop = STRTRIM (telescop, 2) ; IF (telescop NE 'SPARTAN 201' AND instrume NE 'WLC') THEN $ ; BEGIN ; PRINT, 'TELESCOP: ', telescop, ' should be "SPARTAN 201".' ; PRINT, 'INSTRUME: ', instrume, ' should be "WLC".' ; RETURN ; END ;--- Display image. dmin = dispmin dmax = dispmax ; IF (KEYWORD_SET (wmin) OR wmin EQ 0.0) THEN dmin = wmin IF (KEYWORD_SET (wmin)) THEN dmin = wmin IF (KEYWORD_SET (wmax)) THEN dmax = wmax ; TV, BYTSCL (img, min=dispmin, max=dispmax, top=249), xb, yb fitsdispw, fits_name, xdim_prev, ydim_prev, gif=gif, wmin=wmin, wmax=wmax, $ xb, yb IF (KEYWORD_SET (nolabel)) THEN $ pos_lab_time, fits_name, xdim, ydim, xcen, ycen, pixrs, revroll, $ pos=1, pfile=pfile $ ELSE $ pos_lab_time, fits_name, xdim, ydim, xcen, ycen, pixrs, revroll, $ pos=1, pfile=pfile, /disp_label ;--- Write displayed image as a GIF file (if "gif" keyword is set). IF (KEYWORD_SET (gif)) THEN $ BEGIN gif_file = basename + '.gif' img_gif = TVRD () WRITE_GIF, gif_file, img_gif, red, green, blue END END