;+ ; This procedure displays a spectral line data container. If no ; dc is passed, the global container is used. ; ; @param dc {in}{optional}{type=data container or integer} a data container, ; or an integer index into the global data containers ; @keyword postscript {in}{optional}{type=boolean} If set, then this ; write to a postscript file given by filename. ; ; @keyword portrait {in}{optional}{type=boolean} If set and the ; postcript keyword is also set, then the postscript will be generated ; in portrait mode instead of the default landscape mode. ; ; @keyword filename {in}{optional}{type=string} Filename to use for ; postscript file. If not supplied, a file dialog will appear. This ; keyword is ignored unless postscript is set. ; ; @keyword reshow {in}{optional}{type=boolean} When set, then dc ; argument is ignored and the previously set xarray will be re-used ; here. This allows other routines to set the xarray and speeds up ; this procedure when the same data is being reshown. ; ; @keyword defaultx {in}{optional}{type=boolean} When set, the default ; x-axis (frame, velocity definition, units from the data header in ; absolute units) will be used. In the default case (unset), the current ; settings are retained. ; ; @keyword color {in}{optional}{type=long integer}{default=!g.showcolor} The ; color for the primary data. ; ; @examples ;
; ; a simple use of show: ; getrec,1 ; show ; ; ; retrieve some records and place them in global data containers 1-10 ; for i=1,10 do begin & getrec,i & copy,0,i & end ; ; show,2 ; show !g.s[2] ; show,5 ; show !g.s[5] ; oshow,6 ; overlay !g.s[6] ;; ; @version $Id: show.pro,v 1.38 2005/05/28 23:31:17 bgarwood Exp $ ;- pro show,dc,postscript=postscript,filename=filename,reshow=reshow, $ defaultx=defaultx,portrait=portrait,color=color common gbtplot_common,mystate,xarray plotterEmpty = data_valid(*mystate.dc_ptr) le 0 if (plotterEmpty and keyword_set(reshow)) then return if not keyword_set(postscript) and not gbtplot() then begin message,'No plotter! Check your DISPLAY environment variable setting.',/info return endif if (n_elements(color) eq 0) then begin if (keyword_set(reshow)) then begin ; reuse last use color color = mystate.lastshowcolor endif else begin ; default color color = !g.showcolor endelse endif mystate.lastshowcolor = color foreground = !g.foreground background = !g.background usecolor = 1 ; postscript always has white background, ensure forground is always black if keyword_set(postscript) then begin foreground=!black ; this background is used as a comparison later on, it doesn't ; actually matter to the postscript device background=!white ; the following controls how everything NOT forground and background behave if not !g.colorpostscript then begin usecolor = 0 color=foreground endif endif label_dc = ' ' newx = 0 if (!g.plotter_axis_type ne mystate.xtype) then begin case !g.plotter_axis_type of 0: setxunit, 'Channels' 1: begin ; 'Frequency' ; work out what scaling is best scalevals,(*mystate.dc_ptr).observed_frequency,fsky,fskyprefix newunits = fskyprefix + 'Hz' setxunit, newunits end 2: setxunit, 'km/s' else: begin message,'Unknown !g.plotter_axis_type value, using default units',/info defaultx = 1 end endcase newx = 1 endif if (not keyword_set(reshow)) then begin clearannotations,/noshow if n_params() ne 1 then begin dc = !g.s[0] endif ; If an integer is passed, use it as an index into the global DC's if size(dc,/type) eq 2 then begin if dc lt 0 or dc gt 15 then begin $ message,"Bad DC identifier.",/informational return endif label_dc = string('Data Container ',dc, format='(A,I2)') dc = !g.s[dc] endif if (data_valid(dc) le 0) then begin message,"Invalid data container",/informational return endif newx = 1 if dc.units eq 'Jy' then mystate.ytitle = 'Flux Density (Jy)' $ else if dc.units eq 'Ta*' then mystate.ytitle = 'Antenna Temperature (Ta*)' $ else if dc.units eq 'Ta' then mystate.ytitle = 'Antenna Temperature (Ta)' $ else if strlen(dc.units) eq 0 then mystate.ytitle = 'Intensity' $ else mystate.ytitle=dc.units data_copy, dc, *mystate.dc_ptr clearoplotslist clearoshowslist endif if (plotterEmpty or keyword_set(defaultx)) then begin ; set frame, default units, veldef, absrel for this scan mystate.absrel = 'Abs' veldef_ok = decode_veldef((*mystate.dc_ptr).velocity_definition, v_def, v_frame) if (veldef_ok le 0) then begin message, "Problems deciphering data.velocity_definition, velocities may be wrong", /info endif mystate.frame = v_frame mystate.veldef = v_def mystate.xoffset = 0.0D if (veldef_ok gt 0) then begin ; start out with frequencies, scaled appropriately ; use value of reference frequency as a guide to best scaling scalevals,(*mystate.dc_ptr).observed_frequency,fsky,fskyprefix case fskyprefix of 'G': begin mystate.xunit = 'GHz' mystate.xscale = 1.d9 end 'M': begin mystate.xunit = 'MHz' mystate.xscale = 1.d6 end 'k': begin mystate.xunit = 'kHz' mystate.xscale = 1.d3 end else: begin mystate.xunit = 'Hz' mystate.xscale = 1.d end endcase mystate.xtype = 1 endif else begin mystate.xunit = 'Channels' mystate.xtype = 0 mystate.xscale = 1.d endelse !g.plotter_axis_type = mystate.xtype widget_control, mystate.frame_id,set_value=mystate.frame widget_control, mystate.absrel_id,set_value=mystate.absrel widget_control, mystate.veldef_id,set_value=mystate.veldef widget_control, mystate.xunits_id,set_value=mystate.xunit newx = 1 endif if (newx) then begin if (mystate.absrel eq 'Rel') then begin mystate.xoffset = newxoffset(mystate.xtype, mystate.xscale, mystate.frame, mystate.veldef) endif else begin mystate.xoffset = 0.0D endelse setxarray endif yptr = (*mystate.dc_ptr).data_ptr ; reassign the actual values to dummy values, to accomodate bdrop and edrop nchan = (size(*yptr))[1] if (mystate.bdrop+mystate.edrop) ge nchan then begin message,'bdrop and edrop exclude all channels, nothing to show',/info return endif xarray2 = xarray[mystate.bdrop:(nchan-mystate.edrop-1)] yval2 = (*yptr)[mystate.bdrop:(nchan-mystate.edrop-1)] plotpos = [0.07,0.13,0.95,0.75] charsize = 1.4 updatePixmap = 1 if (keyword_set(postscript)) then begin if (n_elements(filename) eq 0) then begin filename='gbtidl.ps' filename = dialog_pickfile(file=filename,/write) endif if (strlen(filename) eq 0) then return ; user cancelled out of dialog set_plot,'PS' ; the use of scale, xoff, and yoff here is to get landscape ; to not come out inverted - the default case (seascape). ; The portrait numbers are the default case. if (keyword_set(portrait)) then begin charsize = 0.9 hdrCharsize = 0.85 if !g.colorpostscript then begin device,file=filename,/color,/portrait,/inches,scale=1.0, $ xoff=0.75,yoff=5.0 endif else begin device,file=filename,/portrait,/inches,scale=1.0, $ xoff=0.75,yoff=5.0 endelse endif else begin charsize = 1.2 hdrCharsize = 1.1 if !g.colorpostscript then begin device,file=filename,/color,/landscape,/inches,scale=-1.0, $ xoff=7.75,yoff=0.75 endif else begin device,file=filename,/landscape,/inches,scale=-1.0, $ xoff=7.75,yoff=0.75 endelse endelse annCharsizeFactor = charsize updatePixmap = 0 endif else begin hdrCharsize = charsize annCharsizeFactor = 1.0 wset,mystate.win_id endelse ; find x and y range of data and any overlays ; first x - x and y are treated differently minx = min(xarray2,max=maxx) thisptr = mystate.oshows_ptr while (ptr_valid(thisptr)) do begin this_struct = *thisptr thisData = (*this_struct.dc_ptr).data_ptr nchan = n_elements(*thisData) if (mystate.bdrop+mystate.edrop lt nchan) then begin ; okay to show this one, else skip silently thisminx = min(this_struct.x[mystate.bdrop:(nchan-mystate.edrop-1)], max=thismaxx) minx = minx < thisminx maxx = maxx > thismaxx endif thisptr = this_struct.next endwhile xrange=[minx,maxx] xstyle=1 if (mystate.xfix) then xrange=mystate.xrange ; then y - only want min and max within xrange ; convert xrange to channels chxrange = round(xtochan(xrange)) if chxrange[1] lt chxrange[0] then begin tmp=chxrange[0] chxrange[0] = chxrange[1] chxrange[1] = tmp endif if chxrange[0] lt 0 then chxrange[0] = 0 if chxrange[1] lt 0 then chxrange[1] = 0 if chxrange[0] ge n_elements(yval2) then chxrange[0] = n_elements(yval2)-1 if chxrange[1] ge n_elements(yval2) then chxrange[1] = n_elements(yval2)-1 miny = min(yval2[chxrange[0]:chxrange[1]],max=maxy) thisptr = mystate.oshows_ptr while (ptr_valid(thisptr)) do begin this_struct = *thisptr thisData = (*this_struct.dc_ptr).data_ptr nchan = n_elements(*thisData) ; convert xrange to channels in this overshow chxrange = round(xtochan(xrange,dc=*this_struct.dc_ptr)) if chxrange[1] lt chxrange[0] then begin tmp=chxrange[0] chxrange[0] = chxrange[1] chxrange[1] = tmp endif if chxrange[0] lt 0 then chxrange[0] = 0 if chxrange[1] lt 0 then chxrange[1] = 0 if chxrange[0] ge nchan then chxrange[0] = nchan-1 if chxrange[1] ge nchan then chxrange[1] = nchan-1 thisminy = min((*thisData)[chxrange[0]:chxrange[1]], max=thismaxy) miny = miny < thisminy maxy = maxy > thismaxy thisptr = this_struct.next endwhile yrange=[miny,maxy] ystyle=18 if (mystate.yfix) then begin yrange=mystate.yrange ystyle=1 endif if ((mystate.nzooms eq 0 or (not mystate.xfix and not mystate.yfix)) and mystate.nzooms ne 0) then begin ; *fix values are 0, reset zooms to all the way out mystate.nzooms = 0 mystate.xrange = [0.0,0.0] mystate.nzooms = 0 mystate.xfix = 0 mystate.yfix = 0 widget_control, mystate.unzoom_button, sensitive=0 zoom_text = string(mystate.nzooms,format='("Zoom Level:",i3)') widget_control,mystate.zoomlabel,set_value=zoom_text endif ; first plot sets axes et al, but doesn't plot any data plot,xrange,yrange,xrange=xrange,yrange=yrange,xstyle=xstyle,ystyle=ystyle,/nodata,$ pos=plotpos,xtitle=mystate.xtitle,ytitle=mystate.ytitle, $ xcharsize=charsize, ycharsize=charsize, background=background, color=foreground ; oplot actually plots the data in the appropriate color oplot,xarray2,yval2,color=color ; and the header nocolor = usecolor ? 0 : 1 show_header,dc=dc,charsize=hdrCharsize,label_dc=label_dc,foreground=foreground,nocolor=nocolor ; again in the other pixmap if necessary if (updatePixmap) then begin wset,mystate.pix_id plot,xrange,yrange,xrange=xrange,yrange=yrange,xstyle=xstyle,ystyle=ystyle,/nodata,$ pos=plotpos,xtitle=mystate.xtitle,ytitle=mystate.ytitle, $ xcharsize=charsize, ycharsize=charsize, background=background, color=foreground oplot, xarray2,yval2,color=color show_header,dc=dc,charsize=hdrCharsize,label_dc=label_dc,foreground=foreground,nocolor=nocolor mystate.xrange = !x.crange mystate.yrange = !y.crange wset,mystate.win_id endif thisptr = mystate.oshows_ptr if (mystate.overshows) then begin while (ptr_valid(thisptr)) do begin this_struct = *thisptr thisData = (*this_struct.dc_ptr).data_ptr nchan = n_elements(*thisData) if (mystate.bdrop + mystate.edrop) lt nchan then begin thisColor = this_struct.color if not usecolor or thisColor eq background then thisColor=foreground oplot, this_struct.x[mystate.bdrop:(nchan-mystate.edrop-1)], (*thisData)[mystate.bdrop:(nchan-mystate.edrop-1)], color=thisColor if (updatePixmap) then begin wset,mystate.pix_id oplot, this_struct.x[mystate.bdrop:(nchan-mystate.edrop-1)], (*thisData)[mystate.bdrop:(nchan-mystate.edrop-1)], color=thisColor wset,mystate.win_id endif endif thisptr = this_struct.next endwhile endif if (mystate.overplots) then begin thisptr = mystate.oplots_ptr while (ptr_valid(thisptr)) do begin thisColor = (*thisptr).color if not usecolor or thisColor eq background then thisColor = foreground if (thisColor ge 0) then begin oplot,(*thisptr).x, (*thisptr).y, color=thisColor endif else begin oplot, (*thisptr).x, (*thisptr).y endelse if (updatePixmap) then begin wset,mystate.pix_id if (thisColor gt 0) then begin oplot, (*thisptr).x, (*thisptr).y, color=thisColor endif else begin oplot, (*thisptr).x, (*thisptr).y endelse wset,mystate.win_id endif thisptr = (*thisptr).next endwhile endif mkcolor = !g.markercolor if not usecolor or mkcolor eq background then mkcolor=foreground for i=0,mystate.nmarkers-1 do begin oplot,[mystate.marker_pos[i,0]],[mystate.marker_pos[i,1]],psym=1,color=mkcolor xyouts,mystate.marker_pos[i,0],mystate.marker_pos[i,1],mystate.marker_txt[i],color=mkcolor if (updatePixmap) then begin wset,mystate.pix_id oplot,[mystate.marker_pos[i,0]],[mystate.marker_pos[i,1]],psym=1,color=mkcolor xyouts,mystate.marker_pos[i,0],mystate.marker_pos[i,1],mystate.marker_txt[i],color=mkcolor wset,mystate.win_id endif end vcolor = !g.vlinecolor if not usecolor or vcolor eq background then vcolor=foreground for i=0,mystate.nvlines-1 do begin oplot,[mystate.vline_pos[i,0],mystate.vline_pos[i,0]],mystate.yrange,color=vcolor if mystate.vline_ynorm[i] then begin yline = mystate.vline_pos[i,1] * (mystate.yrange[1] - mystate.yrange[0]) + mystate.yrange[0] endif else begin yline = mystate.vline_pos[i,1] endelse xyouts,mystate.vline_pos[i,0],yline,mystate.vline_txt[i],color=vcolor if (updatePixmap) then begin wset,mystate.pix_id oplot,[mystate.vline_pos[i,0],mystate.vline_pos[i,0]],mystate.yrange,color=vcolor xyouts,mystate.vline_pos[i,0],yline,mystate.vline_txt[i],color=vcolor wset,mystate.win_id endif end for i=0,mystate.n_annotations-1 do begin thisColor=mystate.ann_color[i] if not usecolor or thisColor eq background then thisColor=foreground if (mystate.ann_normal[i]) then begin xyouts,mystate.xyannotation[i,0],mystate.xyannotation[i,1],mystate.annotation[i], /normal, $ color=thisColor, charsize=mystate.ann_charsize[i]*annCharsizeFactor if (updatePixmap) then begin wset,mystate.pix_id xyouts,mystate.xyannotation[i,0],mystate.xyannotation[i,1],mystate.annotation[i], /normal, $ color=thisColor, charsize=mystate.ann_charsize[i]*annCharsizeFactor wset,mystate.win_id endif endif else begin xyouts,mystate.xyannotation[i,0],mystate.xyannotation[i,1],mystate.annotation[i], $ color=thisColor, charsize=mystate.ann_charsize[i]*annCharsizeFactor if (updatePixmap) then begin wset,mystate.pix_id xyouts,mystate.xyannotation[i,0],mystate.xyannotation[i,1],mystate.annotation[i], $ color=thisColor, charsize=mystate.ann_charsize[i]*annCharsizeFactor wset,mystate.win_id endif endelse end zcolor = !g.zlinecolor if not usecolor or zcolor eq background then zcolor=foreground if mystate.zline eq 1 then begin oplot,mystate.xrange,[0,0],color=zcolor if (updatePixmap) then begin wset,mystate.pix_id oplot,mystate.xrange,[0,0],color=zcolor wset,mystate.win_id endif endif if (keyword_set(postscript)) then begin device,/close set_plot,'X' print,'Postscript file written: ', filename endif else begin ; select default to get this out of the way wset,-1 endelse return end