;+ ; lasco_rename3.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_rename3, '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' ; 16 Jul 2003: Use FILEORIG keyword to get the date & time. ;- pro lasco_rename3, 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") fileorig = fxpar (hdu, "FILEORIG") date = fxpar (hdu, "DATE") date_obs = fxpar (hdu, "DATE-OBS") time_obs = 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) syear = STRMID (fileorig, 0, 2) smonth = STRMID (fileorig, 2, 2) sday = STRMID (fileorig, 4, 2) year = FIX (syear) IF (year GT 90 AND year LT 1900) THEN year = year + 1900 IF (year LT 90 ) THEN year = year + 2000 syear = STRTRIM (STRING (year), 2) date_img = syear + smonth + sday ; date_obs = sday + '/' + smonth + '/' + syear date_obs = syear + '-' + smonth + '-' + sday 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) ; hour = STRMID (date, 9, 2) ; minute = STRMID (date, 12, 2) ; second = STRMID (date, 15, 2) shour = STRMID (fileorig, 7, 2) sminute = STRMID (fileorig, 9, 2) ssecond = STRMID (fileorig, 11, 2) time_obs = shour + ':' + sminute + ':' + ssecond fxaddpar, hdu, 'TIME-OBS', time_obs, " HOUR:MINUTE:SECOND [UT]" time_img = shour + sminute + ssecond inst = STRLOWCASE (STRMID (detector, 0, 2)) ; new_name = inst + '.' + year + month + day + '.' $ ; + hour + minute + second + '.' + pixtyp + xsize + '.fts' new_name = syear + smonth + sday + '.' $ + shour + sminute + ssecond + '.' + 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