image_show.pro

来自「IDL语言编写的用于天文自适应光学仿真的软件CAOS V6.0的第一部分。」· PRO 代码 · 共 513 行 · 第 1/2 页

PRO
513
字号
; $Id: image_show.pro,v 1.5 2002/12/06 14:40:42 riccardi Exp $pro image_show, input, x_vec, y_vec, NX=nx, NY=ny, XAXIS=xax, YAXIS=yax $    , WINDOW_SCALE = window_scale, ASPECT = aspect, MAX_VALUE = max_value $    , MIN_VALUE = min_value, SHOW_BAR = show_bar, INV = inv, POSIZ = posiz $    , DIG = dig, INTERP=interp, _EXTRA=plot_keywords, SCALE = scale $    , BAR_TITLE=ytitle_bar, NOERASE=noerase, NO_GT=no_gt, NO_LT=no_lt $    , TITLE=title, YTITLE=ytitle, YTICKF_BAR=ytickf_bar, YSTYLE=ystyle $    , XSTYLE=xstyle, COL_INVERT=col_invert, LOG=log, XBAR=xbar $    , CONTOUR=do_contour, NLEV = nlev ,PERCENT = percent;+; NAME:;   IMAGE_SHOW;; PURPOSE:;   Display an image.;; CATEGORY:;   General graphics.;; CALLING SEQUENCE:;; image_show, input, x_vec, y_vec, NX=nx, NY=ny, XAXIS=xax, YAXIS=yax $;    , WINDOW_SCALE = window_scale, ASPECT = aspect, MAX_VALUE = max_value $;    , MIN_VALUE = min_value, SHOW_BAR = show_bar, INV = inv, POSIZ = posiz $;    , DIG = dig, INTERP=interp, _EXTRA=plot_keywords, SCALE = scale $;    , BAR_TITLE=ytitle_bar, NOERASE=noerase, NO_GT=no_gt, NO_LT=no_lt $;    , TITLE=title, YTITLE=ytitle, YTICKF_BAR=ytickf_bar, YSTYLE=ystyle $;    , XSTYLE=xstyle, COL_INVERT=col_invert, LOG=log, XBAR=xbar $;    , CONTOUR=do_contour, NLEV = nlev ,PERCENT = percent;; INPUTS:;   input:  If x_vec and y_vec are not present, "input" is the two-dimensional array;           to display. If x_vec and y_vec are present, "input" is a vector of values;           of the map to dispaly in the corresponding irregular grid defined by x_vec;           and y_vec.;;   x_vec, y_vec  cannot be used when "input" is a two-dimensional array. If they are;           defined, they have to be vectors with the same size as "input". In the last;           case TRIGRID is used to obtain a regular gridded two-dimensional array;           to display.;; KEYWORD PARAMETERS:;;   NX,NY:  Used only when three parameters are passed. Same keywords as TRIGRID.;;	XAXIS:	Two elements array containing minimum and maximum x-axis values;;	YAXIS:	Two elements array containing minimum and maximum y-axis values;;   WINDOW_SCALE:   Set this keyword to scale the window size to the image size.;       Otherwise, the image size is scaled to the window size.;       This keyword is ignored when outputting to devices with;       scalable pixels (e.g., PostScript).;;   ASPECT: Set this keyword to retain the image's aspect ratio.;       Square pixels are assumed.  If WINDOW_SCALE is set, the;       aspect ratio is automatically retained.;;   MAX_VALUE: Set this keyword to change the limit of the lookup table;;   MIN_VALUE: Set this keyword to change the limit of the lookup table;;   SHOW_BAR: Set this keyword to show the color lookup table;;   INV: Set this keyword to invert the lookup table (can be used to;        reduce the amount of toner/ink used when printing certain images);;   POSIZ: Returns the device coordinates of the displayed image;          (can be used to overplot something on the main image);;   DIG: Sets the number of digits used to label the ticks of the lookup table;           (otherwise set automatically);;   INTERP: Uses an interpolation method as described in the routine;           poly_2d;;	_EXTRA: Allows to use the general keywords used with the plot routine to;           insert titles and other features (see help on plot).;;   SCALE:  Scales x and y axis (not used on XAXIS or YAXIS values);;	BAR_TITLE: Allows to insert a title over the color bar;;   XBAR:    0.0 < xbar < 1.0, normalized starting point of the color bar;            in the horizontal direction of the plotting window.;            0.75 by default;;   NOERASE: If set, the window or page is not erased before plotting;;   YTICKF_BAR: tick format strin of the color bar labels;;   COL_INVERT: invert the background and foreground colors;;   LOG:    if set, display the array values using logarithmic scale;;   CONTOUR:  if set, overplot a contour plot on the array map;;   NLEV:   number of levels to use in the contour plot (10 by default);;   PERCENT: if set, contour label are expressed in percent value of;             the plotting range;;   EQUALIZE: if set, the function equalize_limit is called to compute;             the optimal color cuts. MIN_VALUE and MAX_VALUE keywords;             override the EQUALIZE setting.;; OUTPUTS:;   No explicit outputs.;; COMMON BLOCKS:;   None.;; SIDE EFFECTS:;   The currently selected display is affected.;; RESTRICTIONS:;   None.;; PROCEDURE:;   If the device has scalable pixels, then the image is written over;   the plot window.;; MODIFICATION HISTORY:;   DMS, May, 1988. (image_cont);	several times. G. Brusa Zappellini (Osservatorio Astrofisico di Arcetri);                  brusa@arcetri.astro.it.;   Mar 2002. A. Riccardi (OAA) riccardi@arcetri.astro.it;             Keywords CONTOUR, NLEV, PERCENT added.;             Computation of the optimal value for DIG if is not not passed.;   Mar 2002. AR, Implemented the possibility to pass an irregularly gridded set of points.;   Dic 2002. GBZ, added the XBAR keyword;   Dic 2002. AR, Error in the computation of the optimal value of dig fixed.;                 Image x-size is computed as 95% of xbar.;                 Definition of NX and NY keyword fixed.;                 New data type (code numbers from 12 to 15, see SIZE function) are;                 now accepted. The data type check is performed earlier in the code.;                 Check on the x_vec and y_vec data type added.;                 keyword EQUALIZE added;-;; initial settings;    ;on_error,2                 ;Return to caller if an error occurs	npar = n_params()	if npar ne 1 and npar ne 3 then message, "Wrong number of parameters"	sz = size(input)    dtype=sz(sz(0)+1)    if dtype lt 1 or (dtype gt 5 and dtype lt 12) then message, 'Data type no valid'	if npar eq 1 then begin	    image=reform(input)	    sz = size(image)                ;Size of image    	if sz(0) ne 2 then message, 'Parameter not 2D'    endif else begin    	n_el = n_elements(input)		sz = size(x_vec)	    dtype=sz(sz(0)+1)	    if dtype lt 1 or (dtype gt 5 and dtype lt 12) then message, 'x_vec data type no valid'		sz = size(y_vec)	    dtype=sz(sz(0)+1)	    if dtype lt 1 or (dtype gt 5 and dtype lt 12) then message, 'y_vec data type no valid'    	if n_elements(x_vec) ne n_el or n_elements(y_vec) ne n_el then $    		message, "input, x_vec and y_vec must have the same size"    	TRIANGULATE, x_vec, y_vec, tr, b    	image = TRIGRID(x_vec, y_vec, input, tr, NX=nx, NY=ny, MISSING=min(input))    	sz = size(image)    endelse	if keyword_set(do_contour) then contour_image=image	if n_elements(xbar) eq 0 then xbar=0.75	if keyword_set(log) then begin	 	mass_lin=max(image) & mini_lin=min(image)	 	if min(image) le 0 then message,'Image contains values <=0',/cont	 	except=!except        ret=check_math(/print)        !except=0		image=alog10(image)		ret=check_math()        !except=except        if keyword_set(equalize) and (n_elements(max_value) eq 0 or n_elements(min_value) eq 0) then $        	eq_minmax = equalize_limits(image)		if n_elements(max_value) ne 0 then begin			mass_lin=max_value			mass=alog10(max_value)		endif else if keyword_set(equalize) then begin			mass_lin=10^eq_minmax[1]			mass=eq_minmax[1]		endif else begin			mass=max(image)		endelse    	if n_elements(min_value) ne 0 then begin    		mini_lin=min_value    		mini=alog10(min_value)		endif else if keyword_set(equalize) then begin			mini_lin=10^eq_minmax[0]			mini=eq_minmax[0]		endif else begin			mini=min(image)		endelse	endif else begin		if n_elements(max_value) ne 0 then mass=max_value else mass=max(image)    	if n_elements(min_value) ne 0 then mini=min_value else mini=min(image)    endelse    if n_elements(scale) eq 0 then scale=[1.0,1.0]    if n_elements(xax) eq 0 then xax=findgen(sz(1))/(sz(1)-1)*sz(1)*scale[0]    if n_elements(yax) eq 0 then yax=findgen(sz(2))/(sz(2)-1)*sz(2)*scale[1]    if (keyword_set(inv)) then begin        show=bytscl(float(-image),min=-mass,max=-mini,top=!d.table_size)    endif else begin        show=bytscl(float(image),min=mini,max=mass,top=!d.table_size)    endelse    if n_elements(dig) ne 0 then dig=dig(0)>0    if n_elements(ytitle_bar) eq 0 then ytitle_bar=""    if n_elements(title) eq 0 then title=""    if n_elements(ytitle) eq 0 then ytitle=""    if n_elements(xstyle) eq 0 then xstyle=1    if n_elements(ystyle) eq 0 then ystyle=1	if keyword_set(COL_INVERT) then begin		device,decompose=1		background_old=!p.background		color_old=!p.color		!p.background=color_old		!p.color=background_old	endif;; set window used by plot;    pposition_old=!p.position    pregion_old=!p.region    pmulti_old=!p.multi    pflag='nul'    if keyword_set(show_bar) then begin    	; 0 < ximage < xbar < 1		ximage=xbar*0.95        if !p.position[0] ne !p.position[2] then begin        	pflag='pos'        	pposition=!p.position        	dpposition=pposition[2:3]-pposition[0:1]		    pimage=[pposition[0:1],pposition[0:1]+dpposition*[ximage,1]]		    pbar=[pimage[0:1]+dpposition*[xbar,0],pposition[2:3]]            !p.position=pimage        endif else begin

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?