;Make a linear ramp of any dimension ; input ; a - value at low-index end of ramp ; b - value at high-index end of ramp ; n - array of ramp dimension size ; d - dimension along which to take the ramp, where the leftmost ; dimension is 0 and rightmost is n_elements(n)-1 ; return ; an n_elements(n)-dimensional ramp, taken along dimension d ; example ; Suppose you want to evaluate a function ; v=f(x,y) ; where x ranges from -10 to 10 and y ranges from 0 to 5. You want ; 200 points in the x direction and 100 in the y direction. Do this ; x=ramp(-10,10,[200,100],0) ; y=ramp( 0, 5,[200,100],1) ; Notice that n, the size of the ramp, should be the same in both cases, ; but the a and b bounds can be different and the d dimension must be ; different. Then if your function f() can handle arrays, just do this: ; v=f(x,y) ; to get a 200x100 grid of v suitable for tvscl or any further analysis. ; ; If you have a 3D problem v=f(x,y,z), no problem ; x=ramp(-10,10,[200,100,100],0) ; y=ramp( 0, 5,[200,100,100],1) ; z=ramp( 0, 5,[200,100,100],2) ; v=f(x,y,z) ; ; This works with any dimension up to the IDL limit of 8, function ramp,a,b,n,d,inc=inc,delta=delta ;Create a 1D ramp if ~keyword_set(delta) then begin result=range(a,b,n[d],inc=inc) end else begin result=range(a,b,this_n,inc=inc,delta=delta[d]) if n_elements(n) gt d then n[d]=this_n end ;Rearrange it to a [1x...x1xn] ramp dim=n*0+1 dim[n_elements(n)-1]=n[d] result=reform(result,dim) ;Stretch it to the proper size, except ;put the ramp dimension last and the last ;dimension in the slot for the ramp dimension dim=n dim[n_elements(n)-1]=n[d] dim[d]=n[n_elements(n)-1] result=rebin(result,dim,/sample) ;Transpose it to put the ramp dimension ;where it belongs trans=indgen(n_elements(n)) trans[d]=n_elements(n)-1 trans[n_elements(n)-1]=d result=transpose(result,trans) return,result end