; ; Mauna Loa Image differencing program. ; ; This widget program operates on two Mauna Loa .slit format images and ; makes subtractions. Users can also make measurements of events in the ; solar corona using this program. ; ; Drafted by Tony Darnell 26 Nov 1996 ; ; HISTORY: ; ; 9 Dec 96: Fixed problem with logical unit crashes, added FREE_LUN to ; extract procedure. ; 21 Jan 97: Corrected problem with color table shift when measuring from ; direct image. ; 8 Aug 97: Rewrote major portions of code to make program more efficient. ; Repackaged the widgets in a more user friendly manner. Changed ; name from rpB1.pro to df.pro. ; 22 Jan 98: Added compatability with FITS images. ; 2007-7-9 (sitongia) add SECCHI compatibility. ; PRO df_event,event COMMON widgets,back_list,fore_list,meas_window,buttons,path_box,img,image, $ filelist,backimg,foreimg,hdu1,hdu2,text_array,minslider,data_box, $ maxslider,months,time1,time2,direct_flag,back_hdu,fore_hdu,ext, $ meas_array,numpress,buttons2,forefile,err_buttons,dfit,fit,ltest, $ plot1,plot2,plot3,plot_info,exten,exten_b,filepath,panel3,xcenter,ycenter CASE event.id OF back_list:BEGIN ;{ WIDGET_CONTROL,path_box,GET_VALUE=path ;IF (STRMID(path,STRLEN(path)-1,1) NE '/') THEN path=path+'/' path=path+'/' backfile=filelist(event.index) time1=STRMID(backfile,7,2)+':'+STRMID(backfile,10,2) ;CATCH,file_err ;IF (file_err NE 0) THEN BEGIN ; junk=WIDGET_MESSAGE(!ERR_STRING,/ERROR,TITLE='Bummer') ; RETURN ;ENDIF ext=STRMID(backfile,STRLEN(backfile)-3,3) pre=STRMID(backfile,0,3) IF (ext EQ 'lit') THEN BEGIN close,1 openr,1,backfile readu,1,backimg close,1 ENDIF IF (ext EQ 'fts') OR (ext EQ '.gz') OR (pre EQ 'ecd') THEN BEGIN backimg=READFITS(backfile,back_hdu) ;backimg=rfits(backfile,header=back_hdu) ;Modify header for STEREO data obs=fxpar(back_hdu,'OBSRVTRY') obs_err=!err IF (obs_err NE -1) THEN BEGIN IF (STRCMP(obs,'STEREO',6)) THEN BEGIN fxaddpar,back_hdu,'TELESCOP',obs datetime=fxpar(back_hdu,'DATE-OBS') strings=strsplit(datetime,'T',/EXTRACT) fxaddpar,back_hdu,'DATE-OBS',strings[0] fxaddpar,back_hdu,'TIME-OBS',strings[1] ENDIF ENDIF ELSE BEGIN tmp=readfits(backfile,exten_b,exten_no=1) ENDELSE bbso_tst=STRING(fxpar(back_hdu,'ORIGIN')) IF (bbso_tst EQ 'BBSO ') THEN BEGIN tmp1=fxpar(back_hdu,'CENX') tmp2=fxpar(back_hdu,'CENY') fxaddpar,back_hdu,'CRPIX1',tmp1 fxaddpar,back_hdu,'CRPIX2',tmp2 ENDIF ENDIF sz=SIZE(foreimg) backsz=SIZE(backimg) WIDGET_CONTROL,img,GET_VALUE=img_Id WSET,img_Id WIDGET_CONTROL,img,DRAW_XSIZE=backsz(1),DRAW_YSIZE=backsz(2) WIDGET_CONTROL,minslider,GET_VALUE=mn WIDGET_CONTROL,maxslider,GET_VALUE=mx IF (sz(1) NE 0) THEN $ diffimg=BYTSCL(foreimg-backimg,MIN=mn,MAX=mx,TOP=230) $ ELSE diffimg=backimg IF (ext EQ 'lit') THEN $ diffimg=it_drawcircle(diffimg,/SLIT) IF (ext EQ 'fts') OR (ext EQ '.gz') THEN $ diffimg=it_drawcircle(diffimg,/FTS,HDR=back_hdu) ;dispimg=BYTSCL(diffimg,MIN=mn,MAX=mx,TOP=230) ;tv,dispimg TV,diffimg WIDGET_CONTROL,back_list,SET_UVALUE=backfile END ;} fore_list:BEGIN ;{ ;dfcol minval=-10 maxval=10 WIDGET_CONTROL,path_box,GET_VALUE=path ;IF (STRMID(path,STRLEN(path)-1,1) NE '/') THEN path=path+'/' path=path+'/' forefile=filelist(event.index) ;CATCH,file_err ;IF (file_err NE 0) THEN BEGIN ; junk=WIDGET_MESSAGE(!ERR_STRING,/ERROR,TITLE='Bummer') ; RETURN ;ENDIF ext=STRMID(forefile,STRLEN(forefile)-3,3) pre=STRMID(forefile,0,3) IF (ext EQ 'lit') THEN BEGIN close,1 openr,1,forefile readu,1,foreimg close,1 ENDIF IF (ext EQ 'fts') OR (ext EQ '.gz') OR (pre EQ 'ecd') THEN BEGIN foreimg=READFITS(forefile,fore_hdu) ;foreimg=rfits(forefile,header=fore_hdu) lasco_test=STRCOMPRESS(fxpar(fore_hdu,'INSTRUME'),/REMOVE_ALL) l_sz=SIZE(foreimg) IF (lasco_test EQ 'LASCO') AND (l_sz(1) EQ 512) THEN BEGIN new_platescl=FLOAT(fxpar(fore_hdu,'PLATESCL'))*2 fxaddpar,fore_hdu,'PLATESCL',new_platescl ENDIF ;Modify header for STEREO data obs=fxpar(fore_hdu,'OBSRVTRY') obs_err=!err IF (obs_err NE -1) THEN BEGIN IF (STRCMP(obs,'STEREO',6)) THEN BEGIN fxaddpar,fore_hdu,'TELESCOP',obs datetime=fxpar(fore_hdu,'DATE-OBS') strings=strsplit(datetime,'T',/EXTRACT) fxaddpar,fore_hdu,'DATE-OBS',strings[0] fxaddpar,fore_hdu,'TIME-OBS',strings[1] ENDIF ENDIF ELSE BEGIN tmp=readfits(forefile,exten,exten_no=1) ENDELSE bbso_tst=STRING(fxpar(fore_hdu,'ORIGIN')) IF (bbso_tst EQ 'BBSO ') THEN BEGIN tmp1=fxpar(fore_hdu,'CENX') tmp2=fxpar(fore_hdu,'CENY') fxaddpar,fore_hdu,'CRPIX1',tmp1 fxaddpar,fore_hdu,'CRPIX2',tmp2 ENDIF ENDIF WIDGET_CONTROL,xcenter,SET_VALUE=fxpar(fore_hdu,'CRPIX1') WIDGET_CONTROL,ycenter,SET_VALUE=fxpar(fore_hdu,'CRPIX2') WIDGET_CONTROL,img,GET_VALUE=img_Id WSET,img_Id WIDGET_CONTROL,minslider,GET_VALUE=mn WIDGET_CONTROL,maxslider,GET_VALUE=mx sz=SIZE(foreimg) IF (sz(1) NE 0) THEN $ diffimg=BYTSCL(foreimg-backimg,MIN=mn,MAX=mx,TOP=230) $ ELSE diffimg=backimg IF (ext EQ 'lit') THEN $ diffimg=it_drawcircle(diffimg, /SLIT) IF (ext EQ 'fts') OR (ext EQ '.gz') THEN $ diffimg=it_drawcircle(diffimg,/fts,HDR=fore_hdu) IF (pre EQ 'ecd') THEN $ diffimg=BYTSCL((foreimg-backimg)>minval