comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Polar treatment of a 2D array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Polar treatment of a 2D array [message #15081] Thu, 22 April 1999 00:00
bowman is currently offline  bowman
Messages: 121
Registered: September 1991
Senior Member
In article <371E77DE.6740C7B8@cs.oberlin.edu>, Jim Sheckard
<jsheckar@cs.oberlin.edu> wrote:

> I am currently working on a pulsar project, and we have found that the
> ability to select points out of a polar slice of an array would be very
> useful to our work. I was about to start implementing this particular
> routine when it was suggested that someone might already have done this.
> So my question is: Does anyone have a routine that will select points
> out of an angular region of an array, or one that takes an average over
> such a region? If not, then I'll just try to implement it, but I
> thought I'd check. Thank you for your time.

Something like this should work:

sz = SIZE(a) ;Get size of array
nx = sz[1] ;Get size of x-dimension
ny = sz[2] ;Get size of y-dimension
n = nx > ny ;Find largest dimension in
case array is not square

x = FINDGEN(nx)/n # REPLICATE(1.0, ny) ;Create 'x-coordinates' of
each array element
y = REPLICATE(1.0, nx) # FINDGEN(ny)/n ;Create 'y-coordinates' of
each array element
r = SQRT(x^2 + y^2) ;Just in case you need it

This assumes that the cells of the array are square and the origin is at
the lower left corner (first quadrant convention). If not, you will need
to change how x and y are computed.

You need to decide what to do at the point (0,0), since ATAN is undefined
there. The best solution is probably to put the origin somewhere other an
exactly at a grid point (i.e., the center of the array, with nx or ny
even, rather than the corner). Or you can handle it as a special case.

Then do

theta = ATAN(y, x) ;Compute polar angle
slice = WHERE((theta GT theta_min) AND (theta LT theta_max), count) ;Find
points in slice
mean = TOTAL(a[slice])/count

(I can't remember the order of the arguments in ATAN. Check to be sure.)

Ken Bowman
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Object Oriented programming question
Next Topic: Re: Varaibles higher on the stack

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:10:59 PDT 2025

Total time taken to generate the page: 0.00588 seconds