;+ ; c2dnbsun.pro IDL procedure ; ; PURPOSE ; Read a list of LASCO-C2 FITS images, convert DN to Bsun, ; and write a FITS file with a new name. ; ; SYNTAX ; c2dnbsun, 'fits_list' ; ; PROCEDURES USED ; rdfits ; writefits ; fxaddpar ; ; HISTORY ; Author: Andrew L. Stanger 16 September 1998 ;- pro c2dnbsun, fits_list dn_to_bsun = 3.825e-12 ; fits_name = '' ; Define FITS file name variable. new_name = '' CLOSE, 1 ;PRINT, 'fits_list: ', fits_list OPENR, 1, fits_list ; Open list file. ;--- File Loop : WHILE (NOT EOF (1)) DO $ ; File processing loop. BEGIN READF, 1, fits_name ; Read FITS file name from list file. PRINT, 'fits_name: ', fits_name img = rdfits (fits_name, header=hdu) ; Read FITS image & header. imin = MIN (img, max=imax) ; Find min/max pixel intensity range. ;--- Get keyword parameters from FITS header. xdim = fxpar (hdu, "NAXIS1") ydim = fxpar (hdu, "NAXIS2") bitpix = fxpar (hdu, "BITPIX") observat = fxpar (hdu, "OBSERVAT") date = fxpar (hdu, "DATE-OBS") time = fxpar (hdu, "TIME-OBS") detector = fxpar (hdu, "DETECTOR") exptime = fxpar (hdu, "EXPTIME") xsize = strtrim (string (xdim), 2) ; Convert to string w/o blanks. nbypx = bitpix / 8 IF (nbypx EQ 1) THEN pixtyp = "c" IF (nbypx EQ 2) THEN pixtyp = "s" IF (nbypx EQ 4) THEN pixtyp = "i" IF (nbypx EQ -4) THEN pixtyp = "f" IF (nbypx EQ -8) THEN pixtyp = "d" year = STRMID (date, 0, 4) month = STRMID (date, 5, 2) day = STRMID (date, 8, 2) date_img = year + month + day date_obs = day + '/' + month + '/' + year fxaddpar, hdu, 'DATE-OBS', date_obs, " DAY/MONTH/YEAR (UT)" hour = STRMID (time, 0, 2) minute = STRMID (time, 3, 2) second = STRMID (time, 6, 2) time_img = hour + minute + second inst = STRLOWCASE (STRMID (detector, 0, 2)) ; Convert DN to Bsun units. x_bin = 1024 / xdim ; Binning (pixel sum) factor for X-axis. y_bin = 1024 / ydim ; Binning (pixel sum) factor for X-axis. img = (img * dn_to_bsun) / (x_bin * y_bin * exptime) fmin = MIN (img, max=fmax) ; Find min/max pixel intensity range. print, 'fmin/fmax: ', fmin, fmax fxaddpar, hdu, 'DATAMIN', fmin, ' BSUN UNITS fxaddpar, hdu, 'DATAMAX', fmax, ' BSUN UNITS fxaddpar, hdu, 'DISPMIN', fmin, ' BSUN UNITS fxaddpar, hdu, 'DISPMAX', fmax, ' BSUN UNITS fxaddpar, hdu, 'BUNIT', 'BSUN', ' BSUN=AVERAGE SOLAR DISK BRIGHTNESS' ; new_name = inst + '.' + year + month + day + '.' $ ; + hour + minute + second + '.' + pixtyp + xsize + '.fts' new_name = inst + '.' + year + month + day + '.' $ + hour + minute + second + '.bsun.fts' new_name = STRTRIM (new_name, 2) ; Eliminate any blanks. fxaddpar, hdu, 'FILENAME', new_name PRINT, 'new_name: ', new_name ; -- Write FITS image to disk. writefits, new_name, img, hdu END CLOSE, 1 END