; NAME : convft1 ; PURPOSE : ; convert flare telescope T1 data into MAGPACK2's standard format ; CATEGORY : ; solar magnetic field computation package (MAGPACK2) ; CALLING SEQUENCE : ; convft1, h,img,q,u,v, mparam,rdata, nxnew=nxnew ; INPUTS : ; h(0,1,2,3) = nkrheader ; img,q,u,v = Stokes parameters ; for calibrated data, q,u,v arrays actually store bx,by,bl ; OPTIONAL INPUT PARAMETERS : ; none ; KEYWORD PARAMETERS : ; nxnew = new nx (number of pixels in the x-direction) ; possible values are 512, 256, 128, 64, ,,,. ; if not specified, the old nx value in the file header is used ; OUTPUTS : ; creates arrays mparam and rdata ; mparam = magpack2 parameters ; rdata = i,q,u,v or i,bx,by,bl ; COMMON BLOCKS : none ; SIDE EFFECTS : none ; RESTRICTIONS : none ; PROCEDURE : ; ; MODIFICATION HISTORY : ; T.Sakurai, 1992 ; ;------------------------------------------------------------------------ ; pro convft1, h,img,q,u,v, mparam,rdata, nxnew=nxnew ; mparam = defmp() pix0 = 0.66 ; standard pixel size pix1 = pix0*(512/h(0).nx) ; arc sec. for 1 pixel if ( strmid(h(0).dx,0,1) eq ' ' ) then begin ; dx is blank pixx = pix1 pixy = pix1 endif else begin pixx = float(h(0).dx) pixy = float(h(0).dy) endelse if keyword_set(nxnew) then nbin=( h(0).nx/nxnew > 1 ) else nbin=1 timeint,h,time1,time2,date1,date2 time1 = strmid(time1,0,8) time2 = strmid(time2,0,8) sunparam, h(0).time_sys, date1,time1, rsp, pdeg, b0deg, cl0deg, doy if h(1).correct gt 100 then $ ; in this case q=bx and u=by kindm = 1002L $ ; intensity and pseudo vector field else $ kindm = -3033L ; waveband No.3 = 6303A nbytem =h(0).nbyt nframe =4 nx0 =h(0).nx ny0 =h(0).ny dx0 = pixx * 0.07 dy0 = pixy * 0.07 xs0 =h(0).g_x*0.07 - 0.5*nx0*dx0 ys0 =h(0).g_y*0.07 - 0.5*ny0*dy0 nx = nx0/nbin ny = ny0/nbin dx = dx0 * nbin dy = dy0 * nbin xs = xs0 + 0.5* dx0 * (nbin-1) ys = ys0 + 0.5* dy0 * (nbin-1) ypos =0.0 mesh =0 rsp = 0.07 * rsp xxtod = [ xs + 0.5*dx*(nx-1), ys + 0.5*dy*(ny-1), 0.0 ] zt2 = rsp*rsp - xxtod(0)^2 - xxtod(1)^2 if zt2 ge 0.0 then xxtod(2) = sqrt(zt2) else xxtod(2) = -rsp pi = 3.141592 mparam.kindm =kindm mparam.nbytem =nbytem mparam.nframe =nframe mparam.nx =nx mparam.ny =ny mparam.xs =xs mparam.ys =ys mparam.dx =dx mparam.dy =dy mparam.ypos =ypos mparam.mesh =mesh mparam.rsp =rsp mparam.prad =pi*pdeg/180.0 mparam.b0rad =pi*b0deg/180.0 mparam.cl0rad =pi*cl0deg/180.0 mparam.xxtod=xxtod mparam.inst='MTK/FT1 ' mparam.tsys= string( h(0).time_sys, format='(a6)') mparam.dateo = date1 mparam.stime= time1 mparam.etime= time2 mparam.mfile = string( h(0).obs_id, format='(a8)') ftag='' spawn, "date '+%y/%m/%d%T'",ftag mparam.ftag= ftag(0) mparam.inst = string( h(0).observatory, h(0).telescope, format='(a4,a4)') mparam.title = string( h(0).obs_id, format='(a80)') rdata = fltarr(nx,ny,8) rbuf = fltarr(nx,ny) mparam.status.i = 0 rbuf = rebin( float(img), nx, ny ) rbuf = rbuf/max(rbuf) rdata(*,*,0) = rotate(rbuf,7) ; reverse y-direction factp=0.00005 if kindm lt 0 then begin mparam.status.q = 1 rbuf = factp*rebin( float(q), nx, ny) rdata(*,*,1) = rotate(rbuf,7) mparam.status.u = 2 rbuf = factp*rebin( float(u), nx, ny) rdata(*,*,2) = rotate(rbuf,7) mparam.status.v = 3 rbuf = factp*rebin( float(v), nx, ny) rdata(*,*,3) = rotate(rbuf,7) endif else begin ; binning should be done on (q,u) rather than on (bx,by) nonzero = where( u ne 0 or q ne 0 ) angle = fltarr( nx0,ny0 ) angle( nonzero ) =atan( float(u(nonzero)), float(q(nonzero))) ; q=bx, u=by, theta=field azimuth qq= float(q)^2 + float(u)^2 uu=qq qq = qq * cos(2.0*angle) ; qq=Bt^2 *cos(2*theta) uu = uu * sin(2.0*angle) ; uu=Bt^2 *sin(2*theta) qq = rebin( qq, nx,ny ) uu = rebin( uu, nx,ny ) bt = sqrt( sqrt( qq^2 + uu^2 ) ) nonzero = where( uu ne 0.0 or qq ne 0.0 ) angle = fltarr( nx,ny ) angle( nonzero ) = 0.5*atan( uu(nonzero) ,qq(nonzero) ) factb=0.1 ; unit of bx,by,bl is 0.1 gauss mparam.status.bx = 1 rbuf = factb*bt*cos(angle) rdata(*,*,1) = rotate(rbuf,7) mparam.status.by = 2 rbuf = factb*bt*sin(angle) rdata(*,*,2) = - rotate(rbuf,7) ; reverse y-direction and sign of y-components mparam.status.bl = 3 rbuf = factb*rebin( float(v), nx, ny) rdata(*,*,3) = rotate(rbuf,7) endelse print,'(proc.convft1) nbin,nx,ny,kindm=',nbin,nx,ny,kindm return end