;+ ; A procedure to convert a unipops SDD format file to an SDFITS table ; that can be consumed by GBTIDL. ; ;
This uses an sdd object to do the conversion, one scan at a ; time. The converted scan is then copied into the PDC and ; keep is used ; to save that scan to the output file. ; ;
This also converts recent data from the 12m which uses the ; unipops SDD format except that the byte ordering is reversed. ; ;
This could use more error checking and reporting. ; ;
Contributed By: Bob Garwood, NRAO-CV
; .com sdd__define ; only need to do this the first time
; .com uni2sdfits
; uni2sdfits,'sdd_hc.wbl_001','sdd_hc.wbl_001.fits'
;
;
; @uses data_free
; @uses fileout
; @uses freeze
; @uses keep
; @uses sdd object
; @uses set_data_container
; @uses unfreeze
;
; @version $Id$
;-
pro uni2sdfits, unifile, sdfitsfile
compile_opt idl2
; remember current output file for restoration later
curFileOut = !g.line_fileout_name
fileout,sdfitsfile
uniIn = obj_new('sdd',unifile)
if uniIn->nscans() le 0 then begin
message,sdfitsfile + ' appears to have no scans in it, can not continue',/info
obj_destroy, uniIn
fileout, curFileOut
return
endif
print,'Begin converting ', uniIn->nscans(), ' scans from ', unifile, ' to ', sdfitsfile
fstate = !g.frozen
freeze
for i=0,(uniIn->nscans()-1) do begin
if uniIn->indexUsed(i) then begin
dc = uniIn->getdc(i)
if data_valid(dc) gt 0 then begin
set_data_container, dc
keep
print,string(i,dc.scan_number,dc.procseqn,format='(i5," : scan ", i5, ".", i2.2," converted")')
data_free, dc
endif else begin
print,' ... skipping'
endelse
endif else begin
print,'Index ', i,' is empty.'
endelse
endfor
obj_destroy,uniIn
if not fstate then unfreeze
fileout, curFileOut
print,'finished'
end