;+ ; ; NAME: ; HXISTSPEC ; ; PURPOSE: ; Plots count rate vs. band energy for area defined by the pixels ; selected. A specified number of spectra are plotted evenly spaced ; between given start and stop time. ; ; CATEGORY: ; HXIS display ; ; CALLING SEQUENCE: ; HXISTSPEC ; ; CALLED BY: ; HXISWIDGET ; ; CALLS TO: ; HXISAREA, HXISSUM_AREA, HXISGETWINDOW, HXISHARD, HXISEDGE_IMG ; ; INPUTS: ; none explicit, only through commons ; ; OPTIONAL INPUTS: ; none ; ; OUTPUT: ; none explicit, only through commons ; ; OPTIONAL INPUTS: ; none ; ; COMMON BLOCKS: ; HXISAREA for the currently program selection of pixel ; HXISCOLOR for the line colors for spectra plots ; HXISDATA_INFO for the structure INFO ; HXISTSPEC for values and parameters of last calculated spectra ; HXISWIDGET for program output to information widget ; ; SIDE EFFECTS: ; If info.hard is set then a hard copy will be printed. ; ; RESTRICTIONS: ; none ; ; PROCEDURE: ; Spectra are calculated at times START+(STOP-START)/(NSPEC-1)*I ; (I=0,NSPEC-1). For each spectrum TOVER seconds are accumulated. ; MODIFICATION HISTORY: ; APR-1991, Paul Hick (ARC) ; MAR-1993, Elaine Einfalt (HSTX) - converted to widgets ;- pro hxistspec @hxisasread.common @hxisarea.common @hxiscolor.common @hxisdata_info.common @hxistime.common @hxistspec.common @hxiswidget.common error = 0 ; success until failure ; ; If there is already a strectra in memory. Further testing will be performed ; to see if this saved spectra fits all the current program conditions ; if (n_elements(TSPEC_TIME) ne 0) and (n_elements(TSPEC_DATA) ne 0) $ then in_memory=1 $ else in_memory=0 ; ; If there are no selected pixels, then select some pixels ; if (pixels(0) eq -1) then HXISAREA, error=error ; ; If still don't have any pixels, nothing more can be done here. ; Else, how many pixels are there. ; if (PIXELS(0) eq -1) or error then begin widget_control, comment, set_value='No pixel(s) selected', /append return endif else CUR_NPIX = n_elements(PIXELS) ; # of pixels selected most recent ; ; Test to see if the pixels have changed since last call to TSPEC ; last_npix = n_elements(S_PIXIES) ; # of pixels from last TSPEC if last_npix ne cur_npix then in_memory = 0 $ ; Selected different pixels. else begin ; Same number of pixels, but ; are they the same pixels. not_eq = where(S_PIXIES ne PIXELS) ; Compare the old and the new if not_eq(0) ne -1 then in_memory = 0 ; They were not the same in ; at least one element endelse ; ; If there is a spectra in memory and the pixels are the same... ; We can only use the spectra in memory if ALL the current parameter match ; the parameters present when the spectra was calculated. ; if in_memory then begin if (timg(info.frst_img) eq S_START) and $ ; if same start (timg(info.last_img) eq S_STOP) and $ ; same stop (info.tover eq S_TOVER) and $ ; same average (info.back eq S_BACK) and $ ; same backgroun (info.sig eq S_SIG) and $ ; same sigma (info.nspec eq S_NSPEC) and $ ; same number of spectra (info.dead eq S_DEAD) $ ; same dead condition then GOTO, PLOT_SPECTRA ; then don't recalculate endif ;=========================================================================== ; ; Well, we didn't get to jump. So, we need to go calculated a spectra. ; ;=========================================================================== ; ; Create arrays for spectra ; TT = fltarr(info.NSPEC) ; the times of the spectra selected FF = fltarr(6,info.NSPEC) ; the spectra at info.nspec points ; ; Save current settings, they will be restored after the SUM_AREA loop ; temp_btyp = info.btyp & temp_blow = info.blow & temp_bup = info.bup temp_frst = info.frst_img & temp_last = info.last_img temp_mode = info.mode(0) & info.mode(0) = 0 ; ; Only use counts (no temperature, emission, or energy) ; and all of the bands. ; info.btyp = 0 & info.blow = 1+indgen(6) & info.bup = info.blow ; ; Half the averaging value in units of hours ; average = info.tover / 7200. ; ; ; Calculate the spectra for the current program parameters ; ; widget_control, comment, set_value='Calculating ' + strtrim(info.nspec,2) + $ ' spectra...', /append for I = 0, info.nspec-1 do begin ; ; Evenly space the N_SPEC times to get the spectra times ; ;1/94 TT(I) = timg(info.frst_img)+(timg(info.last_img)-timg(info.frst_img)) $ ; / (info.nspec-1)*I TT(I) = timg(temp_frst)+(timg(temp_last)-timg(temp_frst)) $ / (info.nspec-1)*I a = abs(timg-tt(I)) & b = min(a,c) TT(I) = timg(c) ;The spectra's times ; ; Collect all the images within the given average of this image. ; Reassign first and last image to this range for SUM_AREA. ; range = where(A le average) if range(0) ne -1 then begin ; a significant average is present info.frst_img = range(0) info.last_img = range(n_elements(range)-1) endif else begin ; use closest time info.frst_img = c info.last_img = c endelse ; ; Sum all the pixels selected for this image ("I") in the range. ; Results in one values for each image plot displayed. ; HXISSUM_AREA, datarea, I, info.nspec-1, error=error if error then begin widget_control, comment, set_value='Unable to sum pixels.', /append return endif ; ; The spectra data values ; FF(*,I) = datarea ; The spectra endfor widget_control, comment, set_value='Calculation complete ', /append ; ; Restore original settings ; info.btyp = temp_btyp & info.blow = temp_blow & info.bup = temp_bup info.frst_img = temp_frst & info.last_img = temp_last info.mode(0) = temp_mode ; ; See if there are any valid spectra data ; if max(FF) le 0 then begin widget_control, comment, set_value='Sorry. No valid data available ' + $ 'for spectra.', /append return endif ; ; The parameters used to calculate the spectra to be put in memory ; S_START = timg(info.frst_img) S_STOP = timg(info.last_img) S_TOVER = info.tover S_NSPEC = info.nspec S_DEAD = info.dead S_BACK = info.back S_SIG = info.sig S_PIXIES = pixels ; ; These are the resulting spectra arrays ; TSPEC_TIME = TT ; the times of the spectra TSPEC_DATA = FF ; the spectra data values PLOT_SPECTRA: ;=========================================================================== ; ; Have the spectra, so give the people what they want. ; ;=========================================================================== ; ; ; Set up the output plot ; ; ; ; For screen output get a new window or reuse old one. ; For a hard copy set up the device. ; info.cplot_up = 0 ; about to erase current window if not(info.hard) then hxisgetwindow $ else hxishard, /fileopen, colo=info.colo ; ; Set up the X-axis ; xnames = ['3.5','5.5','8','11.5','16','22','30'] ; X-axis labels x_log = float(xnames) & x_log = alog10(x_log) ; X-axis is log scale xarr = alog10([4.5, 6.75, 9.75, 13.75, 19., 26.]) ; X-axis data locations xrange = alog10([3., 32.]) ; X-axis range ; ; The Y-axis range is determined by the scaling condition ; if not(info.scal) then yrange = [0., max(TSPEC_DATA)] $ else yrange = [min(TSPEC_DATA(where(TSPEC_DATA gt 0)) ), $ max(TSPEC_DATA)] ; ; Screen and hard copy outputs are different. ; ; if !d.name eq 'X' then csize = 1.7 else csize = 1. csize = 1.7 ; ; Output the plot. First the axis in white, then the spectra in colors. ; plot, XARR, TSPEC_DATA(*,0), /nodata, $ title='HXIS SPECTRA', $ xrange=xrange, yrange=yrange, $ xtickname=xnames, $ xtickv=x_log, $ xticks=6, $ xtitle='Energy (keV)', ytitle='counts/s', $ xmargin=[10,16], ymargin=[3.,2], $ charsize=csize, $ xcharsize=1., ycharsize=1., $ xstyle=1, ytype=info.scal ; ; the spectra are symbol and color coded ; psim = [1,2,4,5,6,7] & max_psim = n_elements(psim) colors = my_colors & max_col = n_elements(my_colors) ; ; When doing hard copy to grayscale printer lines should be in black ; if info.hard and not(info.colo) then colors = colors * 0 ; ; Plot each of the spectra ; left = 0.80 ; where the legend is positioned for I=0, info.nspec-1 do begin psym = psim(I mod max_psim) ; cycle through symbols colo = colors(i mod max_col) ; cycle through colors oplot, XARR, TSPEC_DATA(*,I), psym=-(psym), color=colo ; plot spectra plots, left, 0.65-I*.045, /normal, psym=psym, color=colo ; for legend A = hxisstrtime(INFO.DOY+double(TSPEC_TIME(I)/24.)) ; the time xyouts, left+.01,0.64-i*.045, /normal, A, color=colo ; output time endfor ; ; Write out applicable program parameter(s) ; A = .20 & B = 0.03 xyouts, LEFT,A,/normal,'Start time : ', size=CSIZE A = A-B ;t xyouts, LEFT,A,/normal, strmid(usestart,0,strpos(usestart,'.')), size=CSIZE xyouts, LEFT,A,/normal, usestart, size=CSIZE A = A-1.5*B xyouts, LEFT,A,/normal,'Stop time : ', size=CSIZE A = A-B ;e xyouts, LEFT,A,/normal, strmid(useend,0,strpos(useend,'.')), size=CSIZE xyouts, LEFT,A,/normal, useend, size=CSIZE A = A-1.5*B xyouts, LEFT, A, /normal,'Average : ', size=CSIZE A = A-B xyouts, LEFT, A, /normal, strtrim(string(format='(F10.1)',info.tover),1) + $ ' sec', size=CSIZE ; ; Reset that pesky Y-axis scale ; !Y.TYPE = 0 ; ; Up in the right top corner, do a contour plot with pixels used for calc. ; if n_elements(pixels) ne 512 then hxisedge_img ; ; Plot complete, close and print. ; if info.hard then hxishard, /fileclose, colo=info.colo return end