;+ ; Project : SOHO - LASCO ; ; Name : LASCO_FITSHDR2STRUCT ; ; Purpose : Read a LASCO FITS file to obtain an image and header array. ; ; Explanation : This routine calls the IDL Astronomy Library routine READFITS ; to read the LASCO FITS file. It then fills in a LASCO header ; structure with the header information. ; ; Use : IDL> lasco_hdr = LASCO_FITSHDR2STRUCT(fits_hdr) ; ; Inputs : fits_hdr FITS header, STRARR ; ; Outputs : lasco_hdr LASCO header structure. ; ; Calls : FXPAR, GETTOK ; ; Category : Data_Handling, I_O ; ; Prev. Hist. : None. ; ; Written : Scott Paswaters, NRL, Feb. 1996. ; ; Modified : 02/22/96 S. Paswaters Modified for DATE-OBS,TIME-OBS change ; to FITS header. ; 08/30/96 S. Paswaters Perform STRTRIM(val,2) on type STR tags ; ex: changes 'C1 ' to 'C1' ; 10/23/96 S. Paswaters added default structure to work with differing fits hdrs ; 11/10/97 S. Paswaters include multiple comment or history fields ; 11/30/01, N. Rich - Add Windows SSW compatibility for GSV ; 8/28/02, N. Rich - Use SSW recommendation for DATE_OBS (includes time) for Level 1 images ; 9/19/02, N. Rich - Change test for Level 1 ; 4/14/03, N. Rich - Reverse SSW DATE_OBS change (because getbkgimg crashed) ; 1/15/10, N. Rich - Upon user request, use $SSW_LASCO instead of $NRL_LIB by default ; 7/29/11, N. Rich - Use def_lasco_hdr() instead of example_hdr.sav ; ; Version : ; ; 07/29/11 @(#)lasco_fitshdr2struct.pro 1.13 :LASCO IDL LIBRARY ; ;- ;_______________________________________________________________________________ ; FUNCTION LASCO_FITSHDR2STRUCT, fts_hdr COMMON LASCO_HDR_COMMON, lasco_hdr_struct, lasco_hdr_tags len = N_ELEMENTS(fts_hdr) IF trim(fxpar(fts_hdr,'BUNIT')) EQ 'MSB' THEN level1=1 ELSE level1=0 ;** if calling for the first time we need to define the header structure IF (DATATYPE(lasco_hdr_struct) EQ 'UND') THEN BEGIN ;RESTORE, 'example_hdr.sav' ;RESTORE, FILEPATH('example_hdr.dat',ROOT_DIR='$NRL_LIB',SUBDIRECTORY=['lasco','inout']) ; rootdir=getenv('SSW_LASCO') ; IF rootdir EQ '' THEN rootdir=getenv('NRL_LIB') ; RESTORE, FILEPATH('example_hdr.sav',ROOT_DIR=rootdir,SUBDIRECTORY=['idl','inout']) lasco_hdr_struct=def_lasco_hdr(lasco_hdr_tags) ENDIF lasco_hdr = lasco_hdr_struct nt = N_ELEMENTS(lasco_hdr_tags) FOR t=0, nt-1 DO BEGIN ;** for each tag in the lasco hdr structure key = lasco_hdr_tags(t) ;IF NOT level1 THEN IF (key EQ 'DATE_OBS') THEN key = 'DATE-OBS' IF (key EQ 'DATE_OBS') THEN key = 'DATE-OBS' IF (key EQ 'TIME_OBS') THEN key = 'TIME-OBS' var = FXPAR(fts_hdr, key, COUNT=cnt) IF ( (key EQ 'COMMENT') OR (key EQ 'HISTORY') ) THEN BEGIN ;** only these may have multiple entries FOR c=0, cnt-1 DO BEGIN val = STRTRIM(var(c), 2) lasco_hdr.(t)(c) = val ENDFOR ENDIF ELSE BEGIN IF (DATATYPE(var(0)) EQ 'STR') THEN var = STRTRIM(var(0), 2) lasco_hdr.(t) = var(0) ENDELSE ENDFOR RETURN, lasco_hdr END