pro writefit, image, fname, notes=notes, obs=obs, inst=inst, tele=tele, obj=obj, date=date, filter=filter, $ itype=itype, expo=expo, xbin=xbin, ybin=ybin, xmic=xmic, ymic=ymic, antime=antime, anframe=anframe, $ focal=focal, diam=diam, help=help IF KEYWORD_SET(help) THEN BEGIN PRINT,'pro writefit, image, fname, notes=notes, obs=obs, inst=inst, tele=tele, obj=obj, date=date, filter=filter, $ PRINT,' itype=itype, expo=expo, xbin=xbin, ybin=ybin, xmic=xmic, ymic=ymic, antime=antime, anframe=anframe, $ PRINT,' focal=focal, diam=diam, help=help PRINT,' PRINT,' This procedure saves to a file caled in the MaximDL style FITS format. PRINT,'The header can contain optional information as below. PRINT,' PRINT,'USAGE: writefit, image, fname, obs="Dr. Rob Suggs", antime=times, anframe=100 PRINT,'HELP: writefit,/help Prints these notes PRINT,' PRINT,'Parameters: PRINT,' image 2-dimensional array of almost any type but string. Default = indgen(150,100)+100 PRINT,' fname String, name of FITS file to be written. Default = WriteFit.fit PRINT,' PRINT,' --- Optional --- PRINT,'notes String of length <69 char. Longer will be truncated. PRINT,'obs String of length <69 char. Longer will be truncated. (observer name) PRINT,'inst String of length <69 char. Longer will be truncated. (camera name) PRINT,'tele String of length <27 char. Longer will be truncated. (telescope name) PRINT,'obj String of length <69 char. Longer will be truncated. ( object name) PRINT,'date YYYY-MM-DDThh:mm:ss observation start, UT See below PRINT,'filter String of length <27 char. Longer will be truncated. (filter name) PRINT,'itype String of length <27 char. Longer will be truncated. (light, dark, flat) PRINT,'expo Scalar length of exposure in seconds PRINT,'xbin Integer, Binning factor in width PRINT,'ybin Integer, Binning factor in height PRINT,'xmic Scalar, Pixel Width in microns (after binning) PRINT,'ymic Scalar, Pixel height in microns (after binning) PRINT,'Focal Focal lenght, mm PRINT,'diam Aperture in mm PRINT,'antime Structure, frame time from Boulder Imaging AN file. If array, anframe is required PRINT,'anframe Integer, Frame number for antime. If absent and required, 0 is assumed PRINT,' RETURN ENDIF ; help IF N_ELEMENTS(image) LT 10 THEN image = indgen(150,100)+100 IF N_ELEMENTS(fname) EQ 0 THEN fname = 'WriteFit.fit' IF N_ELEMENTS(anframe) EQ 0 AND N_ELEMENTS(antime) GT 1 THEN BEGIN anframe = 0 PRINT,'WriteFit: WARNING, anframe assumed zero, start time will be for frame 0' ENDIF s = SIZE(image) naxis = S(0) naxis = STRING(naxis, FORMAT='(A20)') naxis1 = S(1) naxis1 = STRING(naxis1, FORMAT='(A20)') IF naxis GE 2 THEN naxis2 = S(2) ELSE naxis2 = 0 naxis2 = STRING(naxis2, FORMAT='(A20)') CASE S(naxis+1) OF 1: bitpix = 8 2: bitpix = 16 3: bitpix = 32 4: bitpix = -32 5: bitpix = -64 12: bitpix = 16 13: bitpix = 32 14: bitpix = 64 15: bitpix = 64 ELSE: bitpix = 0 ENDCASE bitpix = STRING(bitpix, FORMAT='(A20)') cblack = FIX(MIN(image)) cblack = STRING(cblack, FORMAT='(A20)') cwhite = FIX(MAX(image)) cwhite = STRING(cwhite, FORMAT='(A20)') header = [$ 'SIMPLE = T ', $ ; 0 'BITPIX = '+bitpix+' /8 unsigned int, 16 & 32 int, -32 & -64 real ', $ ; 1 'NAXIS = '+naxis+' /number of axes ', $ ; 2 'NAXIS1 = '+naxis1+' /fastest changing axis ', $ ; 3 'NAXIS2 = '+naxis2+' /next to fastest changing axis ', $ ; 4 'BSCALE = 1.0000000000000000 /physical = BZERO + BSCALE*array_value ', $ ; 5 'BZERO = 0.0000000000000000 /physical = BZERO + BSCALE*array_value ', $ ; 6 'OBJECT = ', $ ; 7 'TELESCOP= /telescope used to acquire this image ', $ ; 8 'INSTRUME= ', $ ; 9 'OBSERVER= ', $ ;10 'NOTES = ', $ ;11 'DATE-OBS= / YYYY-MM-DDThh:mm:ss observation start, UT', $ ;12 'EXPTIME = 0.0000000000000000 /Exposure time in seconds ', $ ;13 'EXPOSURE= 0.0000000000000000 /Exposure time in seconds ', $ ;14 'SET-TEMP= 0.0000000000000000 /CCD temperature setpoint in C ', $ ;15 'CCD-TEMP= 0.0000000000000000 /CCD temperature at start of exposure in C ', $ ;16 'XPIXSZ = 0.0000000000000000 /Pixel Width in microns (after binning) ', $ ;17 'YPIXSZ = 0.0000000000000000 /Pixel Height in microns (after binning) ', $ ;18 'XBINNING= 1 /Binning factor in width ', $ ;19 'YBINNING= 1 /Binning factor in height ', $ ;20 'XORGSUBF= 0 /Subframe X position in binned pixels ', $ ;21 'YORGSUBF= 0 /Subframe Y position in binned pixels ', $ ;22 'FILTER = /Filter used when taking image ', $ ;23 'IMAGETYP= /Type of image ', $ ;24 'FOCALLEN= 0.00000000000000000 /Focal length of telescope in mm ', $ ;25 'APTDIA = 0.00000000000000000 /Aperture diameter of telescope in mm ', $ ;26 'APTAREA = 0.00000000000000000 /Aperture area of telescope in mm^2 ', $ ;27 'SWCREATE= "IDL WriteFit by W swift"/Name of software that created the image ', $ ;28 'SBSTDVER= "SBFITSEXT Version 1.0" /Version of SBFITSEXT standard in effect ', $ ;29 'FLIPSTAT= ', $ ;30 'CBLACK = '+cblack+' /Initial display black level in ADUs ', $ ;31 'CWHITE = '+cwhite+' /Initial display white level in ADUs ', $ ;32 'PEDESTAL= 0 /Correction to add for zero-based ADU ', $ ;33 'SWOWNER = "NASA / MSFC EV44" / Licensed owner of software ', $ ;34 'END '] ;35 IF cwhite GE 32768 THEN BEGIN ; to fit into signed integer tmp = header(6) STRPUT, tmp, STRING(32768.0), 11 header(6) = tmp image = image - 32668 ENDIF IF KEYWORD_SET(notes) THEN BEGIN tmp = header(11) STRPUT, tmp, notes, 11 header(11) = tmp ENDIF IF KEYWORD_SET(obs) THEN BEGIN tmp = header(10) STRPUT, tmp, obs, 11 header(10) = tmp ENDIF IF KEYWORD_SET(inst) THEN BEGIN tmp = header(9) STRPUT, tmp, inst, 11 header(9) = tmp ENDIF IF KEYWORD_SET(tele) THEN BEGIN tmp = header(8) tele = STRTRIM(STRING(tele, FORMAT='(A26)'),2) STRPUT, tmp, tele, 10 header(8) = tmp ENDIF IF KEYWORD_SET(obj) THEN BEGIN tmp = header(7) STRPUT, tmp, obj, 11 header(7) = tmp ENDIF IF KEYWORD_SET(date) THEN BEGIN tmp = header(12) date = STRTRIM(STRING(date, FORMAT='(A26)'),2) STRPUT, tmp, date, 10 header(12) = tmp ENDIF IF KEYWORD_SET(filter) THEN BEGIN tmp = header(23) filter = STRTRIM(STRING(filter, FORMAT='(A26)'),2) STRPUT, tmp, filter, 10 header(23) = tmp ENDIF IF KEYWORD_SET(expo) THEN BEGIN expo = STRING(expo, FORMAT='(A20)') tmp = header(13) STRPUT, tmp, expo, 10 header(13) = tmp tmp = header(14) STRPUT, tmp, expo, 10 header(14) = tmp ENDIF IF KEYWORD_SET(itype) THEN BEGIN tmp = header(24) itype = STRING(itype, FORMAT='(A26)') STRPUT, tmp, itype, 10 header(24) = tmp ENDIF IF KEYWORD_SET(xmic) THEN BEGIN tmp = header(17) xmic = STRING(xmic, FORMAT='(A20)') STRPUT, tmp, xmic, 10 header(17) = tmp ENDIF IF KEYWORD_SET(ymic) THEN BEGIN tmp = header(18) ymic = STRING(ymic, FORMAT='(A20)') STRPUT, tmp, ymic, 10 header(18) = tmp ENDIF IF KEYWORD_SET(xbin) THEN BEGIN tmp = header(19) xbin = STRING(xbin, FORMAT='(A20)') STRPUT, tmp, xbin, 10 header(19) = tmp ENDIF IF KEYWORD_SET(ybin) THEN BEGIN tmp = header(20) ybin = STRING(ybin, FORMAT='(A20)') STRPUT, tmp, ybin, 10 header(20) = tmp ENDIF IF KEYWORD_SET(focal) THEN BEGIN tmp = header(25) focal = STRING(focal, FORMAT='(A20)') STRPUT, tmp, focal, 10 header(25) = tmp ENDIF IF KEYWORD_SET(diam) THEN BEGIN tmp = header(26) diam = STRING(diam, FORMAT='(A20)') STRPUT, tmp, diam, 10 header(26) = tmp ENDIF ;IF KEYWORD_SET(gain) THEN BEGIN ; tmp = header(33) ; gain = STRING(gain, FORMAT='(A20)') ; STRPUT, tmp, gain, 10 ; header(33) = tmp ;ENDIF IF KEYWORD_SET(antime) THEN BEGIN IF N_ELEMENTS(antime) GT 1 THEN BEGIN ansave = antime antime = antime(anframe) ENDIF date=STRTRIM(antime.year,2)+'-'+STRTRIM(antime.month,2)+'-'+STRTRIM(antime.day,2)+' ' sec = antime.sec + antime.msec/1000.0 + antime.usec/1.0e6 time = STRTRIM(antime.hr,2)+':'+STRTRIM(antime.minute,2)+':'+STRING(sec,FORMAT='(f9.6)') tmp = header(12) date = STRTRIM(STRING(date+time, FORMAT='(A26)'),2) STRPUT, tmp, date, 10 header(12) = tmp IF N_ELEMENTS(ansave) NE 0 THEN antime=ansave ENDIF ON_IOERROR, ioerror OPENW, lun, fname, /GET_LUN WRITEU, lun, BYTE(header) WRITEU, lun, SWAP_ENDIAN(REVERSE(image,2)) CLOSE, lun GOTO, done ioerror: PRINT, 'WriteFit: '+!ERR_STRING done: IF N_ELEMENTS(lun) NE 0 THEN FREE_LUN, lun END ; pro writefit, image, fname