image_show.pro
来自「IDL语言编写的用于天文自适应光学仿真的软件CAOS V6.0的第一部分。」· PRO 代码 · 共 513 行 · 第 1/2 页
PRO
513 行
if !p.region[0] ne !p.region[2] then begin pflag='reg' pregion=!p.region dpregion=pregion[2:3]-pregion[0:1] pimage=[pregion[0:1],pregion[0:1]+dpregion*[ximage,1]] pbar=[pimage[0:1]+dpregion*[xbar,0],pregion[2:3]] !p.region=pimage endif else begin if total(!p.multi) ne 0 then begin pflag='mul' nc=!p.multi(1) ;number of columns in the multi plot nr=!p.multi(2) ;number of rows in the multi plot nfr=nc*nr if !p.multi(0) eq 0 then begin ifr=0 ;frame index from 0 to nfr-1 endif else begin ifr=nfr-!p.multi(0) noerase=1 endelse if !p.multi(4) eq 0 then begin ir=ifr/nc ic=ifr-ir*nc endif else begin ic=ifr/nc ir=ifr-ic*nr endelse ir=nr-ir-1 ir=float(ir) & ic=float(ic) pregion=[ic/nc, ir/nr, (ic+1)/nc , (ir+1)/nr] dpregion=pregion(2:3)-pregion(0:1) pimage=[pregion(0:1),pregion(0:1)+dpregion*[ximage,1]] pbar=[pimage(0:1)+dpregion*[xbar,0],pregion(2:3)] !p.region=pimage !p.multi=0 endif else begin pflag='nul' pimage=[0,0,ximage,1] pbar=[xbar,0,1,1] endelse endelse endelse endif plot,[min(xax),max(xax)],[min(yax),max(yax)] $ , /nodata,xstyle=xstyle and 4, ystyle=ystyle and 4, noerase=noerase $ , color=!P.BACKGROUND, _EXTRA=plot_keywords, TITLE=title, YTITLE=ytitle px = !x.window * !d.x_vsize ;Get size of window in device units py = !y.window * !d.y_vsize swx = px(1)-px(0) ;Size in x in device units swy = py(1)-py(0) ;Size in Y if keyword_set(show_bar) then swx=swx*ximage if swx le 0.0 or swy le 0.0 then begin message, 'Image can not be displayed',/cont goto,fine endif six = float(sz(1)) ;Image sizes siy = float(sz(2)) aspi = six / siy ;Image aspect ratio aspw = swx / swy ;Window aspect ratio f = aspi / aspw ;Ratio of aspect ratios ;plot,[min(xax),max(xax)],[min(yax),max(yax)] $ ; , /nodata,xstyle=4, ystyle=4, /noerase, color=0 $ ; , title="", xtitle="", ytitle="" if (!d.flags and 1) ne 0 then begin ;Scalable pixels? if keyword_set(aspect) then begin ;Retain aspect ratio? ;Adjust window size if f ge 1.0 then swy = swy / f else swx = swx * f endif tv1,show,px(0),py(0),xsize = swx, ysize = swy, /device endif else begin ;Not scalable pixels if keyword_set(window_scale) then begin ;Scale window to image? tv1,show,px(0),py(0) ;Output image swx = six ;Set window size from image swy = siy endif else begin ;Scale window if keyword_set(aspect) then begin if f ge 1.0 then swy = swy / f else swx = swx * f endif ;aspect ;Have to resample image tv1,poly_2d(show $ , [[0,0],[six/swx,0]], [[0,siy/swy],[0,0]],keyword_set(interp) $ , swx,swy), px(0),py(0) endelse ;window_scale endelse ;scalable pixels posiz=[px(0),py(0),px(0)+swx,py(0)+swy] plot,[min(xax),max(xax)],[min(yax),max(yax)] $ , /noerase,/nodata,xst=xstyle,yst=ystyle $ , pos = posiz $ , /dev, _EXTRA=plot_keywords, TITLE=title $ , YTITLE=ytitle ; ; Overplot contours if requested ; if keyword_set(do_contour) then begin if (n_elements(nlev) eq 0) then nlev=10 mx = !d.n_colors-1 ;Brightest color colors=fltarr(nlev) colors[0:nlev/2-1]=mx & colors[nlev/2:*]=0 if keyword_set(inv) then colors = mx - colors if !d.name eq 'PS' then begin colors = mx - colors ;invert line colors for pstscrp temp=mass & mass=-mini & mini=-temp endif xl=findgen(nlev)/(nlev-1)*(mass-mini)+mini if keyword_set(log) then begin xann=strtrim(string(10^xl,format='(e10.2)'),2) contour,contour_image,/noerase,xst=1+4,yst=1+4,$ ;Do the contour pos = posiz,/dev,$ c_color = colors,$ levels=10^xl,c_annotation=xann,/follow, $ max_value=10^mass, min_value=10^mini, chars=1.2, ZLOG=LOG endif else begin if (keyword_set(percent)) then begin xann=strmid(strtrim(string((findgen(nlev-1)+1)/nlev*100),2),0,2)+'%' endif else begin xann=strtrim(string(xl,format='(e10.2)'),2) endelse contour,contour_image,/noerase,xst=1+4,yst=1+4,$ ;Do the contour pos = posiz,/dev,$ c_color = colors,$ levels=xl,c_annotation=xann,/follow, $ max_value=mass, min_value=mini, chars=1.2, ZLOG=LOG endelse endif;; color bar; if keyword_set(show_bar) then begin; checks min and max values if pflag eq 'pos' then begin message,'Bar cannot be displaied: set the variable !p.position to 0',/cont goto,fine endif !p.position=0 !p.region=pbar if mass eq mini then goto,fine except=!except ret=check_math(/print) !except=0 res=machar(double=(dtype eq 5)) expo=ceil(alog10(-alog10(res.xmin))) ret=check_math() !except=except if n_elements(dig) ne 0 then begin digits=dig(0); endif else digits=-floor(alog10(res.eps)) endif else begin max_digits=-floor(alog10(res.eps)) digits=(ceil(alog10(abs(mini)/(mass-mini)))+1)<max_digits>1 endelse mx = !d.table_size ;Brightest color show=reform(bindgen(mx),1,mx) sz = size(show) if (keyword_set(inv)) then show=-show dig_p=digits extra_dig=6 ;IDL under Windows uses 6 extra characters for the E format and not 5! if n_elements(ytickf_bar) ne 0 then begin noplot=0B tot_p=strlen(string(0.0,format=ytickf_bar)) plot,[[0,0],[1,1]],/nodata, xstyle=4, ystyle = 4, /noerase $ , xmargin= tot_p,TITLE=ytitle_bar, _EXTRA=plot_keywords, color=!P.BACKGROUND, YTICKF=ytickf_bar px = !x.window * !d.x_vsize ;Get size of window in device units py = !y.window * !d.y_vsize swx = px(1)-px(0) ;Size in x in device units swy = py(1)-py(0) ;Size in Y if ((swx le 0.0 or swy le 0.0) and ((!d.flags and 1) ne 0)) or $ ((swx le 10.0 or swy le 10.0) and ((!d.flags and 1) eq 0)) $ then noplot=1B endif else begin repeat begin noplot=0B tot_p=dig_p+expo+extra_dig plot,[[0,0],[1,1]],/nodata, xstyle=4, ystyle = 4, /noerase $ , xmargin=tot_p, TITLE=ytitle_bar, _EXTRA=plot_keywords, color=!P.BACKGROUND px = !x.window * !d.x_vsize ;Get size of window in device units py = !y.window * !d.y_vsize swx = px(1)-px(0) ;Size in x in device units swy = py(1)-py(0) ;Size in Y if ((swx le 0.0 or swy le 0.0) and ((!d.flags and 1) ne 0)) or $ ((swx le 10.0 or swy le 10.0) and ((!d.flags and 1) eq 0)) $ then begin dig_p=dig_p-1 noplot=1B endif endrep until not(noplot) or dig_p lt 0 endelse if noplot then begin print, 'Bar can not be displayed' goto, fine endif six = float(sz(1)) ;Image sizes siy = float(sz(2)) aspi = six / siy ;Image aspect ratio aspw = swx / swy ;Window aspect ratio f = aspi / aspw ;Ratio of aspect ratios if (!d.flags and 1) ne 0 then begin ;Scalable pixels? tv1,show,px(0),py(0),xsize = swx, ysize = swy, /device endif else begin ;Not scalable pixels ;Have to resample image tv1,poly_2d(show $ , [[0,0],[six/swx,0]], [[0,siy/swy],[0,0]],0 $ , swx,swy), px(0),py(0) endelse ;scalable pixels if n_elements(dig) ne 0 then begin if dig_p lt dig then print,'Requested # of digits does not fit' endif val=mini+(mass-mini)*indgen(11)/10 if n_elements(ytickf_bar) ne 0 then begin form=ytickf_bar endif else form='(E'+strtrim(tot_p,2)+'.'+strtrim(dig_p,2)+')' vals=string(val,format=form) if (keyword_set(max_value) and not keyword_set(no_gt)) then vals(10)=">"+vals(10) if (keyword_set(min_value) and not keyword_set(no_lt)) then vals(0)="<"+vals(0) if keyword_set(log) then begin plot,[0,0],[mini_lin,mass_lin],/nodata, xstyle=1+4, ystyle=1+4, /noerase $ , xmargin=tot_p, TITLE=ytitle_bar, _EXTRA=plot_keywords,/ylog axis,yaxis=0,_EXTRA=plot_keywords, ystyle=1,yticklen=0.2 endif else begin plot,[0,0],[1,1],/nodata, xstyle=1+4, ystyle=1+4, /noerase $ , xmargin=tot_p, TITLE=ytitle_bar, _EXTRA=plot_keywords axis,yaxis=0,yticks=10,ytickn=vals, _EXTRA=plot_keywords endelse endif if keyword_set(COL_INVERT) then begin !p.background=background_old !p.color=color_old endif fine: !p.position=pposition_old !p.region=pregion_old if total(pmulti_old) ne 0 and keyword_set(show_bar) then begin if pmulti_old(0) eq 0 then begin !p.multi=[pmulti_old(1)*pmulti_old(2)-1,pmulti_old(1:4)] endif else begin !p.multi=[pmulti_old(0)-1,pmulti_old(1:4)] endelse endif end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?