;+ ; lasco_rename.pro IDL procedure ; ; PURPOSE ; Read a list of LASCO FITS images, extract date, time, resolution, ; and write a FITS file with a new name (containing date & time). ; ; SYNTAX ; lasco_rename, 'fits_list' ; ; PROCEDURES USED ; rdfits ; writefits ; fxaddpar ; ; HISTORY ; Author: Andrew L. Stanger 19 August 1998 ; 16 Sep 1998: LASCO 'DATE-OBS' is reverse order from convention. ; It should be: day/month/year, not year/month/day. ; 8 Oct 2002: DATE-OBS='YYYY/DD/MM' (should be 'YYYY-MM-DD' ;- pro lasco_rename, fits_list 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") 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) day = STRMID (date, 5, 2) month = 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)) ; new_name = inst + '.' + year + month + day + '.' $ ; + hour + minute + second + '.' + pixtyp + xsize + '.fts' new_name = year + month + day + '.' $ + hour + minute + second + '.' + inst + '.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