;+ ; ; PROJECT: CHIANTI ; ; CHIANTI is an atomic database package for the calculation of ; astrophysical emission line spectra. It is a collaborative project ; involving Ken Dere (Naval Research Laboratory, Washington DC), ; Brunella Monsignori-Fossi and Enrico Landi (Arcetri Observatory, ; Florence), and Helen Mason and Peter Young (DAMTP, Cambridge Univ.). ; ; ; NAME: TEMP_PLOTTER ; ; PURPOSE: ; ; A widget-based routine to allow the analysis of temperature ; sensitive ratios. ; ; EXPLANATION: ; ; This is a simplified version of DENS_PLOTTER for studying temperature ; sensitive ratios. I hope to combine TEMP_PLOTTER and DENS_PLOTTER ; into one routine someday as they have almost the same code. ; ; CALLING SEQUENCE: ; ; TEMP_PLOTTER, IZ, ION [ , EM, PATH=PATH ] ; ; EXAMPLES: ; ; TEMP_PLOTTER, 26, 13 ; Fe XIII ; ; TEMP_PLOTTER, 10, 6 ; Ne VI ; ; TEMP_PLOTTER, 26, 13, PATH='/home/new_chianti_data' ; ; INPUTS: ; ; IZ: The atomic number of the ion ; ION: The spectroscopic number of the ion (e.g., 12 = XII) ; ; OPT. INPUTS: ; ; EM: Save the displayed emissivities to structure EM. This ; structure is simply the structure EMISS_SELECT used in ; the routine. ; ; PATH: Data in the CHIANTI format that is not in the CHIANTI ; database can be read by specifying the directory in which ; it lies through PATH. ; ; CALLS: ; ; EMISS_CALC, READ_IONEQ, EMISS_SELECT, CHOOSE_IONEQ ; ; HISTORY: ; ; Ver.1: PRY, 15-SEP-97. ; Ver.2: PRY, 6-JUL-98, added EM and PATH ; Ver.3: PRY, 5-SEP-98, added call to choose_ioneq ; Ver.4: PRY, 21-Dec-00, removed set_plot,'x' following help from ; Bill Thompson ; Ver.5: PRY, 27-Dec-00, changed switch to tst1 for IDL v5.4 ; ; CONTACT: ; ; Peter Young, CfA, pyoung@cfa.harvard.edu ;- ;------------------------------------------------------------------------------ PRO DENS_FINDER, INDEX ;------------------------------------------------------------------------------ COMMON emiss_data,iz,ion,emiss,lo_temp,hi_temp,tint,dens,temp COMMON select,emiss_sel COMMON sliders,lo_w,hi_w,min_w,max_w COMMON plotting,lims,set_scale,all I_num=emiss_sel(index).obs & I_den=emiss_sel(0).obs sig_num=emiss_sel(index).sig & sig_den=emiss_sel(0).sig obs_ratio=I_num/I_den sig_ratio=SQRT((I_num*sig_den)^2 + (I_den*sig_num)^2)/(I_den^2) ratio=emiss_sel(index).em/emiss_sel(0).em ;-------------------- ; Work out observed density ; result=MIN(abs(ratio-obs_ratio),ind) IF (ind LT 2) OR (ind GT N_ELEMENTS(temp)-3) THEN BEGIN result=DIALOG_MESSAGE(['The ratio lies close to the edges of the plot.', $ 'Try a different temperature range.'],/info) RETURN ENDIF tempi=FINDGEN(41)*tint/10. + temp(ind-2) rati=SPLINE(temp(ind-2:ind+2),ratio(ind-2:ind+2),tempi) result=MIN(abs(rati-obs_ratio),ind) oplot,[tempi(ind),tempi(ind)],[rati(ind),rati(ind)],psym=6,symsiz=2 oplot,[tempi(ind),tempi(ind)],[rati(ind)+sig_ratio,rati(ind)-sig_ratio] PRINT,format='("Observed ratio: ",f8.3,"+/-",f8.3)',obs_ratio,sig_ratio PRINT,format='("Predicted temp: ",f5.2)',tempi(ind) emiss_sel(index).dens=tempi(ind) ;-------------------- ;--------------------[O] result=MIN(abs(ratio-(obs_ratio+sig_ratio)),ind) IF (ind LT 2) OR (ind GT N_ELEMENTS(temp)-3) THEN BEGIN dens1=-1 ENDIF ELSE BEGIN tempi=FINDGEN(41)*tint/10. + temp(ind-2) rati=SPLINE(temp(ind-2:ind+2),ratio(ind-2:ind+2),tempi) ; result=MIN(abs(rati-(obs_ratio+sig_ratio)),ind) ; dens1=tempi(ind) ENDELSE ;--------------------[O] ;--------------------(O) result=MIN(abs(ratio-(obs_ratio-sig_ratio)),ind) IF (ind LT 2) OR (ind GT N_ELEMENTS(temp)-3) THEN BEGIN dens2=-1 ENDIF ELSE BEGIN tempi=FINDGEN(41)*tint/10. + temp(ind-2) rati=SPLINE(temp(ind-2:ind+2),ratio(ind-2:ind+2),tempi) ; result=MIN(ABS(rati-(obs_ratio-sig_ratio)),ind) ; dens2=tempi(ind) ; PRINT,format='("Lower limit: ",e10.2)',dens2 ENDELSE ;--------------------(O) tst1=((dens2 EQ -1) AND (dens1 EQ -1))+(dens2 EQ -1) ; CASE tst1 OF ; 0: BEGIN ;---dens2 not equal to -1 IF (dens2 GE emiss_sel(index).dens) THEN BEGIN emiss_sel(index).densup=dens2 emiss_sel(index).denslo=dens1 ENDIF ELSE BEGIN emiss_sel(index).densup=dens1 emiss_sel(index).denslo=dens2 ENDELSE END ; 1: BEGIN ;---only dens2 equal to -1 IF (dens1 GE emiss_sel(index).dens) THEN BEGIN emiss_sel(index).densup=dens1 emiss_sel(index).denslo=dens2 ENDIF ELSE BEGIN emiss_sel(index).densup=dens2 emiss_sel(index).denslo=dens1 ENDELSE END ; 2: BEGIN ;---dens1 and dens2 equal to -1 emiss_sel(index).densup=-1 emiss_sel(index).denslo=-1 END ; ENDCASE IF ((obs_ratio+sig_ratio) GT MAX(ratio)) THEN BEGIN ind=WHERE(ratio EQ MAX(ratio)) IF temp(ind(0)) GT emiss_sel(index).dens $ THEN emiss_sel(index).densup=-1 $ ELSE emiss_sel(index).denslo=-1 ENDIF IF ((obs_ratio-sig_ratio) LT MIN(ratio)) THEN BEGIN ind=WHERE(ratio EQ MIN(ratio)) IF temp(ind(0)) GT emiss_sel(index).dens $ THEN emiss_sel(index).densup=-1 $ ELSE emiss_sel(index).denslo=-1 ENDIF END ;;----------------------------------------------------------------------------- PRO INDEX_EXTRACTOR, I, INDEX=INDEX, PLOT_LABEL=PLOT_LABEL ;------------------------------------------------------------------------------ ; This procedure has a dual purpose: (i) to extract `emiss' indices from ; `emiss_sel' and, (ii) create labels that will be displayed on the plot ; window. ; ; The lines that comprise the blend are contained in emiss_sel.label ; as, e.g., '203.79+203.80'. This routine separates this string into ; the separate wavelengths and looks in emiss.lambda to see which ; indices they correspond to. The set of indices are output through INDEX. ; ; I is the index of blend in emiss_sel. E.g., for the denominator I=0. COMMON emiss_data,iz,ion,emiss,lo_temp,hi_temp,tint,dens,temp COMMON select, emiss_sel n=emiss_sel(i).n_ind - 1 ; the no. of lines in blend index=intarr(n+1) result=STR_SEP(emiss_sel(i).label,'+') IF N_ELEMENTS(index) NE 0 THEN FOR j=0,n DO $ ; index(j)=WHERE(emiss.lambda EQ FLOAT(result(j))) index(j)=WHERE(result(j) EQ STRTRIM(STRING(emiss.lambda),2)) IF N_ELEMENTS(plot_label) THEN BEGIN plot_label=result(0) IF n GT 0 THEN FOR j=1,n DO plot_label=plot_label+'!c'+result(j) ENDIF END ;------------------------------------------------------------------------------ PRO TEMP_PLOT ;------------------------------------------------------------------------------ ; This is where the line ratios get plotted. The common block `plotting' is ; used to denote what type of scaling is being used (set_scale) and whether ; all lines are plotted or just selected lines (all) COMMON emiss_data,iz,ion,emiss,lo_temp,hi_temp,tint,dens,temp COMMON select,emiss_sel COMMON sliders,lo_w,hi_w,min_w,max_w COMMON plotting,lims,set_scale,all ;-------------------------------< ; The following definition creates space at the side of the plot for ; displaying labels. To change space, change 0.8 to a different value. ; nt=n_elements(temp) width=(max(temp)-min(temp))/0.8 xrange=[min(temp), width + min(temp)] ;-------------------------------< zion2spectroscopic,iz,ion,title title=title+' line ratios relative to '+emiss_sel(0).label IF all eq 0 THEN BEGIN ;;----------------; PLOT SELECTED LINES ; IF set_scale EQ 1 THEN BEGIN ;---get y-scale for plot yrange=lims ENDIF ELSE BEGIN max_rat=0. FOR i=1,4 DO BEGIN max_i=MAX(emiss_sel(i).em/emiss_sel(0).em) IF max_i GT max_rat THEN max_rat=max_i ENDFOR yrange=[0.,1.15*max_rat] ENDELSE ; line_label=strarr(5) ;---construct the line labels FOR i=0,4 DO BEGIN IF emiss_sel(i).n_ind NE -1 THEN BEGIN result='' index_extractor,i,plot_label=result line_label(i)=result ENDIF ENDFOR ; PLOT,temp,emiss_sel(1).em/emiss_sel(0).em,XSTY=1, $ ;---plot first ratio XRANGE=xrange,YTICKLEN=-0.015, $ YRANGE=yrange,YSTY=1,XTICKLEN=-0.015,TITLE=title, $ XTITLE='Log!d10!n (Electron temperature [K])',$ YTITLE='Ratio' ; XYOUTS,min(temp)+width*0.83, $ ;---add first label emiss_sel(1).em(nt-1)/emiss_sel(0).em(nt-1),$ line_label(1) ; IF emiss_sel(1).obs NE 0. THEN dens_finder,1 ;--add observed ratio ; IF emiss_sel(2).label NE '' THEN oplot,temp,emiss_sel(2).em/emiss_sel(0).em ; IF emiss_sel(3).label NE '' THEN oplot,temp,emiss_sel(2).em/emiss_sel(0).em ; ; ENDIF ELSE BEGIN ;-------; PLOT ALL LINES IN WAVELENGTH RANGE ; index=WHERE(emiss.lambda GE lo_w AND emiss.lambda LE hi_w) ; IF index(0) EQ -1 THEN BEGIN ;---no lines in specified range result=WIDGET_MESSAGE('No lines in specified range',/info) ENDIF ELSE BEGIN IF set_scale EQ 1 THEN BEGIN ;---get y-scale for plot yrange=lims ENDIF ELSE BEGIN max_rat=0. FOR i=0,nt-1 DO BEGIN max_i=MAX(emiss(index).em(i)/emiss_sel(0).em(i),m_ind) IF max_i GT max_rat THEN max_rat=max_i ENDFOR yrange=[0.,1.15*max_rat] ENDELSE ; line_label=strtrim(string(format='(f12.3)',emiss(index).lambda),2) ; PLOT,xrange,yrange,/NODATA,YSTY=1,XSTY=1, $ ;---show plot axes TITLE=title,XTICKLEN=-0.015,YTICKLEN=-0.015, $ XTITLE='Log!d10!n (Temperature [K])',$ YTITLE='Ratio' ; FOR i=1,N_ELEMENTS(index) DO BEGIN OPLOT,temp,emiss(index(i-1)).em(*)/emiss_sel(0).em ;---plot lines ; XYOUTS,min(temp)+width*0.83,$ ;---add labels emiss(index(i-1)).em(nt-1)/emiss_sel(0).em(nt-1),$ line_label(i-1) ENDFOR ENDELSE ; ENDELSE END ;------------------------------------------------------------------------------ PRO DENS_MAIN_Event, Event ;------------------------------------------------------------------------------ COMMON emiss_data,iz,ion,emiss,lo_temp,hi_temp,tint,dens,temp COMMON select,emiss_sel COMMON sliders,lo_w,hi_w,min_w,max_w COMMON plotting,lims,set_scale,all COMMON Comm, plot_rat_id, plot_spec_id COMMON radiative, radtemp,dilute COMMON extra, fpath WIDGET_CONTROL,Event.top, get_uvalue=state ;,/no_copy CASE 1 OF event.id EQ state.calc: BEGIN ;-----re-calculate the emissivities ; ;; When the new emissivities are calculated, `emiss_sel' has to be completely ;; re-defined ; nt=ROUND((hi_temp-lo_temp)/tint +1) temp=FINDGEN(nt)*tint + lo_temp WIDGET_CONTROL,/hourglass emiss=emiss_calc(iz,ion,dens=dens,temp=temp,dil=dilute, $ radt=radtemp,path=fpath,/proton) result=WIDGET_MESSAGE('New line emissivities have been calculated.', $ /INFORMATION) labels=emiss_sel.label & n_inds=emiss_sel.n_ind ; save info before obs=emiss_sel.obs & sig=emiss_sel.sig ; destroying emiss_sel str={label:'', em:fltarr(nt), n_ind:-1, obs:0., sig:0., $ dens:0., densup:0., denslo:0.} emiss_sel=replicate(str,5) ; recreate emiss_sel FOR i=0,4 DO BEGIN emiss_sel(i).label=labels(i) & emiss_sel(i).n_ind=n_inds(i) emiss_sel(i).obs=obs(i) & emiss_sel(i).sig=sig(i) IF emiss_sel(i).n_ind NE -1 THEN BEGIN index_extractor,i,index=index IF emiss_sel(i).n_ind EQ 1 THEN BEGIN emiss_sel(i).em=emiss(index(0)).em ENDIF ELSE BEGIN emiss_sel(i).em=TOTAL(emiss(index).em,2) ENDELSE ENDIF ENDFOR temp_plot END event.id EQ state.lo_dens_slid: BEGIN lo_temp=FLOAT(event.value)/10. IF lo_temp GE hi_temp THEN BEGIN lo_temp=hi_temp-0.1 WIDGET_CONTROL,state.lo_dens_slid,set_value=ROUND(lo_temp*10.) ENDIF WIDGET_CONTROL,state.lo_temp_lbl, $ set_value=STRING(FORMAT='(f3.1)',lo_temp) END event.id EQ state.hi_dens_slid: begin hi_temp=FLOAT(event.value)/10. IF hi_temp LE lo_temp THEN BEGIN hi_temp=lo_temp+0.1 WIDGET_CONTROL,state.hi_dens_slid,set_value=ROUND(hi_temp*10.) ENDIF WIDGET_CONTROL,state.hi_temp_lbl, $ set_value=STRING(FORMAT='(f3.1)',hi_temp) end event.id EQ state.dens_bgrp: BEGIN ;---density interval ; ; buttons CASE event.value OF ; 0: BEGIN WIDGET_CONTROL,state.dens_bgrp,get_value=bob,get_uvalue=fred tint=float(fred(bob)) END ; 1: BEGIN WIDGET_CONTROL,state.dens_bgrp,get_value=bob,get_uvalue=fred tint=float(fred(bob)) END ; 2: BEGIN WIDGET_CONTROL,state.dens_bgrp,get_value=bob,get_uvalue=fred tint=float(fred(bob)) END ; ; 3: BEGIN ; WIDGET_CONTROL,state.dens_bgrp,get_value=bob,get_uvalue=fred ; tint=float(fred(bob)) ; END ; ENDCASE END event.id eq state.temp_read: BEGIN ;---read emiss temp WIDGET_CONTROL,state.temp_read,get_value=bob dens=float(bob) END event.id eq state.dil_read: BEGIN ;---read dilution factor WIDGET_CONTROL,state.dil_read,get_value=bob dilute=float(bob) & dilute=dilute(0) END event.id eq state.rt_read: BEGIN ;---read rad temp WIDGET_CONTROL,state.rt_read,get_value=bob radtemp=float(bob) & radtemp=radtemp(0) END ;;-------------------------------------------------; LINE SELECTION ;;The following bit allows new lines to be inserted ;;into emiss_sel, and also allows blends to be analysed. ;;`identity' determines which of the denominator or ;;numerators is being altered. ;; ;; To add more numerators simply add an extra OR to the line below ; (event.id eq state.d_lines) OR (event.id eq state.n1_lines): BEGIN ; WIDGET_CONTROL,event.id,get_uvalue=identity ; identity is an integer ; ; that identifies what is ; ; being altered CASE event.value of 1: BEGIN n=n_elements(temp) index=reverse( sort (emiss.em(fix(n/2))) ) index=index(0:15) ; 15 strongest lines. index2=sort(emiss(index).lambda) ; Sort the strongest lines into index=index(index2) ; wavelength order. result=emiss_select(emiss,index,sel_ind=ind) IF result(0) NE -1 THEN BEGIN emiss_sel(identity).em=result emiss_sel(identity).n_ind=n_elements(ind) emiss_sel(identity).sig=0. IF identity EQ 0 THEN emiss_sel(identity).obs=1. $ ELSE emiss_sel(identity).obs=0. WIDGET_CONTROL,state.ints(identity), $ set_value=strtrim(string(format='(f5.1)', $ emiss_sel(identity).obs),2) WIDGET_CONTROL,state.sigs(identity), $ set_value=strtrim(string(format='(f5.1)', $ emiss_sel(identity).sig),2) label='' for i=1,n_elements(ind) do $ label=label+'+'+strtrim(string(format='(f10.3)',emiss(ind(i-1)).lambda),2) len=strlen(label) label=strmid(label,1,len-1) emiss_sel(identity).label=label WIDGET_CONTROL,state.labels(identity),set_value=label temp_plot ENDIF END ; 2: BEGIN index=WHERE(emiss.lambda GE lo_w AND emiss.lambda LE hi_w) IF index(0) EQ -1 THEN BEGIN result=WIDGET_MESSAGE(['There are no lines in the', $ 'specified wavelength range.'],/INFORMATION) ENDIF ELSE BEGIN result=emiss_select(emiss,index,sel_ind=ind) IF result(0) NE -1 THEN BEGIN emiss_sel(identity).em=result emiss_sel(identity).n_ind=N_ELEMENTS(ind) IF identity EQ 0 THEN emiss_sel(identity).obs=1. $ ELSE emiss_sel(identity).obs=0. emiss_sel(identity).sig=0. WIDGET_CONTROL,state.ints(identity), $ set_value=STRTRIM(STRING(FORMAT='(f5.1)', $ emiss_sel(identity).obs),2) WIDGET_CONTROL,state.sigs(identity), $ set_value=STRTRIM(STRING(FORMAT='(f5.1)', $ emiss_sel(identity).sig),2) label='' FOR i=1,N_ELEMENTS(ind) DO $ label=label+'+'+STRTRIM(STRING(FORMAT='(f10.3)',emiss(ind(i-1)).lambda),2) len=STRLEN(label) label=STRMID(label,1,len-1) emiss_sel(identity).label=label WIDGET_CONTROL,state.labels(identity),SET_VALUE=label temp_plot ENDIF ENDELSE END ; 3: result=WIDGET_MESSAGE('Not implemented yet.',/INFO) ; ENDCASE ; END ;;-------------------------------------------------; LINE SELECTION ;--------------------------------------------; INPUT OBSERVED INTENSITIES ; (event.id EQ state.ints(0)) OR (event.id EQ state.ints(1)): BEGIN WIDGET_CONTROL,event.id,get_uvalue=identity WIDGET_CONTROL,state.ints(identity),get_value=new_obs new_obs=FLOAT(new_obs) emiss_sel(identity).obs=new_obs(0) END (event.id EQ state.sigs(0)) OR (event.id EQ state.sigs(1)): BEGIN WIDGET_CONTROL,event.id,get_uvalue=identity WIDGET_CONTROL,state.sigs(identity),get_value=new_sig new_sig=FLOAT(new_sig) emiss_sel(identity).sig=new_sig(0) END ;--------------------------------------------; INPUT OBSERVED INTENSITIES ;--------------------------------------------; WAVELENGTH SLIDER event.id eq state.lo_slid: BEGIN IF event.value GE alog10(hi_w) THEN BEGIN lo_w=hi_w-1 WIDGET_CONTROL,state.lo_slid,set_value=alog10(lo_w) ENDIF ELSE BEGIN lo_w=10.^(event.value) ENDELSE WIDGET_CONTROL,state.lo_txt,set_value=strtrim(string(format='(f7.0)',lo_w),2) wset,plot_spec_id plot,[min_w,max_w],[0,1],/nodata,xticklen=0.00001,yticklen=0.000001,$ xsty=1,yticks=1,charsiz=.01 for i=0,n_elements(emiss)-1 do $ oplot,alog10([emiss(i).lambda,emiss(i).lambda]),[0,1] oplot,alog10([lo_w,lo_w]),[0,1],th=3,col=150 oplot,alog10([hi_w,hi_w]),[0,1],th=3,col=150 wset,plot_rat_id temp_plot END event.id EQ state.hi_slid: BEGIN IF event.value LE ALOG10(lo_w) THEN BEGIN hi_w=lo_w+1 WIDGET_CONTROL,state.hi_slid,SET_VALUE=ALOG10(hi_w) ENDIF ELSE BEGIN hi_w=10.^(event.value) ENDELSE WIDGET_CONTROL,state.hi_txt, $ SET_VALUE=STRTRIM(STRING(FORMAT='(f7.0)',hi_w),2) wset,plot_spec_id plot,[min_w,max_w],[0,1],/nodata,xticklen=0.00001,yticklen=0.000001,$ xsty=1,yticks=1,charsiz=.01 for i=0,n_elements(emiss)-1 do $ oplot,alog10([emiss(i).lambda,emiss(i).lambda]),[0,1] oplot,alog10([lo_w,lo_w]),[0,1],th=3,col=150 oplot,alog10([hi_w,hi_w]),[0,1],th=3,col=150 wset,plot_rat_id temp_plot END ;--------------------------------------------; WAVELENGTH SLIDER event.id eq state.up_read: BEGIN ; upper limit for manual plots WIDGET_CONTROL,state.up_read,get_value=result lims(1)=result temp_plot END event.id eq state.LO_read: BEGIN ; lower limit for manual plots WIDGET_CONTROL,state.lo_read,get_value=result lims(0)=result temp_plot END event.id eq state.man_aut: BEGIN ; switch between manual and CASE event.value OF ; automatic scaling ; 0: set_scale=0 1: set_scale=1 ; ENDCASE temp_plot END event.id EQ state.b_all: BEGIN CASE event.value OF ; 0: all=0 1: all=1 ; ENDCASE temp_plot END event.id eq state.extras: BEGIN CASE event.value OF ; 0: temp_plot ; 1: BEGIN ; display densities in a widget n_lines=intarr(5) FOR i=1,4 DO BEGIN ; for each numerator IF emiss_sel(i).obs NE 0. THEN n_lines(i)=1 ENDFOR ind=WHERE(n_lines EQ 1) IF ind(0) NE -1 THEN BEGIN line_labels=emiss_sel(where(n_lines EQ 1)).label+'/'$ +emiss_sel(0).label line_text=STRARR(N_ELEMENTS(ind)) FOR i=0,N_ELEMENTS(ind)-1 DO BEGIN ; ; Create string containing ratio plus errors ; sig1=emiss_sel(ind(i)).sig sig2=emiss_sel(0).sig i1=emiss_sel(ind(i)).obs i2=emiss_sel(0).obs ratio=i1/i2 sig=sqrt( (i1*sig2)^2 + (i2*sig1)^2 )/i2^2 ratio_txt=strtrim(string(format='(f10.3)',ratio),2)+'+/-'+$ strtrim(string(format='(f10.3)',sig),2) ; ; Create string containing density plus errors ; density=emiss_sel(ind(i)).dens densup=emiss_sel(ind(i)).densup IF densup EQ -1 THEN BEGIN densup='HI' ENDIF ELSE BEGIN densup=strtrim(string(format='(f10.2)',densup-density),2) ENDELSE denslo=emiss_sel(ind(i)).denslo IF denslo EQ -1 THEN BEGIN denslo='LO' ENDIF ELSE BEGIN denslo=strtrim(string(format='(f10.2)',density-denslo),2) ENDELSE density=strtrim(string(format='(f10.2)',density),2) dens_txt=density+'+'+densup+'-'+denslo ; IF i EQ 0 THEN disp_string=[line_labels(i),$ ' Observed Ratio: '+ratio_txt, $ ' Temp: '+dens_txt] IF i NE 0 THEN disp_string=[disp_string,line_labels(i),$ 'Observed Ratio: '+ratio_txt,'Temp: '] ENDFOR result=WIDGET_MESSAGE(disp_string,/info) ENDIF ELSE BEGIN result=WIDGET_MESSAGE('Observed intensities have not been specified',/info) ENDELSE END ; 2: BEGIN dname=!d.name SET_PLOT,'ps' temp_plot DEVICE,/CLOSE SET_PLOT,dname CD,CURRENT=curr_dir result=WIDGET_MESSAGE('Plot sent to '+curr_dir+'/idl.ps',$ /info) END ; 3: WIDGET_CONTROL, event.top, /DESTROY ; quit ; ENDCASE END ENDCASE END ;----------------------------------------------------------------------------- PRO temp_wid, GROUP=Group ;----------------------------------------------------------------------------- COMMON emiss_data,iz,ion,emiss,lo_temp,hi_temp,tint,dens,temp COMMON select,emiss_sel COMMON sliders,lo_w,hi_w,min_w,max_w COMMON plotting,lims,set_scale,all COMMON Comm, plot_rat_id, plot_spec_id COMMON radiative, radtemp,dilute IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0 junk = { CW_PDMENU_S, flags:0, name:'' } desc=[ { CW_PDMENU_S, 1, 'Choose a new line' }, $ { CW_PDMENU_S, 0, '...from strongest lines' }, $ { CW_PDMENU_S, 2, '...from specified wavelength range' }, $ { CW_PDMENU_S, 2, 'Show blends' } ] zion2spectroscopic,iz,ion,title IF KEYWORD_SET(fpath) THEN direc=fpath ELSE zion2filename,iz,ion,direc title='ION: '+title+' --- DIRECTORY: '+direc ; Main base ; DENS_MAIN = WIDGET_BASE(GROUP_LEADER=Group, $ col=1, $ MAP=1, $ UVALUE='DENS_MAIN', title=title) ;---------------------------------------------------[] ; base_1 will contain emissivity stuff. Everything else is on base_2 ; BASE_1=WIDGET_BASE(DENS_MAIN,row=1,map=1,uvalue='BASE_1',frame=1) CALC=WIDGET_BUTTON(BASE_1,val='Calculate emissivity') B_D_SLID=WIDGET_BASE(BASE_1,col=1,map=1,uvalue='B_D_SLID',frame=1) B_D_LABEL=WIDGET_LABEL(B_D_SLID,/align_left,value='Select temp range, log T [K]') ; LO_TEMP_BASE=WIDGET_BASE(B_D_SLID,row=1,map=1,uvalue='LO_TEMP_BASE') LO_DENS_SLID=WIDGET_SLIDER(LO_TEMP_BASE,min=30,max=80, $ val=round(lo_temp*10.),xsiz=200,/suppress) LO_TEMP_LBL=WIDGET_LABEL(LO_TEMP_BASE,/align_left, $ value=string(format='(f3.1)',lo_temp)) ; HI_TEMP_BASE=WIDGET_BASE(B_D_SLID,row=1,map=1,uvalue='LO_TEMP_BASE') HI_DENS_SLID=WIDGET_SLIDER(HI_TEMP_BASE,min=30,max=80, $ val=round(hi_temp*10.),xsiz=200,/suppress) HI_TEMP_LBL=WIDGET_LABEL(HI_TEMP_BASE,/align_left, $ value=string(format='(f3.1)',hi_temp)) TEMP_DENS=WIDGET_BASE(BASE_1,col=1,map=1,uvalue='TEMP_DENS') ; ; Note: the set_value below selects the second button in the group by default ; DENS_INT=WIDGET_BASE(TEMP_DENS,col=1,map=1,uvalue='DENS_INT',frame=2) DENS_INT_TXT=WIDGET_LABEL(DENS_INT,/align_left,value='Temp intervals') DENS_BGRP=CW_BGROUP(DENS_INT,['0.1','0.05','0.01'],/row,$ set_value=0,/exclusive,$ uvalue=['0.1','0.05','0.01']) TEMP_SET=WIDGET_BASE(TEMP_DENS,row=1,map=1,uvalue='TEMP_SET',frame=2) ; TEMP_LBL=WIDGET_LABEL(TEMP_SET,/align_left, $ value='Dens, log N_e [cm^-3]:') TEMP_READ=WIDGET_TEXT(TEMP_SET,$ value=strtrim(string(format='(f5.2)',dens),2),$ xsiz=5,/editable) ;TEMP_DENS=WIDGET_BASE(BASE_1,col=1,map=1,uvalue='TEMP_DENS') ; ; Note: the set_value below selects the second button in the group by default ; ;DENS_BGRP=CW_BGROUP(TEMP_DENS,['0.1','0.05','0.01'],/row,$ ; set_value=0,/exclusive,$ ; uvalue=['0.1','0.05','0.01']) ;TEMP_SET=WIDGET_BASE(TEMP_DENS,row=1,map=1,uvalue='TEMP_SET') ; ;TEMP_LBL=WIDGET_LABEL(TEMP_SET,/align_left,value='Dens:') ;TEMP_READ=WIDGET_TEXT(TEMP_SET,$ ; value=strtrim(string(format='(f5.2)',dens),2),$ ; xsiz=5,/editable) RAD_SET=WIDGET_BASE(BASE_1,col=1,map=1,frame=2) ;; DIL_SET=WIDGET_BASE(RAD_SET,row=1,map=1) ; DIL_LBL=WIDGET_LABEL(DIL_SET,/align_left,value='Dilution factor:') DIL_READ=WIDGET_TEXT(DIL_SET,$ value=strtrim(string(format='(f4.2)',dilute),2),$ xsiz=5,/editable) RT_SET=WIDGET_BASE(RAD_SET,row=1,map=1) ; RT_LBL=WIDGET_LABEL(RT_SET,/align_left,value='Radiation Temp:') RT_READ=WIDGET_TEXT(RT_SET,$ value=strtrim(string(format='(f7.1)',radtemp),2),$ xsiz=8,/editable) ;---------------------------------------------------[] ; BASE_2 contains all other widgets ; BASE_2=WIDGET_BASE(DENS_MAIN,row=1,map=1,uvalue='BASE_2') ; ; ; Base to contain denominator and numerator bases ; BASE_ND = WIDGET_BASE(BASE_2, COLUMN=1, MAP=1, xsiz=500, UVALUE='BASE_ND') ;---------------------------------------[] ; Label and buttons for denominator ; D_BASE=WIDGET_BASE(BASE_ND, FRAME=2, $ COLUMN=1, MAP=1, xsiz=500, UVALUE='D_BASE') D_BASE_1=WIDGET_BASE(D_BASE, row=1, MAP=1, xsiz=500, UVALUE='D_BASE_1') ; D_TXT2=WIDGET_LABEL(D_BASE_1,/align_left,value='Denominator: ') D_TXT =WIDGET_LABEL(D_BASE_1,/align_left,xsiz=400,VALUE=emiss_sel(0).label) D_LINES=CW_PDMENU(D_BASE,desc,uvalue=0) D_BASE_2=WIDGET_BASE(D_BASE, row=1, MAP=1, xsiz=500, UVALUE='D_BASE_1') ; L_INT_D=WIDGET_LABEL(D_BASE_2,/align_left,value='Intensity:') INT_D=WIDGET_TEXT(D_BASE_2,/EDITABLE, xsiz=7, uvalue=0, $ value=strtrim(string(format='(f6.2)',emiss_sel(0).obs),2)) L_SIG_D=WIDGET_LABEL(D_BASE_2,/align_left,value='Sigma:') SIG_D=WIDGET_TEXT(D_BASE_2,/EDITABLE, xsiz=7, uvalue=0, $ value=strtrim(string(format='(f6.2)',emiss_sel(0).sig),2)) ;---------------------------------------[] ;---------------------------------------<> ; Label and buttons for numerator ; N1_BASE=WIDGET_BASE(BASE_ND, FRAME=2, $ COLUMN=1, MAP=1, xsiz=500, UVALUE='N1_BASE') N1_BASE_1=WIDGET_BASE(N1_BASE, row=1, MAP=1, xsiz=500, UVALUE='D_BASE_1') ; N1_TXT2=WIDGET_LABEL(N1_BASE_1,/align_left,value='Numerator 1: ') N1_TXT =WIDGET_LABEL(N1_BASE_1,/align_left,xsiz=400,VALUE=emiss_sel(1).label) N1_LINES=CW_PDMENU(N1_BASE,desc,uvalue=1) N1_BASE_2=WIDGET_BASE(N1_BASE, row=1, MAP=1, xsiz=500, UVALUE='N1_BASE_1') ; L_INT_N1=WIDGET_LABEL(N1_BASE_2,/align_left,value='Intensity:') INT_N1=WIDGET_TEXT(N1_BASE_2,/EDITABLE, xsiz=7, uvalue=1, $ value=strtrim(string(format='(f6.2)',emiss_sel(1).obs),2)) L_SIG_N1=WIDGET_LABEL(N1_BASE_2,/align_left,value='Sigma:') SIG_N1=WIDGET_TEXT(N1_BASE_2,/EDITABLE, xsiz=7, uvalue=1, $ value=strtrim(string(format='(f6.2)',emiss_sel(1).obs),2)) ;---------------------------------------<> ;----------------------------------(I) LO_SLID_B=WIDGET_BASE(BASE_ND, ROW=1, MAP=1, xsiz=400,$ /align_center,UVALUE='LO_SLID_B') ; LO_SLID=cw_fslider(LO_SLID_B,min=min_w,max=max_w,xsiz=300,$ tit='Low wavelength limit', val=alog10(lo_w),/suppress_value) LO_TXT=WIDGET_LABEL(LO_SLID_B,xsiz=60,$ /align_left,VALUE=strtrim(string(lo_w),2)) HI_SLID_B=WIDGET_BASE(BASE_ND,ROW=1,MAP=1, xsiz=400,/align_center, $ UVALUE='HI_SLID_B') ; HI_SLID=cw_fslider(HI_SLID_B,min=min_w,max=max_w,xsiz=300,$ tit='High wavelength limit', val=alog10(hi_w),/suppress_value) HI_TXT=WIDGET_LABEL(HI_SLID_B,xsiz=60,$ /align_left,VALUE=strtrim(string(hi_w),2)) ;----------------------------------(I) P_S_BASE=WIDGET_BASE(BASE_ND,row=1,map=1,xsiz=380,/align_center) PLOT_SPEC=WIDGET_DRAW(P_S_BASE, $ RETAIN=1, xsiz=350,ysiz=30, $ UVALUE='PLOT_RAT') ;---------------------------------------0 ; Quit button ; EXTRAS = CW_BGROUP( BASE_ND, $ ['Re-plot lines','Show derived temps','Hardcopy',$ 'Quit'],$ /row) ;---------------------------------------0 ;---------------------------------------<> ; Base for plotting window ; WIND_BASE=WIDGET_BASE(BASE_2, frame=2,$ col=1, $ MAP=1, $ xsiz=500,$ UVALUE='WIND_BASE') ; Choose between selected lines and all lines. Default=0 ; B_ALL = CW_BGROUP( WIND_BASE,['Selected lines','All lines'],/row,$ set_value=0,/exclusive) ; Plotting window ; PLOT_RAT = WIDGET_DRAW( WIND_BASE, $ RETAIN=1, $ UVALUE='PLOT_RAT', $ XSIZE=500, $ YSIZE=400) ;----------------------X ; Base for plotting widgets ; PLOT_BASE= WIDGET_BASE(WIND_BASE,$ ROW=1, MAP=1, UVALUE='PLOT_BASE') ;----------------[] ; Base for containing plot upper and lower limits ; LIM_BASE=WIDGET_BASE(PLOT_BASE,$ row=1, MAP=1, UVALUE='LIM_BUT_B') LO_READ_L=WIDGET_LABEL(LIM_BASE,value='Lower limit:') LO_READ=WIDGET_TEXT(LIM_BASE,$ value=strtrim(string(format='(e10.2)',lims(0)),2),$ xsiz=11,/editable) UP_READ_L=WIDGET_LABEL(LIM_BASE,value='Upper limit:') UP_READ=WIDGET_TEXT(LIM_BASE,$ value=strtrim(string(format='(e10.2)',lims(1)),2),$ xsiz=11,/editable) ;----------------[] ; Choose between selected lines and all lines. Default=0 ; MAN_AUT = CW_BGROUP( WIND_BASE,['Automatic Scaling','Manual Scaling'],/row,$ set_value=0,/exclusive) ;----------------------X ;---------------------------------------<> ;; To add more numerators, add an extra n?_bgroup and n?_txt to `state' ; state={calc:calc, lo_dens_slid:lo_dens_slid, hi_dens_slid:hi_dens_slid, $ lo_temp_lbl:lo_temp_lbl, hi_temp_lbl:hi_temp_lbl, $ dens_bgrp:dens_bgrp, temp_read:temp_read, $ dil_read:dil_read, rt_read:rt_read, $ d_lines:d_lines, n1_lines:n1_lines, $ labels:[d_txt,n1_txt], $ ints:[int_d,int_n1], sigs:[sig_d,sig_n1], $ lo_txt:lo_txt, lo_slid:lo_slid, $ hi_txt:hi_txt, hi_slid:hi_slid, $ up_read:up_read, lo_read:lo_read, man_aut:man_aut, $ b_all:b_all, extras:extras} WIDGET_CONTROL, DENS_MAIN, /REALIZE, set_uvalue=state ; Get drawable window index WIDGET_CONTROL, plot_rat, GET_VALUE=plot_rat_id WIDGET_CONTROL, plot_spec, GET_VALUE=plot_spec_id wset,plot_spec_id plot,[min_w,max_w],[0,1],/nodata,xticklen=0.00001,yticklen=0.000001,$ xsty=1,yticks=1,charsiz=.01 for i=0,n_elements(emiss)-1 do $ oplot,alog10([emiss(i).lambda,emiss(i).lambda]),[0,1] oplot,alog10([lo_w,lo_w]),[0,1],th=3,col=150 oplot,alog10([hi_w,hi_w]),[0,1],th=3,col=150 wset,plot_rat_id temp_plot XMANAGER, 'DENS_MAIN', DENS_MAIN, group=group END ;------------------------------------------------------------------------------ PRO TEMP_PLOTTER, ION_Z, ION_SP, EM, PATH=PATH, DENSITY=DENSITY ;------------------------------------------------------------------------------ COMMON emiss_data,iz,ion,emiss,lo_temp,hi_temp,tint,dens,temp COMMON select,emiss_sel COMMON sliders,lo_w,hi_w,min_w,max_w COMMON plotting,lims,set_scale,all COMMON radiative, radtemp,dilute COMMON extra, fpath ;-------------------------------[] ; There was a problem when using this routine in the CDS environment as ; !xuvtop was not set, and an error would be generated. The following ; prevents this problem ; chianti_var='!xuvtop' defsysv,chianti_var,exist=exist ; IF exist EQ 0 THEN xuvtop_help,chianti_var ;-------------------------------[] ;------------------< ; If, in a previous call to dens_plotter, you have set path, then it ; is `remembered' in the common block. The following command removes it ; from the common block ; IF N_ELEMENTS(fpath) NE 0 THEN junk=temporary(fpath) ;------------------< IF N_PARAMS() LT 2 THEN BEGIN PRINT,'Use: IDL> temp_plotter, iz, ion [, em, path=path] RETURN ENDIF IF N_ELEMENTS(path) NE 0 THEN fpath=path iz=ion_z & ion=ion_sp lims=[0.,0.] & set_scale=0 ; default: automatic scaling all=0 ; default: display selected lines loadct,39 ; gives yellow bars on the small graphics ; window radtemp=6000. & dilute=0. ; default: radiation data ;------------------------------------+ ; Work out the T_max for the ion using the ion balance data in CHIANTI. ; choose_ioneq,iz,ion,temp_all,ioneq ; f_all=ioneq(*,iz-1,ion-1) ind=WHERE(f_all EQ max(f_all)) ind=ind(0) ; in case ind has more than one element (e.g., Ar IX) tmax=temp_all(ind) ;------------------------------------+ temp=findgen(9)/10. + tmax - 0.4 lo_temp=temp(0) hi_temp=temp(8) tint=0.1 IF NOT KEYWORD_SET(density) THEN density=10. dens=density PRINT,' PRINT,' -- Please wait while emissivities are calculated -- PRINT,' emiss=emiss_calc(iz,ion,temp=temp,dens=density,path=fpath,/quiet) lo_w=MIN(emiss.lambda-1) & hi_w=MAX(emiss.lambda+1) min_w=ALOG10(lo_w) & max_w=ALOG10(hi_w) ;;--------------------------------------------------< ;; Create the `emiss_sel' structure from emiss ; ; emiss_sel is a structure similar to emiss that contains the ; emissivities of the lines begin plotted. emiss_sel(0) is always the ; denominator. ; It is not possible to directly store the indices of blends in `emiss_sel' ; and so I'm going to store the number of indices and then use a little ; routine to extract the indices from emiss_sel.label ; str={label:'', em:FLTARR(9), n_ind:-1, obs:0., sig:0., $ dens:0. , densup:0. , denslo:0.} emiss_sel=REPLICATE(str,5) ; allow for up to 4 numerators ; ind=WHERE(emiss.em(0) EQ MAX(emiss.em(0))) emiss_sel(0).label=STRTRIM(STRING(emiss(ind).lambda),2) emiss_sel(0).em=emiss(ind).em emiss_sel(0).n_ind=1 emiss_sel(0).obs=1.0 & emiss_sel(0).sig=0. ; ind=WHERE(emiss.em(8) EQ MAX(emiss.em(8))) emiss_sel(1).label=STRTRIM(STRING(emiss(ind).lambda),2) emiss_sel(1).em=emiss(ind).em emiss_sel(1).n_ind=1 emiss_sel(1).obs=0. & emiss_sel(1).sig=0. ;;----------------------------------------------------< temp_wid em=emiss_sel END