Thanks Daniele.

I am writing a small plotting function that can receive the index range as argument value.
like I have variables var1, var2, var3, var4, var5 which have exactly the same dimensions.

def plot_eg(index_range):
      #here I need the function above which can use the index_range to retrieve data from variables
      plot(func(var1,index_range)))
      plot(func(var2,index_range))
      plot(func(var3,index_range))
      plot(func(var4,index_range))
      plot(func(var5,index_range))

actually I can also put the [var1,var2,var3,var4,var5] as arguments in the plot_eg function so that I can pick any variables I want to plot as long as they have the same dimension. otherwise, I have to change the index_range for every variable.

cheers,

Chao

2012/7/13 Daniele Nicolodi <daniele@grinta.net>
On 12/07/2012 23:32, Chao YUE wrote:
> Thanks all for the discussion. Actually I am trying to use something
> like numpy ndarray indexing in the function. Like when I call:
>
> func(a,'1:3,:,2:4'), it knows I want to retrieve a[1:3,:,2:4], and
> func(a,'1:3,:,4') for a[1:3,:,4] ect.
> I am very close now.

I don't see the advantage of this approach over directly using the
sliced array as an argument of your function, as in func(a[1:3,:,4]).

Can you elaborate more why you are going through this route?

Cheers,
Daniele
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion



--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************