;+ ; Name: ; SPEX_PLOT_SAVED ; ; Purpose: ; This procedure provides a simple interface for plotting the results of analysis ; in SPEX. ; ; Category: ; SPEX ; Explanation: ; This procedure restores a save file then plots out the requested interval. ; Use: ; SPEX_PLOT_SAVED, Filename, Interval ; Inputs: ; Filename - Fully qualified filename of IDL XDR save file. ; Interval - Fitting Interval to plot or overplot ; Opt. Inputs: None ; ; Outputs: None ; ; Opt. Outputs: None ; ; Keywords: ; UNITS - Two cases: ; For Spectral Plots the Default is ; 'Photons'+uflux or UNITS+uflux ; ; For Time-History it can be Counts/sec or Counts/sec/cm2/keV controlled ; by the value of 'T_hist_mode' restored into common. If UNITS are 'PHOTONS' ; for th plots, then background subtracted accumulations, (OBSI-BACKI)/CONVI will ; be used with photons in the labels and photons used for integrating over bands. ; PH_MODEL - If set, then the model photon fits will be used to construct ; the time history plots. ; OVERPLOT - Overplot these values. ; RESIDUALS- Show residual plot, too. ; EXTRA - Provide keyword inheritance into SPEX_SPEC_PLOT ; The following keywords have their usual meaning in Plot. ; XRANGE ; YRANGE ; XMARGIN ; YMARGIN ; CHARSIZE ; SUBTITLE - Pass this subtitle onto time (not implemented) or spectral plot. ; Can be used to plot time-histories too by use of the following keyword: ; TIME_HISTORY: A string with value 'TIME_HISTORY' or 'GRAPH' ; for TIME_HISTORY an integrate light curve is plotted, while for ; GRAPH the variable ENERGY_BANDS gives the 4 band ranges. ; NEW_EBANDS: OVERRIDES ENERGY_BANDS in spex_commons, only used when PH_MODEL is set ; BAND_DENSITY: Only used with NEW_EBANDS, the number of sub-bins per NEW_EBAND, ; logarithmic scaling. ; NEW_SCALE: Overrides scale_bands in save files, set scaling on multi-traces ; Calls: ; SPEX_SPEC_PLOT, FCHECK, ATIME, GETUTBASE, SETUTBASE, CHECKVAR, LINECOLORS, ; SPEX_THISTORY, SPEX_SAVE_DATA, SPEX_CURRENT ; ; Common Blocks: ; spex_plot_saved ; Restrictions: ; ; Side effects: ; !p.charsize, !x.margin, and !y.margin are set within this procedure ; Prev. Hist : ; Based on the plotting interface with SPEX.PRO ; Modified : ; Version 1, RAS, 10-April-1996 ; Version 2, RAS, 31-May-1996, changes to new_scale and trange ;- ;============================================================================== pro SPEX_PLOT_SAVED, filename, interval, $ UNITS=UNITS, PH_MODEL=PH_MODEL, BAND_DENSITY=BAND_DENSITY, $ NEW_EBANDS=NEW_EBANDS, NEW_SCALE=NEW_SCALE, SUBTITLE=SUBTITLE, $ OVERPLOT=OVERPLOT, XRANGE=XRANGE, YRANGE=YRANGE, RESIDUALS=RESIDUALS, $ XMARGIN=XMARGIN, YMARGIN=YMARGIN, CHARSIZE=CHARSIZE, _EXTRA=extra, $ TIME_HISTORY=TIME_HISTORY, XTYPE=XTYPE, YTYPE=YTYPE common spex_plot_saved, filename_sav @function_com ; ; Space for other variables to be restored ; hxdir=0 & idlproc=0 & idl_vers=0 & path=0 & sd_pos=0 &ys_pos=0 checkvar, filename, '' if filename ne '' then $ if fcheck(filename_sav,'') ne filename then begin spex_save_data,/restore,filename filename_sav=fcheck(filename,'') endif ; ;Extract the basetime from the title, very hokey ; title = spex_current('title') titles = str_sep(title, ' ') wdate = where( strpos(titles,'-') ne -1) setutbase,titles(wdate(0)) ; ; ; DEFAULTS ; checkvar, xrange, [10., 1000.] checkvar, yrange, [1e-4, 100.] checkvar, xmargin, [15,4] checkvar, ymargin,[8,4] !x.margin = xmargin !y.margin = ymargin !p.charsize = fcheck( charsize, 1.2) linecolors if not exist(TIME_HISTORY) then begin vlist='edges,drm,delta_light,e_in,apar_arr,obsi,eobsi,backi,ebacki,uflux,wuse,'+$ 'apar_sigma,chi,uncert,xselect,more_info,title' vlist = str_sep(vlist,',') for i=0,n_elements(vlist)-1 do result=execute(vlist(i)+'=spex_current(vlist(i))') tselect = xselect checkvar, interval, 0 interval = interval < (n_elements(apar_arr(0,*))-1) if not exist(units) then units_out = 'Photons'+uflux else units_out=units+uflux apar_use = apar_arr(*,interval) checkvar, new_scale, 1 norm_param = model_components(f_model) apar_use(norm_param) = apar_use(norm_param) / new_scale cflux = obsi(*,interval) / new_scale ecflux = eobsi(*,interval) / new_scale bflux=backi(*,interval) / new_scale ebflux=ebacki(*,interval) / new_scale if not exist(subtitle) then trange= tselect(*,interval) else trange = '' spex_spec_plot,edges=edges, drm=drm, delta_light=delta_light, e_in=e_in, $ apar=apar_use, cflux=cflux, ecflux=ecflux, bflux=bflux, ebflux=ebflux, $ set=0, units=units_out, xtype=xtype, ytype=ytype, wuse=wuse, $ yrange=yrange, xrange=xrange, sigma=apar_sigma(*,interval), chisqr=chi(interval), $ interval=interval,uncert=uncert, trange=trange, subtitle=subtitle, residuals=residuals, $ more_info=more_info, title=title, overplot=overplot, _extra=extra endif else begin if exist(units) then begin if strpos(strupcase(units),'PHOTON') ne -1 then begin ; ; Use accumulations corrected background and conversion factor ; Plot photon fluxes using deconvolved accumulations or fitting model. ; vlist ='command,data_tipe,edges,'+$ 'count_2_flux,uflux,area,title,uncert,'+$ 't_hist_mode,energy_bands,scale_bands,edg_units,eplots,tavg,iavg,ltime,f_model' vlist = str_sep(vlist,',') for i=0,n_elements(vlist)-1 do result=execute(vlist(i)+'=spex_current(vlist(i))') if keyword_set(new_ebands) then energy_bands=new_ebands ut = spex_current('xselect') use_photons = 1 if not keyword_set(ph_model) then begin ; ;Use deconvolved measured fluxes ; obsi = spex_current('obsi') eobsi= spex_current('eobsi') backi= spex_current('backi') ebacki= spex_current('ebacki') convi= spex_current('convi') rate = f_div( obsi-backi, convi) erate = sqrt( f_div( eobsi^2+ebacki^2, convi^2)) endif else begin apar_arr = spex_current('apar_arr') f_model = spex_current('f_model') if keyword_set(new_ebands) then begin ;Subdivide energy bands, spex_thistory will integrate checkvar, band_density, 20 edges = fltarr(2, n_elements(new_ebands(0,*))*band_density) for i=0,n_elements(new_ebands(0,*))-1 do begin sub_edges=new_ebands(0,i)*10.^( (findgen(band_density+1)/band_density) * $ alog10(new_ebands(1,i)/new_ebands(0,i)) ) edges(0,i*band_density:(i+1)*band_density-1) = sub_edges(0:band_density-1) edges(1,i*band_density:(i+1)*band_density-1) = sub_edges(1:band_density) endfor count_2_flux=area*(edges(1,*)-edges(0,*))(*) endif spex_model_array, f_model, edges, apar_arr, rate erate = rate * uncert ;A bad estimate of uncertainty on integrated fitted flux. endelse endif endif else begin use_photons = 0 vlist ='ut,rate,erate,command,data_tipe,edges,count_2_flux,uflux,area,title,'+$ 't_hist_mode,energy_bands,scale_bands,edg_units,eplots,tavg,iavg,ltime,f_model' vlist = str_sep(vlist,',') for i=0,n_elements(vlist)-1 do result=execute(vlist(i)+'=spex_current(vlist(i))') endelse command = time_history if keyword_set(new_scale) then scale_bands=new_scale spex_thistory, ut, rate, erate, command, data_tipe, edges, $ count_2_flux, uflux, area, title, $ t_hist_mode, energy_bands, scale_bands, yrange, ytype, $ edg_units=edg_units, eplots=eplots, photons=use_photons, $ sampav=fcheck(tavg,iavg), ltime=ltime, overplot=overplot, _extra=extra endelse end