PRO gfunc, X, A, F, pder bx = EXP(A[1] * X) F = A[0] * bx + A[2] IF N_PARAMS() GE 4 THEN $ pder= [[bx], [A[0] * X * bx], [replicate(1.0, N_ELEMENTS(X))]] END function intenzity,pole vel=n_elements(pole(*,0)) intt=make_array(vel,2,/float) intt(*,0)=pole(*,1) atlas=make_array(4400,/float) openr,unit,'c:\Rsi\Idl54\polarizace\liegout.dat',/get_lun readf,unit,atlas free_lun,unit for i=0,vel-1 do begin delka1=pole(i,0) & delka1=(round(delka1*100.0))/100.0 index=where(atlas eq delka1,count) intt(i,1)=atlas(index+1) endfor return,intt end function vyber,pole,x1,x2 vel=n_elements(pole(*,0)) poleob=make_array(vel,/int) intervaly=make_array(22,/float) openr,unit,'c:\Rsi\Idl54\polarizace\Halfap.dat',/get_lun readf,unit,intervaly free_lun,unit for j=x1,x2 do begin poleob(j)=0 for i=0,10 do if (pole(j,0) gt intervaly(i*2)) and (pole(j,0) lt intervaly(i*2+1)) then poleob(j)=1 endfor indexy=where(poleob eq 1) cast=pole(indexy,*) return,cast end pro list_event,event COMMON spol,item,wave COMMON spol1,pocet,delky widget_control,event.id,get_uvalue=uvalue case uvalue of 'LIST':begin wave=float(item(event.index)) end 'OK':begin widget_control,event.top,/destroy delky(pocet)=wave pocet=pocet+1 end endcase end function najdi,pole,ind i=ind while (pole(195,i) lt 70) do i=i-1 return,i end function najdih,pole,ind i=ind while (pole(195,i) lt 70) do i=i+1 return,i end pro nakresli,zceho,kam,jedna,dva,diff,pozice,lab COMMON disperze,dispx if diff ne 0 then begin if (((jedna-15) gt 0) and ((jedna+15) lt 619)) and (dva lt 569) and ((dva-diff) gt 0) then begin !P.MULTI=[0,1,2] widget_control,kam,get_value=nas & wset,nas y1=make_array(31,value=0) & y2=make_array(31,value=0) for i=-1,1 do begin y1=y1+smooth(zceho((jedna-15):(jedna+15),dva+i),4) y2=y2+smooth(zceho((jedna-15):(jedna+15),dva-diff+i),4) endfor y1=round(y1/3.0) & y2=round(y2/3.0) min1=where(y1 eq min(y1),count1) min2=where(y2 eq min(y2),count2) if (count1 eq 1) and (count2 eq 1) then begin dispx=0 dispx=min2(0)-min1(0) val1=strcompress(string(dispx),/remove_all) widget_control,lab,set_value=val1 endif else widget_control,lab,set_value=' ' plot,y1 if (count1 eq 1) then plots,min1(0),min(y1),psym=2,/data plot,y2 if (count2 eq 1) then plots,min2(0),min(y2),psym=2,/data device,set_graphics=6 arrow,pozice,0,pozice,399,hsize=0,color=!D.N_colors-1 device,set_graphics=3 endif endif end pro nastav,co widget_control,co,get_value=nas wset,nas end pro polar_event,event COMMON profily,profzacx,profkonx,profzacy,profkony,lbcorx,rucorx,lbcory,rucory COMMON box,box1,box2,calk1,calk2,st1,en1 COMMON kolik,rozhrani,pozicep COMMON spol,item,wave COMMON spol1,pocet,delky COMMON pos,pozice COMMON baze,base,basep,based,omenu,baset,basepet COMMON kal,acoef1,bcoef1,ccoef1,acoef2,bcoef2,ccoef2 COMMON kal1,a1,b1,c1,a2,b2,c2 COMMON disperze,dispx COMMON uloz,nazev,robraz COMMON slid,line,rotat,rotval,f2,obr,prof,lineprof,roz2,o2,dis2 ;,line3 COMMON dalsi,pos2,pos3,pos4,pos5 COMMON inner,ypos,rotpos,xpos,prvni,druhy,dif;,xpos2,rozsah COMMON inner2,n1,n2 COMMON inner3,cesta COMMON posunobr,posun,zac1,kon1 COMMON oblasti,black1,black2,mensi COMMON interpo,body,pocetint COMMON knof,f1 widget_control,event.id,get_uvalue=uvalue case uvalue of 'LOAD':begin nastav,obr & erase & nastav,prof & erase cesta=pickfile(filter='*.fts') obraz=readfits(cesta) & robraz=obraz widget_control,obr,sensitive=1 nastav,obr tvscl,obraz widget_control,line,sensitive=1 widget_control,rotat,sensitive=1 ; widget_control,f2,sensitive=1 ; widget_control,f22,sensitive=1 widget_control,f1,sensitive=0 widget_control,rotval,sensitive=1 widget_control,lineprof,sensitive=1 widget_control,o2,sensitive=1 widget_control,line,set_value=300 & ypos=300 widget_control,rotat,set_value=0 & rotpos=0.0 widget_control,rotval,set_value='0' widget_control,lineprof,set_value=10 widget_control,roz2,set_value=' ' widget_control,dis2,set_value=' ' widget_control,pos3,set_value=' ' device,set_graphics=6 arrow,0,300,619,300,hsize=0,color=!D.N_colors-1 nastav,prof arrow,10,0,10,399,hsize=0,color=!D.N_colors-1 device,set_graphics=3 xpos=10 & prvni=-1 & druhy=-1 dif=0 & n1=0 & n2=0 dispx=0 & posun=0 & pocetint=0 end 'SAVE':begin nazev='p'+strmid(cesta,strlen(cesta)-10,10) strput,cesta,nazev,strlen(cesta)-10 cesta=cesta+'s' val='The result has been saved as a '+nazev writefits,cesta,tvrd() basesave=widget_base() labelsave=widget_label(basesave,value=val) widget_control,basesave,/realize & wait,2 widget_control,basesave,/destroy widget_control,event.top,/destroy polar end 'QUIT':begin !p.multi=0 widget_control,event.top,/destroy if (!d.window ne -1) then wdelete,!d.window end 'LINE':begin nastav,obr device,set_graphics=6 arrow,0,ypos,619,ypos,hsize=0,color=!D.N_colors-1 widget_control,line,get_value=hodnota arrow,0,hodnota,619,hodnota,hsize=0,color=!D.N_colors-1 device,set_graphics=3 ypos=hodnota end 'LINE2':begin nastav,prof device,set_graphics=6 arrow,xpos,0,xpos,399,hsize=0,color=!D.N_colors-1 widget_control,lineprof,get_value=hodn arrow,hodn,0,hodn,399,hsize=0,color=!D.N_colors-1 device,set_graphics=3 xpos=hodn end 'ROT':begin widget_control,rotat,get_value=hodnp hodnota=hodnp/10.0 if hodnota lt 0 then strhodnota=strmid(strcompress(string(hodnota),/remove_all),0,4) $ else strhodnota=strmid(strcompress(string(hodnota),/remove_all),0,3) widget_control,rotval,set_value=strhodnota otoceni=hodnota-rotpos robraz=rot(robraz,otoceni,/INTERP) nastav,obr tvscl,robraz device,set_graphics=6 arrow,0,ypos,619,ypos,hsize=0,color=!D.N_colors-1 device,set_graphics=3 rotpos=hodnota if (prvni ne -1) then nakresli,robraz,prof,prvni,druhy,dif,xpos,dis2 if dif ne 0 then begin widget_control,pos4,get_value=black1 & widget_control,pos5,get_value=black2 black1=fix(black1(0)) & black2=fix(black2(0)) n1=najdi(robraz,black1) n2=najdi(robraz,black2) dif=abs(n1-n2) val1=strcompress(string(dif),/remove_all) widget_control,roz2,set_value=val1 endif end 'OKNO':begin widget_control,pos2,set_value=STRCOMPRESS('('+string(event.x)+','+string(event.y)+')',/rem) if event.press eq 1 then begin nakresli,robraz,prof,event.x,event.y,dif,xpos,dis2 prvni=event.x & druhy=event.y endif end 'VER':begin widget_control,pos4,get_value=black1 & widget_control,pos5,get_value=black2 black1=fix(black1(0)) & black2=fix(black2(0)) if (black1 ne 0) and (black2 ne 0) then begin n1=najdi(robraz,black1) n2=najdi(robraz,black2) dif=abs(n1-n2) val1=strcompress(string(dif),/remove_all) widget_control,roz2,set_value=val1 endif end 'NEXT1':begin widget_control,profzacx,get_value=lbcorx & lbcorx=fix(lbcorx(0)) widget_control,profkonx,get_value=rucorx & rucorx=fix(rucorx(0)) widget_control,profzacy,get_value=lbcory & lbcory=fix(lbcory(0)) widget_control,profkony,get_value=rucory & rucory=fix(rucory(0)) widget_control,pos3,get_value=pozicep widget_control,pos5,get_value=rozhrani rozhrani=fix(rozhrani(0)) & pozicep=fix(pozicep(0)) ;print,pozicep,rozhrani,dispx ;!!!!!!!!!!!!!!!!!!!!!!!!!! if (dispx ne 0) and (dif ne 0) and (rozhrani ne 0) and (pozicep ne 0)then begin part=shift(robraz(*,0:rozhrani),-dispx,0) robraz(*,0:rozhrani)=part widget_control,basep,/destroy widget_control,omenu,/destroy based=widget_base(base,/column) based1=widget_base(based,/row) drawd=widget_draw(based1,/button_events,/motion_events,uvalue='OBR2',xsize=620,ysize=570) based11=widget_base(based1,/column) plab=widget_label(based11,value='POSITION') pos2=widget_label(based11,value=' ',/frame,xsize=70,/align_center) pos4=cw_field(based11,title='start for calibration') pos5=cw_field(based11,title='end for calibration') box1=cw_field(based11,title='start of box') box2=cw_field(based11,title='end of box') based2=widget_base(based,xsize=100) nbut=widget_button(based2,value='CALIBRATE',uvalue='CAL') plot,robraz(*,pozicep),position=[0,0.1,1,0.9],xrange=[0,620],xstyle=1 ;writefit,'h:\idl\polar\o1.fts',robraz ; writefit,'h:\idl\polar\1.fts',float(robraz(*,pozicep)) ;!!!!!!!!!!!!!!!!!!!!!!!!!111 widget_control,based,/realize pocet=0 endif end 'OBR2':begin widget_control,pos2,set_value=STRCOMPRESS('('+string(event.x)+','+string(event.y)+')',/rem) if (event.press eq 1) and (pocet lt 10) then begin if pocet eq 0 then begin pozice=make_array(11,/int,value=0) & delky=make_array(11,/float,value=0.0) endif pozice(pocet)=event.x wave=6552.629 basecal=widget_base(/column) item=['6552.629','6553.785','6554.238','6555.466','6556.077','6556.806','6557.171',$ '6558.149','6559.576','6560.555','6561.007','6562.808','6564.206','6565.545','6569.22'] list = widget_droplist(basecal,value=item,uvalue='LIST',ysize=100) butt=widget_button(basecal,value='OK',uvalue='OK') widget_control,basecal,/realize xmanager,'list',basecal endif end 'CAL':begin widget_control,pos4,get_value=st & st=fix(st(0)) widget_control,box1,get_value=st1 & st1=fix(st1(0)) widget_control,pos5,get_value=en & en=fix(en(0)) widget_control,box2,get_value=en1 & en1=fix(en1(0)) if (st ne 0) and (en ne 0) and (pocet gt 0) and $ (st1 ne 0) and (en1 ne 0) then begin widget_control,based,/destroy baset=widget_base(base,/column) baset1=widget_base(baset,/row) drawt1=widget_draw(baset1,xsize=500,ysize=500) drawt2=widget_draw(baset1,xsize=500,ysize=500) baset2=widget_base(baset,/row) al1=widget_label(baset2,value='1st region',/frame) al2=widget_label(baset2,value=' ',xsize=100) bl2=widget_label(baset2,value=' ',xsize=100) cl2=widget_label(baset2,value=' ',xsize=100) al11=widget_label(baset2,value='2nd region',/frame) al22=widget_label(baset2,value=' ',xsize=100) bl22=widget_label(baset2,value=' ',xsize=100) cl22=widget_label(baset2,value=' ',xsize=100) basen=widget_base(baset,xsize=100) nbut=widget_button(basen,value='NEXT',uvalue='NEXT2') widget_control,baset,/realize !p.multi=0 for oblast=1,2 do begin pozice=pozice(0:pocet-1) & delky=delky(0:pocet-1) coef=linfit(pozice,delky) profil=make_array(620,2,/float) if oblast eq 1 then profil(*,1)=robraz(*,pozicep) else profil(*,1)=robraz(*,pozicep-dif) for i=0,619 do profil(i,0)=coef(0)+coef(1)*i if oblast eq 1 then begin nastav,drawt1 plot,profil(*,0),yrange=[6552,6572],ystyle=1 oplot,pozice,delky,psym=2 endif profil2=vyber(profil,st,en) inten=intenzity(profil2) c=10 X=smooth(inten(*,0),c) Y=smooth(inten(*,1),c) W=1.0/Y A=[20.0,0.0085,-30.0] result=curvefit(X,Y,W,A,sigma,function_name='gfunc') x=findgen(150)+80 nastav,drawt2 if oblast eq 1 then plot,x,a(0)*exp(x*a(1))+a(2) else oplot,x,a(0)*exp(x*a(1))+a(2) oplot,smooth(inten(*,0),c),smooth(inten(*,1),c),psym=1 if oblast eq 1 then calk1=a else calk2=a if oblast eq 1 then begin widget_control,al2,set_value=string(a(0)) & widget_control,bl2,set_value=string(a(1)) widget_control,cl2,set_value=string(a(2)) endif else begin widget_control,al22,set_value=string(a(0)) & widget_control,bl22,set_value=string(a(1)) widget_control,cl22,set_value=string(a(2)) endelse endfor endif end 'NEXT2':begin widget_control,baset,/destroy basepet=widget_base(base,/column) intdraw=widget_draw(basepet,xsize=800,ysize=400,/button_events,uvalue='INTER') basepet1=widget_base(basepet,xsize=100) nbut=widget_button(basepet1,value='NEXT',uvalue='NEXT3') widget_control,basepet,/realize nastav,intdraw zac1=najdi(robraz,black1) kon1=najdih(robraz,black2) mensi=robraz & mensi(*,0:(zac1-kon1))=robraz(*,kon1-dif:zac1-dif) mensi(*,zac1-kon1+1:(2*zac1-2*kon1+1))=robraz(*,kon1:zac1) mensi=mensi(*,0:(2*zac1-2*kon1+1)) boxx2=float(mensi(st1:en1,*)) mensi(*,0:zac1-kon1)=calk2(0)*exp(float(mensi(*,0:zac1-kon1))*calk2(1))+calk2(2) mensi(*,zac1-kon1+1:(2*zac1-2*kon1+1))=calk1(0)*exp(float(mensi(*,zac1-kon1+1:(2*zac1-2*kon1+1)))*calk1(1))+calk1(2) s=size(boxx2) boxx1=make_array(s(2),/float) for i=0,s(2)-1 do begin boxx1(i)=total(boxx2(*,i))/float(n_elements(boxx2(*,i))) ;mensi(*,i)=(90*mensi(*,i)/boxx1(i)) endfor plot,boxx1 body=make_array(100,2) end 'NEXT3':begin if pocetint gt 0 then begin s=size(mensi) U=findgen(s(2)) X=body(0:pocetint-1,0) Y=body(0:pocetint-1,1) R=interpol(Y,X,U) oplot,U,R,color=100 wait,2 for i=0,s(2)-1 do mensi(*,i)=90.0*float(mensi(*,i))/float(R(i)) widget_control,basepet,/destroy basec=widget_base(base) drawc=widget_draw(basec,xsize=620,ysize=s(2)/2) widget_control,basec,/realize mensi1=mensi(*,0:zac1-kon1) mensi2=mensi(*,zac1-kon1+1:(2*zac1-2*kon1+1)) mensivysl=make_array(s(1),zac1-kon1,/byte) mensivysl=float(mensi1)-float(mensi2) tvscl,mensivysl ;-------------------profily------- if (lbcorx ne 0) and (lbcory ne 0) and (rucorx ne 0) and (rucory ne 0) then begin horni=mensi2(lbcorx:rucorx,(lbcory-kon1):(rucory-kon1)) ips1=make_array(rucorx-lbcorx+1,value=0,/double) ;ips1=horni(*,0) for i=0,(rucory-lbcory) do ips1=ips1+double(horni(*,i)) ips1=ips1/double(rucory-lbcory+1) & ips1=0.9*ips1/90.0 dolni=mensi1(lbcorx:rucorx,(lbcory-kon1):(rucory-kon1)) ips2=make_array(rucorx-lbcorx+1,value=0,/double) ;ips2=dolni(*,0) for i=0,(rucory-lbcory) do ips2=ips2+double(dolni(*,i)) ips2=ips2/double(rucory-lbcory+1) & ips2=0.9*ips2/90.0 res=poly_fit(pozice,delky,1) iks=float(findgen(620)) & iks=res(0)+iks*res(1) & iks=iks(lbcorx:rucorx) profil1=dblarr(n_elements(iks),2) & profil2=dblarr(n_elements(iks),2) profil1(*,0)=iks & profil2(*,0)=iks & profil1(*,1)=ips1 & profil2(*,1)=ips2 writefits,'profil1.fts',profil1 & writefits,'profil2.fts',profil2 basehlas=widget_base() labhlas=widget_label(basehlas,value='Profiles have been saved.') widget_control,basehlas,/realize & wait,2 widget_control,basehlas,/destroy ;tvscl,mensi2 & plots,lbcorx,lbcory-kon1,psym=2,/device ;plots,rucorx,rucory-kon1,psym=2,/device & wait,2 ;tvscl,mensi1 & plots,rucorx,rucory-kon1,psym=2,/device ;plots,lbcorx,lbcory-kon1,psym=2,/device endif ;---------------------------- widget_control,f2,sensitive=1 ;widget_control,f22,sensitive=1 endif end 'INTER':begin if event.press eq 1 then begin plots,event.x,event.y,psym=2,/device coord=convert_coord(event.x,event.y,/device,/to_data) body(pocetint,0)=coord(0) & body(pocetint,1)=coord(1) pocetint=pocetint+1 endif end ;'SAVE2':begin ; end endcase end pro polar COMMON profily,profzacx,profkonx,profzacy,profkony,lbcorx,rucorx,lbcory,rucory COMMON slid,line,rotat,rotval,f2,obr,prof,lineprof,roz2,o2,dis2;line3 COMMON dalsi,pos2,pos3,pos4,pos5 COMMON baze,base,basep,based,omenu,basepet COMMON knof,f1 device,set_graphics=3 base=widget_base(/row,mbar=bar,xsize=1020,ysize=700) fmenu=widget_button(bar,value='FILE',/menu) f1=widget_button(fmenu,value='LOAD',uvalue='LOAD') f2=widget_button(fmenu,value='SAVE',uvalue='SAVE') ; f22=widget_button(fmenu,value='SAVE PROFILES',uvalue='SAVE2') f3=widget_button(fmenu,value='QUIT',uvalue='QUIT') omenu=widget_button(bar,value='OPTIONS',/menu) o2=widget_button(omenu,value='VERTICAL DIFFERENCE',uvalue='VER') basep=widget_base(base,/row) base1=widget_base(basep,/column) obr=widget_draw(base1,xsize=620,ysize=570,/button_events,/motion_events,uvalue='OKNO') base3=widget_base(base1,/row) roz1=widget_label(base3,value='VERTICAL DIFFERENCE OF REGIONS') roz2=widget_label(base3,value=' ',/frame,xsize=70,/align_center) dis1=widget_label(base3,value='DISPERSION (px)') dis2=widget_label(base3,value=' ',/frame,xsize=70,/align_center) pos1=widget_label(base3,value='POSITION') pos2=widget_label(base3,value=' ',/frame,xsize=70,/align_center) base4=widget_base(base1,/row,xsize=500) pos3=cw_field(base4,title='y profile position') pos4=cw_field(base4,title='1st region') pos5=cw_field(base4,title='2nd region') base5=widget_base(base1,xsize=100) nbut1=widget_button(base5,value='NEXT',uvalue='NEXT1') base2=widget_base(basep,/column) prof=widget_draw(base2,xsize=370,ysize=400) lineprof=widget_slider(base2,title='Line motion (profiles)',uvalue='LINE2', $ value=10,min=0,max=369) line=widget_slider(base2,title='Line motion (image)',uvalue='LINE', $ value=300,min=0,max=569) rotval=widget_label(base2,value='0.0',xsize=200,/align_center) rotat=widget_slider(base2,title='Image rotation',uvalue='ROT', $ value=0,min=-30,max=30,/suppress_value) base6=widget_base(base2,/row) profzacx=cw_field(base6,title='1st corner (x)') profzacy=cw_field(base6,title='1nd corner (y)') base7=widget_base(base2,/row) profkonx=cw_field(base7,title='2nd corner (x)') profkony=cw_field(base7,title='2nd corner (y)') widget_control,line,sensitive=0 widget_control,rotat,sensitive=0 widget_control,f2,sensitive=0 ;widget_control,f22,sensitive=0 widget_control,rotval,sensitive=0 widget_control,lineprof,sensitive=0 widget_control,base,/realize widget_control,obr,sensitive=0 widget_control,o2,sensitive=0 xmanager,'polar',base end