;+ ; ; NAME : ; SUMER_CDS_FITS ; PURPOSE: ; Read a CDS Fits file into a data structure compatable with ; that used in SUMER_FITS ; CALLING SEQUENCE: ; data_str = SUMER_CDS_FITS(filename) ; INPUTS: ; FILENAME CDS fits file name. ; ; OUTPUT: ; ; DATA_STR a data structure with the following fields: ; ; FILE CDS file name ; H primary header ; BH binary header ; DATA an array of CDS data ; AMP count amplification factor ; Note that DATA = RAW COUNT x AMP ; SUM_STATUS Image Status ; DEL_TIME Relative Time of each image ; EXPTIME Exposure time of each image ; SOLAR_X Azimuth position of each image ; SOLAR_Y Elevation position of each image ; NEXT Number of binary extensions (always 1) ; EXTENSION The present extension number (always 1) ; DIM dimensions of DATA ; dim(0) # of pixels along the spectral direction ; dim(1) # of pixels along the slit direction ; dim(2) # of repetition ; sim(3) # of segments (lines) ; ; NDATA Number of lines in DATA ; DATA_NAMES specification of each line ; DESCR Physical description of each dimension in DATA ; REFPIXELS Reference pixels (from TRPIXi of BH) ; REFPOS Physical values at refernce pixels (from TRVALi) ; DELTAS Physical Increments (from TDELTi) ; SUMPIXELS reference detector co-pixels (from TDETXi and TDETYi) ; ; The SUMER reference co-pixels are the coordinates ; of the reference pixels measured from the lower left ; (solar North and short wavelength) corner of the ; detector. ; HISTORY ; 1999 Apr Jongchul Chae ;- function sumer_cds_fits, filename if n_elements(filename) ne 0 then begin file=findfile(filename, count=count) if count eq 0 then begin result=widget_message('There is no CDS file with the name '+filename, /error) return,0 endif file=file(0) if n_elements(exten) eq 0 then exten=1 defsysv, '!textout', 1 defsysv, '!textunit', 1 fits_info, file, silent=1, textout=1, n_ext=next h=headfits(file) endif if exten gt next then begin print, ' The file : '+file+ ' has only '+ strtrim(string(next),2) $ +' binary extension tables.' return,0 endif fxbopen, unit, file, exten, bh ncol = fxpar(bh,'TFIELDS') ndata = ncol-24 fxbfind, unit, 'TTYPE', indgen(ndata)+1, data_names, n_found data_names=data_names(0:ndata-1) descr = fxbtdim(fxpar(bh, 'TDESC1')) dim = fix(fxbtdim(fxpar(bh,'TDIM1'))) fxbfind, unit, 'TRPIX',indgen(ndata)+1, srefpixels,n_found srefpixles=srefpixels(0:ndata-1) fxbfind, unit, 'TRVAL', indgen(ndata)+1, srefpos, n_found srefpos=srefpos(0:ndata-1) fxbfind, unit, 'TDELT', indgen(ndata)+1, sdeltas, n_found sdeltas=sdeltas(0:ndata-1) fxbfind, unit, 'TDETX', indgen(ndata)+1, sdetx, n_found sdetx = sdetx(0:ndata-1) fxbfind, unit, 'TDETY', indgen(ndata)+1, sdety, n_found sdety = sdety(0:ndata-1) sumpixels=intarr(3, ndata) sumpixels(0,*) = fix(sdetx) sumpixels(1,*) = fix(sdety) sumpixels(2,*) = 1 case n_elements(dim) of 1 : begin fxbread, unit, data1, 1 s=size(data1) & type = s(n_elements(s)-2) data=make_array(dim(0), ndata) for i=0, ndata-1 do begin fxbread, unit, data1, i+1 data(*, i) = data1 endfor end 2 : begin fxbread, unit, data1, 1 s=size(data1) & type = s(n_elements(s)-2) data=fltarr(dim(0),dim(1),1, ndata) deltas=fltarr(3, ndata) refpos = fltarr(3, ndata) refpixels = intarr(3, ndata) for i=0, ndata-1 do begin data(*,*,0, i) = data1 tmp= float(fxbtdim(sdeltas(i))) deltas(0:n_elements(tmp)-1, i) = tmp tmp = float(fxbtdim(srefpos(i))) refpos(0:n_elements(tmp)-1,i) = tmp tmp = fix(fxbtdim(srefpixels(i))) refpixels(0:n_elements(tmp)-1,i) = tmp if i+2 le ndata then fxbread, unit, data1, i+2 endfor dim = [dim, 1] end 3 : begin descr = (descr)([0,2,1]) dim(1:2)=(dim)([2,1]) if ndata gt 1 then begin fxbread, unit, data1, 1 s=size(data1) & type = s(n_elements(s)-2) data=fltarr(dim(0),dim(1),dim(2), ndata) deltas = fltarr(3, ndata, /nozero) refpos = fltarr(3, ndata, /nozero) refpixels = intarr(3, ndata, /nozero) for i=0, ndata-1 do begin for kk=0, dim(0)-1 do data(kk,*,*, i) = $ rotate(reform(data1(kk,*,*)),1) deltas(*, i) = (float(fxbtdim(sdeltas(i))))([0,2,1]) refpos(*,i) = (float(fxbtdim(srefpos(i))))([0,2,1]) refpixels(*,i) = (fix(fxbtdim(srefpixels(i))))([0,2,1]) if i+2 le ndata then fxbread, unit, data1, i+2 endfor endif else begin i=0 fxbread, unit, data1, i+1 data = fltarr(dim(0), dim(1), dim(2)) for kk=0, dim(0)-1 do data(kk, *,*) = $ rotate(reform(data1(kk, *,*)),1) deltas = (float(fxbtdim(sdeltas(i))))([0,2,1]) refpos = (float(fxbtdim(srefpos(i))))([0,2,1]) refpixels = (fix(fxbtdim(srefpixels(i))))([0,2,1]) s=size(data) & type = s(n_elements(s)-2) endelse end else : begin print, 'Data dimension does not fit.' end endcase dim=[dim, ndata] descr=[descr,'COLUMN'] fxbread, unit, sum_status, ncol-4 fxbread, unit, del_time, ncol-3 fxbread, unit, exptime, ncol-2 fxbread, unit, solar_x, ncol-1 fxbread, unit, solar_y, ncol fxbclose, unit amp=1.0 data_str = {file:file, h:h, bh:bh, data:data, amp:float(amp), $ sum_status:sum_status, $ del_time:del_time, exptime:exptime, solar_x:solar_x, $ solar_y:solar_y, next:next, extension:exten, dim:dim, $ ndata:ndata, data_names:data_names, descr:descr, $ refpixels:refpixels, sumpixels:sumpixels, $ refpos:refpos, deltas:deltas} return, data_str end