;+ ; IDL PROCEDURE ; ; NAME: ; xinfts ; ; PURPOSE: ; Animate a sequence of FITS images. ; ; CALLING SEQUENCE: ; xinfts, 'fits.ls' ; xinfts, 'fits.ls', rate=25 ; xinfts, 'fits.ls', rate=8, /label ; xinfts, 'fits.ls', rate=2, /label, cm='~/color/sunset.lut' ; xinfts, 'fits.ls', wmin=-1200, wmax=600 ; ; INPUTS: ; listfile : Character string containing the names of the FITS ; files to be animated. ; rate : Animation rate (range: 0-100). ; label: If present, label each image with frame #, date, time. ; cm: Name of color map file (ASCII, each line: index, red, green, blue). ; order: If set, image is displayed top to bottom; ; default is bottom to top. ; wmin: window minimum intensity scaling value (overrides 'DISPMIN'). ; wmax: window maximum intensity scaling value (overrides 'DISPMAX'). ; ; OUTPUTS: ; none ; ; PROCEDURES USED: ; READFITS ; FXPAR ; XINTERANIMATE ; LCT ; ; MODIFICATION HISTORY: ; 7 Aug 1995: procedure created by Andrew L. Stanger, HAO/NCAR ; 11 Aug 1995: added order keyword, ALS, HAO/NCAR ; 11 Mar 1996: reduce image size if image is larger than 1000x1000. ; 14 Apr 1998: replaced "readfits" with "fxread", since "readfits" ; did not always apply 'BSCALE/BZERO' to MK3 FITS images. ; 14 Oct 1999: Fix label position: ypos = nypix - 20 --> ypos = ydim - 20 ; Move label to bottom of window. ; Increase label size for SunOS. ; 7 Apr 2000: Rotate image if CROTA1 is not zero. ; Also rotate PICS image if CROTA1 missing ; but SOLAR_P0 is present in FITS header. ; 20 Apr 2000: Do NOT rotate image IF 'DATAFORM'='POLAR'. ; 20 Apr 2000: Use either 'CRROTA1' and 'CROTA1' in PICS images. ; Note: CRROTA1 (incorrect spelling) was used for some ; cropped & rotated PICS images. ; 15 Nov 2000: Add min & max keywords so that user may set scaling. ;- pro xinfts, listfile, rate=rate, label=label, cm=cm, order=order, $ wmin=wmin, wmax=wmax if (not keyword_set (rate)) then rate = 100 labsiz = 1 IF (!version.os EQ 'SUNOS') THEN labsiz = 2 rotang = 0.0 filename = ' ' dataform = '' ii = 0 close, 10 openr, 10, listfile ;--- Find number of images in file list. while (not eof (10)) do begin ;{ readf, 10, filename ii = ii + 1 endwhile ;} numimg = ii close, 10 ;--- Read first image to get size information. fxread, filename, imgbuf, hdu ; Read first FITS image in listfile. nbitpx = fxpar (hdu, 'BITPIX') naxis = fxpar (hdu, 'NAXIS') nxpix = fxpar (hdu, 'NAXIS1') nypix = fxpar (hdu, 'NAXIS2') idate = fxpar (hdu, 'DATE-OBS') itime = fxpar (hdu, 'TIME-OBS') nxmax = 1000 nymax = 1000 xdim = nxpix ydim = nypix while (xdim gt nxmax or ydim gt nymax) do $ begin xdim = xdim / 2 ydim = ydim / 2 endwhile if (nbitpx eq 8) then imgbuf = bytarr (xdim, nypix) $ else if (nbitpx eq 16) then imgbuf = intarr (xdim, nypix) $ else if (nbitpx eq 32) then imgbuf = lonarr (xdim, nypix) $ else if (nbitpx eq -32) then imgbuf = fltarr (xdim, nypix) $ else if (nbitpx eq -64) then imgbuf = dblarr (xdim, nypix) $ else exit bkgbuf = intarr (xdim, ydim) bkgbuf (*, *) = 0 if (keyword_set (label)) then $ begin window, 20, xsize = xdim, ysize = ydim, color=256, /pixmap wset, 20 end ;--- Load color table. if (keyword_set (cm)) then lct, cm $ ; Load specified colormap. else loadct, 0 ; Load greyscale colormap. init = 'y' ; --- init can be set to 'n' once everything ; --- has been initialized, ; --- i.e. once this routine has been run once... if ( init eq 'y') then begin ;{ XINTERANIMATE, SET = [xdim+4, ydim+4, numimg], /SHOWLOAD close, 10 & openr, 10, listfile ;--- Image loop. ii = 0 while ( not eof (10) ) do begin ;{ readf, 10, filename ;--- Read image into array & scale intensity levels to range: 0-255. fxread, filename, imgbuf, hdu ; Read FITS image in listfile. dispmin = 0.0 dispmax = 0.0 wintop = 249 nbitpx = fxpar (hdu, 'BITPIX') naxis = fxpar (hdu, 'NAXIS') nxpix = fxpar (hdu, 'NAXIS1') nypix = fxpar (hdu, 'NAXIS2') dispmin = fxpar (hdu, 'DISPMIN') dispmax = fxpar (hdu, 'DISPMAX') telescop = fxpar (hdu, 'TELESCOP') crpix1 = fxpar (hdu, 'CRPIX1', COUNT=crpix1count) crpix2 = fxpar (hdu, 'CRPIX2', COUNT=crpix2count) crota1 = fxpar (hdu, 'CROTA1', COUNT=rotcount) crrota1 = fxpar (hdu, 'CRROTA1', COUNT=rrotcount) pangle = fxpar (hdu, 'SOLAR_P0', COUNT=pangcount) dataform = fxpar (hdu, 'DATAFORM', COUNT=dformcount) if (dformcount EQ 1) THEN $ dform = dataform $ else $ dform = 'NONE' ; print, 'rrotcount: ', rrotcount, ' crrota1 : ', crrota1 ; print, 'rotcount: ', rotcount, ' crota1 : ', crota1 ; print, 'pangcount: ', pangcount, ' solar_p0: ', pangle ; print, 'dataformcount: ', dformcount, ' dataform: ', dataform if (keyword_set (wmin)) then winmin = wmin else winmin = dispmin if (keyword_set (wmax)) then winmax = wmax else winmax = dispmax print, 'winmin/winmax: ', winmin, winmax dimfac = 1.0 nxmax = 1000 nymax = 1000 xdim = nxpix ydim = nypix while (xdim gt nxmax or ydim gt nymax) do $ begin dimfac = dimfac * 2.0 xdim = xdim / 2 ydim = ydim / 2 endwhile ;--- Reduce image size if xdim or ydim > 1000 pixels. if (nxpix ne xdim or ydim ne nypix) then $ imgbuf = rebin (imgbuf, xdim, ydim) ;--- Scale image to the range 0-249. if (nbitpx eq 8) then $ imgbuf = bytscl (imgbuf, top=wintop) $ else $ if (winmin lt winmax) then $ imgbuf = bytscl (imgbuf, min=winmin, max=winmax, top=wintop) $ else $ imgbuf = bytscl (imgbuf, top=wintop) ;--- If order keyword is set, reverse image top to bottom. if (keyword_set (order)) then imgbuf = reverse (imgbuf, 2) ;--- Rotate image (if needed). dpmpos = strpos (telescop, 'DPM') if (dpmpos GE 0 AND rotcount EQ 0 AND rrotcount EQ 0) THEN $ BEGIN if (pangcount EQ 1) THEN $ rotang = pangle $ ELSE $ BEGIN if (rrotcount EQ 1) THEN $ rotang = -crrota1 $ ELSE $ if (rotcount EQ 1) THEN $ rotang = -crota1 $ ELSE $ rotang = 0.0 END END ; print, 'rotang: ', rotang if (rotcount EQ 1) THEN $ BEGIN if (crota1 NE 0.0 AND strpos ('POLAR', dform) LT 0) THEN $ rotang = -crota1 $ ELSE $ rotang = 0.0 END mag = 1.0 IF (crpix1count EQ 1) THEN $ xcen = crpix1 / dimfac - 0.5 $ ELSE $ xcen = xdim / dimfac - 0.5 IF (crpix2count EQ 1) THEN $ ycen = crpix2 / dimfac - 0.5 $ ELSE $ ycen = ydim / dimfac - 0.5 arotang = abs (rotang) if (rotang GT 0.0) THEN rotdir = 'CW' ELSE rotdir = 'CCW' if (rotang NE 0.0) THEN $ BEGIN print, filename, ' rotated ', arotang, ' degrees ', rotdir imgbuf = ROT (imgbuf, rotang, mag, xcen, ycen, MISSING=0) END ;--- Label image if label keyword is set. if (keyword_set (label)) then $ begin idate = fxpar (hdu, 'DATE-OBS', count=count) sizdate = size (idate) if (count eq 0 or sizdate (1) lt 8) then idate = filename itime = fxpar (hdu, 'TIME-OBS', count=count) siztime = size (itime) if (count eq 0 or siztime (1) lt 8) then itime = '' xpos = 10 ypos = 10 sframe = string (ii, FORMAT = "(I3)") sframe = 'FRAME ' + sframe tv, imgbuf imglabel = sframe + ' ' + idate + ' ' + itime XYOUTS, xpos, ypos, imglabel, charsize=labsiz, /device XINTERANIMATE, FRAME = ii, WINDOW = !d.window ; Load image window. end $ else $ XINTERANIMATE, FRAME = ii, IMAGE = imgbuf ; Load image array. ii = ii+1 endwhile ;} close, 10 endif ;} wdelete, 20 ; Delete temp window. ;--- Activate animation. XINTERANIMATE, rate end