; SUMER IMAGE DATA DECOMPRESSION (LINSU1-Version, IED 25.May.97) ; ************************************************************** ; ; necessary input variables in IDL restore file ; --------------------------------------------- ; ; >> The following input variables are taken according to CD-ROMs at MPAe. << ; >> If run in another environment, that part of the program must be changed << ; >> (see below). << ; ; format = SUMER image format type (2,...,45) ; compr = method of data compression (SSCOMPRM) ; p1 = compression parameter 1 (SSCOMPP1) ; p2 = compression parameter 2 (SSCOMPP2) ; p3 = compression parameter 3 (SSCOMPP3) ; cim = compressed image matrix (cf. OpGuide, p.8-52) ; example: format= 2 => cim=bytarr(1024,360) ; format=20 => cim=intarr(1,120) ; format=45 => cim=bytarr(5,360) ; ; resulting output variables ; -------------------------- ; ; output is either a message 'no (de)compression' ; or a message '(de)compression method ##, results:' ; followed by a list of output scalars, vectors or matrices. These are: ; dim = decompressed image matrix ; dhigh = maximum intensity of line profile ; dtotal = total intensity of line profile ; dmy = centroid of line profile ; dsigma = standard deviation of line profile ; dback = background of line profile ; Some output variables are restored according to Gauss fits, some are ; without background, some are averaged over the whole slit, depending ; on the compression method (cf. OpGuide, p.8-12ff). ; ; >> These decompression routines were also used while generating the << ; >> FITS files. Additionally, sometimes Gauss-fitted profiles are << ; >> provided here, which are not part of the FITS files. << ; ; function near2,x return,long(x+0.5) end function break,x for k=-255,-1 do if (-k eq near2(alog(-k)*x)) then hilf=-k return, hilf end function bnstr,x h1='' h2=x for hi=0,7 do begin if ((h2 mod 2) eq 1) then h1='1'+h1 else h1='0'+h1 h2=h2/2 end return,h1 end function restr,x h1=0 for hi=0,7 do if (strmid(x,hi,1) eq '1') then h1=h1+2^(7-hi) return,h1 end pro bdecode,im1,imr,back,ldim back=bytarr(ldim) imr=bytarr(50,ldim) yy='' zi=0 for i=0,ldim-1 do begin for j=0,24 do yy=yy+bnstr(im1(j,i)) if (i lt ldim-1) then uplim=418 else uplim=138 while (strlen(yy) ge uplim) do begin back(zi)=restr(strmid(yy,0,8)) yy=strmid(yy,8,strlen(yy)-1) for j=0,49 do if (strmid(yy,0,1) eq '1') then begin imr(j,zi)=restr(strmid(yy,1,8)) yy=strmid(yy,9,strlen(yy)-1) endif else begin imr(j,zi)=0 yy=strmid(yy,1,strlen(yy)-1) endelse zi=zi+1 end end return end pro method1,cim,p2,p3,spec,spat,dim dim=lonarr(spec,spat) dim=near2((p2-p3)*cim/255.+p3) print,'(de)compression method 1, result:' help,dim end pro method2,cim,spec,spat,dim dim=lonarr(spec-1,spat) for i=0,spat-1 do $ for j=1,spec-1 do dim(j-1,i)=long(cim(j,i))*2^cim(0,i) print,'(de)compression method 2, result:' help,dim end pro method3,cim,p2,p3,spec,spat,dim dim=lonarr(spec,spat) dim=near2((p2-p3)*cim^2./65280.+p3) print,'(de)compression method 3, result:' help,dim end pro method4,cim,spec,spat,dim dim=lonarr(spec-1,spat) for i=0,spat-1 do $ for j=1,spec-1 do dim(j-1,i)=near2(cim(j,i)^2./2.^(8-cim(0,i))) print,'(de)compression method 4, result:' help,dim end pro method5,cim,p2,p3,spec,spat,dim dim=lonarr(spec,spat) scal=255./alog((p2-p3)>255) lev=break(scal) for i=0,spat-1 do for j=0,spec-1 do if (cim(j,i) gt lev) then $ dim(j,i)=near2(exp(cim(j,i)/scal)+p3) else dim(j,i)=cim(j,i)+p3 print,'(de)compression method 5, result:' help,dim end pro method6,cim,p2,spat,dim dim=lonarr(50,spat) bdecode,cim,imr,back,spat imr=near2(p2*imr^2./65280.) back=near2(p2*back^2./65280.) for i=0,spat-1 do for j=0,49 do dim(j,i)=imr(j,i)+back(i) print,'(de)compression method 6, result:' help,dim end pro method7,cim,p2,p3,spat,dim,dhigh,dmy,dsigma dim=lonarr(50,spat) dhigh=lonarr(spat) for i=0,spat-1 do dhigh(i)=long(cim(0,i)) dmy=p3/100. dsigma=p2*0.8493218/100. for i=0,spat-1 do for j=0,49 do $ dim(j,i)=near2(dhigh(i)*exp(-0.5*((j-dmy)/dsigma)^2)) print,'(de)compression method 7, results:' help,dim,dhigh,dmy,dsigma end pro method8,cim,p2,spat,dim,dhigh,dmy,dsigma dim=lonarr(50,spat) dhigh=lonarr(spat) dmy=fltarr(spat) for i=0,spat-1 do begin dhigh(i)=long(cim(0,i)) dmy(i)=cim(1,i)/100. end dsigma=p2*0.8493218/100. for i=0,spat-1 do for j=0,49 do $ dim(j,i)=near2(dhigh(i)*exp(-0.5*((j-dmy(i))/dsigma)^2)) print,'(de)compression method 8, results:' help,dim,dhigh,dmy,dsigma end pro method9,cim,spat,dim,dhigh,dmy,dsigma,dback dim=lonarr(50,spat) dhigh=lonarr(spat) dmy=fltarr(spat) dsigma=fltarr(spat) dback=lonarr(spat) for i=0,spat-1 do begin dback(i)=long(cim(0,i)) dhigh(i)=long(cim(1,i)) dmy(i)=cim(2,i)/100. dsigma(i)=cim(3,i)*0.8493218/100. for j=0,49 do $ dim(j,i)=near2(dhigh(i)*exp(-0.5*((j-dmy(i))/dsigma(i))^2))+dback(i) end print,'(de)compression method 9, results:' help,dim,dhigh,dmy,dsigma,dback end pro method10,cim,p2,p3,spat,dim,dtotal,dmy,dsigma dim=lonarr(50,spat) dtotal=fltarr(spat) for i=0,spat-1 do dtotal(i)=float(cim(0,i))*p2/100./0.2690865 dmy=p3/100. dsigma=p2/0.6745/100. for i=0,spat-1 do for j=0,49 do $ dim(j,i)=near2(cim(0,i)*exp(-0.5*((j-dmy)/dsigma)^2)) print,'(de)compression method 10, results:' help,dim,dtotal,dmy,dsigma end pro method11,cim,p2,spat,dim,dtotal,dmy,dsigma dim=lonarr(50,spat) dtotal=fltarr(spat) dmy=fltarr(spat) for i=0,spat-1 do begin dtotal(i)=float(cim(0,i))*p2/100./0.2690865 dmy(i)=cim(1,i)/100. end dsigma=p2/100./0.6745 for i=0,spat-1 do for j=0,49 do $ dim(j,i)=near2(cim(0,i)*exp(-0.5*((j-dmy(i))/dsigma)^2)) print,'(de)compression method 11, results:' help,dim,dtotal,dmy,dsigma end pro method12,cim,spat,dim,dtotal,dmy,dsigma,dback dim=lonarr(50,spat) dtotal=fltarr(spat) dmy=fltarr(spat) dsigma=fltarr(spat) dback=lonarr(spat) for i=0,spat-1 do begin dback(i)=long(cim(0,i)) dtotal(i)=float(cim(1,i))*cim(3,i)/100./0.2690865 dmy(i)=cim(2,i)/100. dsigma(i)=cim(3,i)/100./0.6745 for j=0,49 do $ dim(j,i)=near2(cim(1,i)*exp(-0.5*((j-dmy(i))/dsigma(i))^2))+dback(i) end print,'(de)compression method 12, results:' help,dim,dtotal,dmy,dsigma,dback end pro method13,cim,spat,dtotal dtotal=lonarr(spat) for i=0,spat-1 do dtotal(i)=long(cim(0,i))*50 print,'(de)compression method 13, result:' help,dtotal end pro method14,cim,spat,dtotal,dmy dtotal=lonarr(spat) dmy=fltarr(spat) for i=0,spat-1 do begin dtotal(i)=long(cim(0,i))*50 dmy(i)=cim(1,i)/100. end print,'(de)compression method 14, results:' help,dtotal,dmy end pro method15,cim,spat,dim,dhigh,dmy,dsigma,dback dim=lonarr(50,spat) dhigh=lonarr(spat) dmy=fltarr(spat) dsigma=fltarr(spat) dback=lonarr(spat) for i=0,spat-1 do begin dback(i)=long(cim(0,i)) dhigh(i)=long(cim(1,i)) dmy(i)=cim(2,i)/100. dsigma(i)=cim(3,i)*0.3989422/100. for j=0,49 do $ dim(j,i)=near2(dhigh(i)*exp(-0.5*((j-dmy(i))/dsigma(i))^2))+dback(i) end print,'(de)compression method 15, results:' help,dim,dhigh,dmy,dsigma,dback end pro method16,cim,spat,dtotal dtotal=lonarr(spat) for i=0,spat-1 do dtotal(i)=long(cim(0,i)) print,'(de)compression method 16, result:' help,dtotal end pro method17,cim,p1,p2,p3,dim,dtotal,dmy,dsigma,dtotal2,dtotal3 dim=lonarr(50,360) dtotal=lonarr(360) dmy=fltarr(360) dsigma=fltarr(360) dtotal2=lonarr(360) dtotal3=lonarr(360) for i=0,359 do begin dtotal(i)=near2(cim(0,i)*p1/255.) dtotal2(i)=near2(cim(3,i)*p2/255.) dtotal3(i)=near2(cim(4,i)*p3/255.) dmy(i)=(cim(1,i)-128.)/10.+25. dsigma(i)=cim(2,i)/10. dhigh=cim(0,i)*p1/255./dsigma(i)*0.3989422 for j=0,49 do $ dim(j,i)=near2(dhigh*exp(-0.5*((j-dmy(i))/dsigma(i))^2)) end print,'(de)compression method 17, results:' help,dim,dtotal,dmy,dsigma,dtotal2,dtotal3 end ; ; input variables according to CD-ROMs at MPAe ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ; format=imgform(header_data) & format=format(0) compr=comprm(header_data) & compr=compr(0) p1=cmp1(header_data) & p1=p1(0) p2=cmp2(header_data) & p2=p2(0) p3=cmp3(header_data) & p3=p3(0) cim=image_data ; ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; input variables according to CD-ROMs at MPAe ; compr=abs(compr) p1=long(p1) & p2=long(p2) & p3=long(p3) if (format eq 2) then begin spec=1024 & spat=360 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim end if (format eq 3) then print,'no (de)compression' if (format eq 4) then begin spec=1024 & spat=120 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim end if (format eq 5) then print,'no (de)compression' if (format eq 8) then begin spec=50 & spat=360 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim end if (format eq 9) then print,'no (de)compression' if (format eq 10) then begin spec=50 & spat=120 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim end if (format eq 11) then print,'no (de)compression' if (format eq 12) then begin spec=25 & spat=360 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim if (compr eq 6) then method6,cim,p2,spat,dim end if (format eq 13) then print,'no (de)compression' if (format eq 14) then begin spec=25 & spat=120 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim if (compr eq 6) then method6,cim,p2,spat,dim end if (format eq 15) then print,'no (de)compression' if (format eq 18) then begin spat=360 if (compr eq 7) then method7,cim,p2,p3,spat,dim,dhigh,dmy,dsigma if (compr eq 10) then method10,cim,p2,p3,spat,dim,dtotal,dmy,dsigma if (compr eq 13) then method13,cim,spat,dtotal if (compr eq 16) then method16,cim,spat,dtotal end if (format eq 19) then print,'no (de)compression' if (format eq 20) then begin spat=120 if (compr eq 7) then method7,cim,p2,p3,spat,dim,dhigh,dmy,dsigma if (compr eq 10) then method10,cim,p2,p3,spat,dim,dtotal,dmy,dsigma if (compr eq 13) then method13,cim,spat,dtotal if (compr eq 16) then method16,cim,spat,dtotal end if (format eq 21) then print,'no (de)compression' if (format eq 24) then print,'no (de)compression' if (format eq 25) then print,'no (de)compression' if (format eq 26) then print,'no (de)compression' if (format eq 27) then print,'no (de)compression' if (format eq 30) then begin spec=25 & spat=24 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim end if (format eq 31) then begin spec=50 & spat=24 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim end if (format eq 34) then print,'no (de)compression' if (format eq 35) then print,'no (de)compression' if (format eq 36) then print,'no (de)compression' if (format eq 37) then print,'no (de)compression' if (format eq 38) then begin spec=512 & spat=360 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim end if (format eq 39) then print,'no (de)compression' if (format eq 40) then begin spec=1024 & spat=12 if (compr eq 1) then method1,cim,p2,p3,spec,spat,dim if (compr eq 2) then method2,cim,spec,spat,dim if (compr eq 3) then method3,cim,p2,p3,spec,spat,dim if (compr eq 4) then method4,cim,spec,spat,dim if (compr eq 5) then method5,cim,p2,p3,spec,spat,dim end if (format eq 41) then begin spat=360 if (compr eq 8) then method8,cim,p2,spat,dim,dhigh,dmy,dsigma if (compr eq 11) then method11,cim,p2,spat,dim,dtotal,dmy,dsigma if (compr eq 14) then method14,cim,spat,dtotal,dmy end if (format eq 42) then begin spat=120 if (compr eq 8) then method8,cim,p2,spat,dim,dhigh,dmy,dsigma if (compr eq 11) then method11,cim,p2,spat,dim,dtotal,dmy,dsigma if (compr eq 14) then method14,cim,spat,dtotal,dmy end if (format eq 43) then begin spat=360 if (compr eq 9) then method9,cim,spat,dim,dhigh,dmy,dsigma,dback if (compr eq 12) then method12,cim,spat,dim,dtotal,dmy,dsigma,dback if (compr eq 15) then method15,cim,spat,dim,dhigh,dmy,dsigma,dback end if (format eq 44) then begin spat=120 if (compr eq 9) then method9,cim,spat,dim,dhigh,dmy,dsigma,dback if (compr eq 12) then method12,cim,spat,dim,dtotal,dmy,dsigma,dback if (compr eq 15) then method15,cim,spat,dim,dhigh,dmy,dsigma,dback end if (format eq 45) then if (compr eq 17) then $ method17,cim,p1,p2,p3,dim,dtotal,dmy,dsigma,dtotal2,dtotal3 end