pro bintotab,fname,intnum ;Program to take WAPP spectral line data and convert into a hacked regular ;fits table format. ; ;SYNTAX: bintotab,"Myfile.fits",intnum ;where intnum is the number of the integration output by WAPP into file ;"Myfile.fits" ;Data is returned as TAB_x_fname where x is the integration number, fname is ;the input filename. ; ; ;REMEMBER: ALFA FITS integrations are written in order as: ;1) Pixel 0, pol A ;2) Pixel 1, pol A ;3) Pixel 0, pol B ;4) Pixel 1, pol B ; and so on. ; ; Ignore the following errors reported by CHECK_FITS: ;% CHECK_FITS: NAXIS keywords in FITS header have been updated ;(Im still fiddling with CHECK_FITS to try and get it to accept these axes..) ;% CHECK_FITS: BITPIX value of -32 added to FITS header ;% Program caused arithmetic error: Floating divide by 0 ; ; On further detail, I didn't get data with sensible RA and DEC (Probably ; because the tolerance was set to 'IGN', XS expects the data to be written ; IN DEGREES. hdrtab=headfits(fname) ; get the header table from the file fxbopen,poo,fname,1,hdrbin ; open binary file, extract header fxbfind,poo,"TTYPE",cols,params,nf ; obtain all header words, and the number of them fxbread,poo,spec,1,intnum ; get the actual spectrum out for this integration. params=strcompress(params,/remove_all) ; get all the keyword names out of the binary header. for i=1,nf-1 do begin ; read all the keyword values out of the binary header. fxbread,poo,store,i+1,intnum if size(store,/type) eq 1 then store=fix(store) sxaddpar,hdrtab,params(i),store(0) ; and add them back into the regular fits table. endfor ; Next: Add more numbers, or modify the existing ones, to make XS like this data. sxaddpar,hdrtab,"NAXIS",3 sxaddpar,hdrtab,"NAXIS2",1,after="NAXIS" sxaddpar,hdrtab,"NAXIS3",1,after="NAXIS2" sxaddpar,hdrtab,"LINE","HI" sxaddpar,hdrtab,"SCAN-NUM",intnum sxaddpar,hdrtab,"COMMENT"," ",after="TELESCOP" sxaddpar,hdrtab,"BSCALE",1.,after="COMMENT" sxaddpar,hdrtab,"BZERO",0.0,after="BSCALE" sxaddpar,hdrtab,"BUNIT","K",after="BZERO" sxaddpar,hdrtab,"DATAMAX",max(spec) sxaddpar,hdrtab,"DATAMIN",min(spec) sxaddpar,hdrtab,"CTYPE1","FREQ" sxaddpar,hdrtab,"VLSR",sxpar(hdrtab,"VELOCITY")*1000. & sxdelpar,hdrtab,"VELOCITY" sxaddpar,hdrtab,"DELTAV",3.e+8*sxpar(hdrtab,"CDELT1")/sxpar(hdrtab,"CRVAL1") sxaddpar,hdrtab,"OBSTIME",1,after="CRPIX3" sxaddpar,hdrtab,"BZERO",0. sxaddpar,hdrtab,"CRVAL1",0.0,after="CTYPE1" sxaddpar,hdrtab,"CTYPE2","RA",after="CRPIX1" sxaddpar,hdrtab,"CDELT2",0.0,after="CRVAL2" sxaddpar,hdrtab,"CRPIX2",1,after="CDELT2" sxaddpar,hdrtab,"CTYPE3","DEC",after="CRPIX2" sxaddpar,hdrtab,"CDELT3",0.0,after="CRVAL3" sxaddpar,hdrtab,"CRPIX3",1,after="CDELT3" sxaddpar,hdrtab,"BITPIX",16 sxaddpar,hdrtab,"CENTFREQ",sxpar(hdrtab,"CRVAL1"),after="RESTFREQ" sxaddpar,hdrtab,"IMAGFREQ",sxpar(hdrtab,"CRVAL1"),after="CENTFREQ" sxaddpar,hdrtab,"DECOFF",0.0 ;now remove some headers that xs does not need - (dont need to do this, ; but I did anyhow) sxdelpar,hdrtab,"EXTEND" sxdelpar,hdrtab,"BANDWID" sxdelpar,hdrtab,"COMMENT" sxdelpar,hdrtab,"REFERENC" sxdelpar,hdrtab,"HISTORY" sxaddpar,hdrtab,"RAOFF",0.0 writefits,"TAB_"+strcompress(string(intnum),/remove_all)+"_"+fname,$ spec,hdrtab ; finally... write out the data in fits format. close,/all ; close anything left open end