;+ ; Name: get_mid_string ; ; Purpose: Auxilary function for resik_read_fits.pro routine ;- function get_mid_string, strx ;BITPIX = 8 / p1= STRPOS( strx, "'") out=strmid(strx, p1+1, strlen(strx)) p2= STRPOS( out, "'") ;stop out=strmid(out, 0, p2) ;return, strcompress(out, /remove_all) return, out end ;------------------------------------------------------------------- ;+ ; Name: resik_read_fits ; ; Purpose: Read RESIK spectra data files, headers or headers and data ; ; Input Parameters: ; file - file name of RESIK fits file to read ; dset - indices of the spectra to read. Set dset to -1 to read entire file ; Output Parameters: ; index - IDL structure vector with spectra parameters description ; data - data cube ; ; Calling Sequence: ; resik_read_fits, file, dset, index, data ; CALLS ; get_mid_string <- defined above in this file ; ; Keyword Parameters: ; NONE ; ;HISTORY: ; Written 2006-Jan-2 by S. Gburek SRC SFD Poland ; Restrictions: ; NONE ;- pro resik_read_fits, fname_fits, dset, index, data read_data=n_params() ge 4 ;stop ;--------- read primary header ------ FXREAD, fname_fits, dd_dummy, hhprim if dset(0) eq -1 then begin nspec=long( get_mid_string(hhprim(9)) ) fdset=lindgen(nspec) endif else begin nspec=n_elements(dset) fdset=dset endelse nbin=long( get_mid_string(hhprim(10)) ) nchan=long( get_mid_string(hhprim(11)) ) if read_data then begin ;--- prepare output data cube --------- data=fltarr(nbin, 4*nchan, nspec) ;stop endif ;stop ; ------ prepare index ------------- index_str = $ {INSTRUMENT:'RESIK' ,$ OBSERVATION_TYPE: 'RESIK ABSOLUTE SPECTRA' ,$ SPECTRA_UNITS:'photons/cm^2/s/Angstrom' ,$ WVL_UNITS:'Angstrom' ,$ SPC_N:0L ,$ BIN_N:0 ,$ CHAN_N:0 ,$ SPEC_ID: 0L ,$ STIME_ST: '' ,$ STIME_CE: '' ,$ STIME_EN: '' ,$ TIME_ST: double(0) ,$ TIME_CE: double(0) ,$ TIME_EN: double(0) ,$ EXPDUR:float(0) $ } index=replicate(index_str, nspec) ;--- read header & spectra ---------- for i=0L, nspec-1 do begin FXBOPEN, UNIT,fname_fits , fdset(i)+1, Hx if read_data then begin FXBREAD, UNIT, DATAx, 1 endif FXBCLOSE, UNIT, ERRMSG=ERRMSG ;stop ;index(i).SPEC_ID=LONG(get_mid_string(hx(8))) index(i).SPEC_ID=get_mid_string(hx(8)) index(i).SPC_N=nspec index(i).BIN_N=nbin index(i).CHAN_N=nchan index(i).STIME_ST=get_mid_string(hx(9)) index(i).STIME_CE=get_mid_string(hx(10)) index(i).STIME_EN=get_mid_string(hx(11)) index(i).TIME_ST=get_mid_string(hx(12)) index(i).TIME_CE=get_mid_string(hx(13)) index(i).TIME_EN=get_mid_string(hx(14)) index(i).EXPDUR=get_mid_string(hx(15)) ;----------------- if read_data then begin data(*,*,i)=datax endif endfor ;stop ;if dset(0) ne -1 then begin ;stop ; index=index(dset) ; if read_data then begin ; data=data(*,*,dset) ; endif ;endif end