; Program for overlaping two fits images pro fitsoverlap_r_event, event ;This procedure is the event handler for set of buttons. WIDGET_CONTROL, event.id, GET_UVALUE = eventvalue device, decomposed=0 loadct,3 ;jk: changes > sxpar err > solution: max. intensity (1) of graphs is maximum intensity of image, not of selected segment only ; 1 point fit err. > wrong names of variables (copy-paste mistake probably) ; ?: location: search for: datamax ;slitrotate is separate procedure, it is used before One point fit ;or before Two points fit, only if necessary to rotate slit case eventvalue of 'slitrotate':begin file=dialog_pickfile() image=readfits(file) imagedims=size(image, /dimensions) window, 0, xsize=imagedims[0], ysize=imagedims[1] tvscl, image !mouse.button = 1 i=0 x0s=intarr(2) y0s=intarr(2) while (i lt 2) do begin cursor, x,y, /device, /down case !mouse.button of 1: begin x0s[i]=x y0s[i]=y i=i+1 end 4: i=i-1 endcase check=i-1 if check lt 0 then begin i=0 check=0 tvscl, image endif else begin tvscl, image plots, x0s[0:check],y0s[0:check], psym=1, /device endelse endwhile wdelete, 0 vec0s=float([(x0s[1]-x0s[0]),(y0s[1]-y0s[0])]) c0=vec0s[1]/(vec0s[0]+0.001) u0=atan(c0)*(180/!dpi) if vec0s[0] lt 0 then u0=u0+180 else begin if u0 lt 0 then u0=u0+360 end urots=u0-90 urotrads=double(abs((urots*(!dpi/180)))) a=float(max(imagedims)) b=float(min(imagedims)) r=(sqrt(a^2+b^2))/2 sizemods=round(r-b/2) end ;open HMI image and determine solar radius in pixels to get acrs/pixel ratio needed ;for scaling the background image ;we will call background image (or picture) the image that will not undergo any changes ;that corrupt the data stored in it, and the one that will be scaled in acrseconds ;the foreground picture (also unscaled) will be the picture to undergo the ;processing and fit the background picture with regards to size, position and orientation 'radius' : begin ;open file to read previously saved radiuses common share2, field2 common sharevar7, r1 common share1, field1 common sharevar1, r0 cesta = dialog_pickfile() openr, 3, cesta readf, 3 , r0, r1 close, 3 ;print values for check print, r0 print, r1 end 'HMI' : begin common share1, field1 common sharevar1, r0 file=dialog_pickfile(/read) ;reads the file path specified by the user in the native enviroment of the operating system widget_control,field1,set_value=file ;sets the value for field widget, for the user to have reference which file has he chosen widget_control,field1,/realize r0=radiusfits(file) ;calls function to calculate solar radius in pixels end ;open the unscaled image with limb, determine radius and calculate resolution ;the code does the same as above, only for the unscaled picture 'unscale' : begin common share2, field2 common sharevar7, r1 file=dialog_pickfile(/read) widget_control,field2,set_value=file widget_control,field2,/realize r1=radiusfits(file) ;write variables r0 and r1 to file otazka = dialog_message("Would you like to save measured radius into file radius.dat (existing data will be overwritten)?", /question, title="Save to radius.dat") case otazka of 'Yes': begin slozka=dialog_pickfile(/directory, title='Select the directory to save radius.dat') fname=slozka + 'radius.dat' openw, 2, fname printf,2, r0, r1 close, 2 end else:print, "OK" endcase ;;open first image without limb and determine size end 'firstimage':begin common share3, field3 common sharevar2, image1, imagedims1, x0,y0 file=dialog_pickfile(/read) image1=readfits(file, header1) ;reads image and header to two separete arrays of appropriate type (two dimensional number and string arrays respectively) imagedims1=size(image1, /dimensions) ;reads the image dimensions - easier and faster than to manipulate and read from header widget_control,field3,set_value=file widget_control,field3,/realize ;pick two disctinctive points on scaled image ;the draw widget is used to display the pictures, because window function does not ;support scrollbars, which are important for pictures that are bigger than the screen based=widget_base(title=file , xsize=700, ysize=700) ;create a base to fit the screen draw=widget_draw(based, xsize=imagedims1[0], ysize=imagedims1[1], $ x_scroll_size=640, y_scroll_size=650) ;create a draw widget for displaying images widget_control, based, /realize widget_control, draw, get_value=windex ;get value of window index (draw widget index) wset, windex ;set the created widget to be active tvscl, image1 ;display the image on the active widget i=0 ;set counter to zero x0=intarr(2) ;create an array for x coordinates to be stored y0=intarr(2) ;create an array for y coordinates to be stored while (i lt 2) do begin ;waits until two points are placed on the picture cursor, x,y, /device, /down ;loads current pointer device coordinates into x and y variables, with "button is down" (any button is pressed) triger case !mouse.button of ;reads the system variable !mouse.button that stores the last button action on the mouse: 1 being left and 4 right mouse button 1: begin x0[i]=x y0[i]=y i=i+1 end 4: i=i-1 endcase ;in case left mouse button is pressed it stores the coordinates into variables, and right mouse button takes the user one step back by lowering the counter by one check=i-1 ;a variable used for checking the counter status, used for easy error evasion if check lt 0 then begin i=0 check=0 tvscl, image1 ;if the check variable is (-1) then reset the process ;this is used when the counter is zero (no points placed on the image) and the user presses the right mouse button - as mentioned above this is error evasion endif else begin tvscl, image1 plots, x0[0:check],y0[0:check], psym=1, color='ff'xl, /device endelse ;if the user presses the right mouse button, the point is marked with a red cross on the picture endwhile widget_control, based, /destroy ;closes the widget so it doesn't take up memory end ;open seconond image without limb and determine size ;the same process described above is repeated for the second picture (the one to be ;processed) only the variable names used to store the measured values are different 'secondimage':begin common share4, field4 common sharevar2, image1, imagedims1, x0,y0 common sharevar3, x1,y1, image2, imagedims2 common sharevar4, urot file=dialog_pickfile(/read) image2=readfits(file, header2) image2= rebin(image2, 640, 512) ; rebinning of sj imagedims2=size(image2, /dimensions) widget_control,field4,set_value=file widget_control,field4,/realize ;pick two distinctive points on unscaled image based=widget_base(title=file , xsize=700, ysize=700) draw=widget_draw(based, xsize=imagedims2[0], ysize=imagedims2[1], $ x_scroll_size=640, y_scroll_size=650) widget_control, based, /realize widget_control, draw, get_value=windex wset, windex tvscl, image2 !mouse.button = 1 i=0 x1=intarr(2) y1=intarr(2) while (i lt 2) do begin cursor, x,y, /device, /down case !mouse.button of 1: begin x1[i]=x y1[i]=y i=i+1 end 4: i=i-1 endcase check=i-1 if check lt 0 then begin i=0 check=0 tvscl, image2 endif else begin tvscl, image2 plots, x1[0:check],y1[0:check], psym=1, color='ff'xl, /device endelse endwhile widget_control, based, /destroy end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;repeat (jfk) ;open first image without limb and determine size 'repeatit':begin common share3, field3 common sharevar2, image1, imagedims1, x0,y0 imagedims1=size(image1, /dimensions) ;reads the image dimensions - easier and faster than to manipulate and read from header widget_control,field3,set_value=file widget_control,field3,/realize ;pick two disctinctive points on scaled image ;the draw widget is used to display the pictures, because window function does not ;support scrollbars, which are important for pictures that are bigger than the screen based=widget_base(title=file , xsize=700, ysize=700) ;create a base to fit the screen draw=widget_draw(based, xsize=imagedims1[0], ysize=imagedims1[1], $ x_scroll_size=640, y_scroll_size=650) ;create a draw widget for displaying images widget_control, based, /realize widget_control, draw, get_value=windex ;get value of window index (draw widget index) wset, windex ;set the created widget to be active tvscl, image1 ;display the image on the active widget i=0 ;set counter to zero x0=intarr(2) ;create an array for x coordinates to be stored y0=intarr(2) ;create an array for y coordinates to be stored while (i lt 2) do begin ;waits until two points are placed on the picture cursor, x,y, /device, /down ;loads current pointer device coordinates into x and y variables, with "button is down" (any button is pressed) triger case !mouse.button of ;reads the system variable !mouse.button that stores the last button action on the mouse: 1 being left and 4 right mouse button 1: begin x0[i]=x y0[i]=y i=i+1 end 4: i=i-1 endcase ;in case left mouse button is pressed it stores the coordinates into variables, and right mouse button takes the user one step back by lowering the counter by one check=i-1 ;a variable used for checking the counter status, used for easy error evasion if check lt 0 then begin i=0 check=0 tvscl, image1 ;if the check variable is (-1) then reset the process ;this is used when the counter is zero (no points placed on the image) and the user presses the right mouse button - as mentioned above this is error evasion endif else begin tvscl, image1 plots, x0[0:check],y0[0:check], psym=1, color='ff'xl, /device endelse ;if the user presses the right mouse button, the point is marked with a red cross on the picture endwhile widget_control, based, /destroy ;closes the widget so it doesn't take up memory ;open seconond image without limb and determine size ;the same process described above is repeated for the second picture (the one to be ;processed) only the variable names used to store the measured values are different imagedims2=size(image2, /dimensions) widget_control,field4,set_value=file widget_control,field4,/realize ;pick two distinctive points on unscaled image based=widget_base(title=file , xsize=700, ysize=700) draw=widget_draw(based, xsize=imagedims2[0], ysize=imagedims2[1], $ x_scroll_size=640, y_scroll_size=650) widget_control, based, /realize widget_control, draw, get_value=windex wset, windex tvscl, image2 !mouse.button = 1 i=0 x1=intarr(2) y1=intarr(2) while (i lt 2) do begin cursor, x,y, /device, /down case !mouse.button of 1: begin x1[i]=x y1[i]=y i=i+1 end 4: i=i-1 endcase check=i-1 if check lt 0 then begin i=0 check=0 tvscl, image2 endif else begin tvscl, image2 plots, x1[0:check],y1[0:check], psym=1, color='ff'xl, /device endelse endwhile widget_control, based, /destroy end ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;difference=abs(image1-image2) ;writefits,'difference.fits',difference ;tvscl,difference ;print,'difference done' ; mix=long(a*float(image1)+(1-a)*float(image2)) ;creates a new image. ;the result of this operation is the sum of two matching pixels from each image ;timed by (a) and (1-a) for background and foreground image respectively. ;this appears to the human eye as transparency mixdims=float(size(mix, /dimensions)) based=widget_base(title='final fit' , xsize=700, ysize=700) draw=widget_draw(based, xsize=mixdims[0], ysize=mixdims[1], $ x_scroll_size=640, y_scroll_size=650) widget_control, based, /realize widget_control, draw, get_value=windex wset, windex tvscl, mix ;********* export of the mixed picture ********** otazka = dialog_message("Would you like to save the image? ?", /question, title="Save it?") case otazka of 'Yes': begin slozka=dialog_pickfile(/directory) for i=1, 20 do begin fname = slozka + 'transparency_' + string(i) + '.fits' vysledek_testu = file_test(fname) if vysledek_testu eq 0 then begin writefits, fname, mix break endif if i eq 20 then begin zprava = 'You have reached maximum of stored files. Please remove or rename some of them.' x = dialog_message(zprava, /error) endif endfor end else:print, "OK" endcase ;************************************************ ticksize=round(10/res1) plot, [0,mixdims[0]],[0,mixdims[1]], /nodata, /device, /noerase, $ position=[0,0,mixdims[0],mixdims[1]], $ xtickinterval=ticksize, ytickinterval=ticksize end 'final':begin common sharevar2, image1, imagedims1, x0,y0 common sharevar3, x1,y1, image2, imagedims2 common sharevar6, status common get, mix a=status ;the value is taken from the slider in the interface ; ;difference=abs(image1-image2) ;writefits,'difference.fits',difference ;tvscl,difference ;print,'difference done' ; ;mix=long(a*float(image1)+(1-a)*float(image2)) ;creates a new image. ;jk> mix=[[[IMAGE1]], [[IMAGE2]],[[IMAGE1]]] ; ;labeL33=widget_label(buttonbase2, value='', ysize=15) ;coeffbutton = widget_button(buttonbase2, value= 'Compute it all', uvalue='compute') ;