PRO normrot,img,p,az,el,zang,yang,cam,filt,lbsang,date primemer=[147.32,147.32] PRINT,'zang=',zang IF ((zang GT -90) AND (zang LT 90)) AND (MAX(az) GT 180) $ THEN az(WHERE(az GE 180))=az(WHERE(az GE 180))-360 readnorm,cam,filt,map,maz,mza mel=90-mza normimg=FLTARR(256,256) position,cam,filt,maz,mza,cl,rw cl=cl/2. & rw=rw/2. normimg(cl,rw)=map normimg=MEDIAN(normimg,3) TVSCL,normimg>0.8,1 IF lbsang EQ 0 THEN $ XYOUTS,384,490,ALIGNMENT=0.5,"Normalizing map",/DEVICE ELSE $ XYOUTS,384,490,ALIGNMENT=0.5,"Before rotation",/DEVICE TVSCL,img>(0.8*MAX(img)),2 XYOUTS,128,234,"Dark-corrected image",/DEVICE,ALIGNMENT=0.5 IF lbsang EQ 0 THEN BEGIN flatimg=normimg*img wwww=WHERE(flatimg) sdf=stdev(flatimg(wwww),mf) PRINT,mf,100*sdf/mf $ ,FORMAT='("Mean = ",F7.1," DN; s.d. = ",F4.1,"% of mean")' ENDIF ELSE BEGIN ; Instead of rotating about the zenith, try rotating about the center ; of the LBS image ;w=MAX(el,loc) ;one2two,loc,img,xz,yz ;normimg=rot(normimg,+147.40-zang,1.,xz,yz,/pivot) WINDOW,2,XSIZE=256,YSIZE=256 meancent,normimg,xc,yc WDELETE,2 normimg=rot(normimg,+primemer(cam)-zang,1.,ROUND(xc),ROUND(yc),/pivot) TVSCL,normimg>0.8,3 XYOUTS,384,234,ALIGNMENT=0.5,"After rotation",/DEVICE pt=WHERE(normimg) ;polrec3d,1.,90-el,(90-az),x,y,z,/DEGREES polrec3d,1.,90-el,-az,x,y,z,/DEGREES ;rot_3d,3,x,y,z,90-zang,x0,y0,z0,/DEGREES rot_3d,3,x,y,z,zang,x0,y0,z0,/DEGREES rot_3d,2,x0,y0,z0,-yang,x1,y1,z1,/DEGREES ;rot_3d,3,x1,y1,z1,zang-90,x2,y2,z2,/DEGREES rot_3d,3,x1,y1,z1,-zang,x2,y2,z2,/DEGREES x='' & x1='' & y='' & y1='' & z='' & z1='' recpol3d,x2,y2,z2,r,za2,ang,/DEGREES ;az2=90-ang & el2=90-za2 az2=-ang & el2=90-za2 wn=WHERE(az2 LT 0) az2(wn)=az2(wn)+360. IF ((zang GT -90) AND (zang LT 90))$ THEN az2(WHERE(az2 GE 180))=az2(WHERE(az2 GE 180))-360 x2=0 & y2=0 & z2=0 TRIANGULATE,az2(pt),el2(pt),triangles ti2=TRIGRID(az2(pt),el2(pt),normimg(pt),triangles,[.25,.5],$ [MIN(az2(pt)),MIN(el2(pt)),MAX(az2(pt)),MAX(el2(pt))]) triangles=0 lbs=WHERE(img GT MAX(img)/1.33) rni=FLTARR(256,256) azl=(az(lbs)-MIN(az2(pt)))/0.25 ell=(el(lbs)-MIN(el2(pt)))/0.5 rni(lbs)=INTERPOLATE(ti2,azl,ell) flatimg=rni*img ENDELSE ; put a frame around the flattened image for context fimg=flatimg mp=MAX(flatimg) fimg(0,*)=mp fimg(255,*)=mp fimg(*,0)=mp fimg(*,255)=mp TVSCL,fimg>(0.8*mean(flatimg)) IF lbsang NE 0 THEN TVSCL,rni,0 TVSCL,normimg,1 TVSCL,img>(0.8*MAX(img)),3 PRINT,'Would you like to save this image ([Y]/N)' ans='' READ,ans IF STRUPCASE(ans) NE 'N' THEN BEGIN IF lbsang LT 0 THEN sign='-' ELSE sign='+' IF zang LT 0 THEN ext=FIX(ROUND(360+zang)) ELSE ext=FIX(ROUND(zang)) fname=STRING(date,cam,filt,sign,ABS(lbsang),ext,$ FORM='("/jasper/cnsr3_data1/flat/fn",I2.2,2I1,A,I2.2,".",I3.3)') OPENW,u,fname,/GET_LUN WRITEU,u,FIX(flatimg) CLOSE,u & FREE_LUN,u ENDIF RETURN END