[Numpy-discussion] Finding indices and setting values
Cliff Martin
camartin at snet.net
Wed May 21 08:09:02 EDT 2003
Hi,
I have a problem where I want to set values in a 2D array based on
conditions I’ve established. The variables are the NA of the system, its
wavelength and the correct units on the device I’m modeling. Using these
variables I define a variable N. I set up a 512 by 512 array [x,y]. Then
I set up a radius , r = x^2 +y^2 and ask it to give me all r’s(to the
closest integer) <= N(the variable I’ve defined above). This gives all
the index values in that radius and then I set all those locations to a
value of 1. After this I do some FFT ‘s, etc. So how do I do this in
Numerical Python without having to index through i,j steps which would
be incredibly tedious. This works fairly well in MatLab but I want to
port my program to Python(for lots of reasons). If you’d rather I write
the MatLab code snippet I can do that. Thanks.
Cliff Martin
More information about the NumPy-Discussion
mailing list