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

Home » Public Forums » archive » Re: array subscripting problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: array subscripting problem [message #43416] Mon, 11 April 2005 08:11 Go to previous message
Benjamin Luethi is currently offline  Benjamin Luethi
Messages: 22
Registered: December 2004
Junior Member
Hi Martin,

You could also extract a 3x3 sub-array first and then do the comparisons
on it. This way you don't need any if checks at all:

s = Size(data, /Dimensions)
subarray=data[ ((i-1)>0):((i+1)<(s[0]-1)), ((j-1)>0):((j+1)<(s[1]-1)), k ]
f=f+total(ABS(cd-subarray) LE mg)-1

Notice that the subarray is not 3x3 if i or j are at the border.
Also notice the -1 in the third line: it's because the [i,j]-element is
always part of the subarray and counts as well.

Ben

On 11 Apr 2005 06:00:14 -0700, Martin Doyle <m.doyle@uea.ac.uk> wrote:

> Hi Guys,
>
> I've got a gridded dataset and I'm searching the grid trying to find
> those points which have a certain value. Once I've found this point, I
> want to check all points around it to see if they have the same value
> plus a little bit. This is what I've come up with:
>
> If (data(i,j,k) GE p) THEN begin
>
> cd = data(i,j,k)
>
> If(ABS(cd-data[i-1,j-1,k]) LE mg) then f = f+1
> If(ABS(cd-data[i, j-1,k]) LE mg) then f = f+1
> If(ABS(cd-data[i+1,j-1,k]) LE mg) then f = f+1
> If(ABS(cd-data[i-1,j, k]) LE mg) then f = f+1
> If(ABS(cd-data[i+1,j, k]) LE mg) then f = f+1
> If(ABS(cd-data[i-1,j+1,k]) LE mg) then f = f+1
> If(ABS(cd-data[i, j+1,k]) LE mg) then f = f+1
> If(ABS(cd-data[i+1,j+1,k]) LE mg) then f = f+1
>
> endif
>
> However, array subscripting with negative numbers isn't allowed by
> IDL.
>
> Has anyone any ideas how I might get around this?
>
> Many thanks!
>
> All the best
> Martin



--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: vector matrix multipication
Next Topic: Re: vector matrix multipication

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

Current Time: Sat Oct 11 07:17:48 PDT 2025

Total time taken to generate the page: 1.35809 seconds