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

Home » Public Forums » archive » Re: IDL out of range error
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: IDL out of range error [message #70145] Tue, 16 March 2010 06:20
Suguru Amakubo is currently offline  Suguru Amakubo
Messages: 24
Registered: March 2010
Junior Member
Thank you very much I will go and test everything now that I know
where to look. :)

And yes print statements will be everywhere.

Again thank you all very much for helping me will be back later with
an update on my status. :)
Re: IDL out of range error [message #70146 is a reply to message #70145] Tue, 16 March 2010 06:13 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Suguru Amakubo writes:

> But how did this happen when I used if conditions to prevent this
> exact situation?
>
> What I did was that if the index goes into the 'rim' of the image past
> y0+L-1 and/or x0+L-1 then the sub image will be forced back into the
> image so it does not fall out or range.

Well, my best guess is that you *think* you did something
that you didn't actually do. Remember, print statements
are your friends here. :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: IDL out of range error [message #70147 is a reply to message #70146] Tue, 16 March 2010 06:12 Go to previous message
Suguru Amakubo is currently offline  Suguru Amakubo
Messages: 24
Registered: March 2010
Junior Member
Very sorry about that I pressed refresh accidentally
Re: IDL out of range error [message #70148 is a reply to message #70147] Tue, 16 March 2010 06:11 Go to previous message
Suguru Amakubo is currently offline  Suguru Amakubo
Messages: 24
Registered: March 2010
Junior Member
Ow dear lord! Yes I saw it now I don't know how I missed that y0+L-1
is completely out of range.

But how did this happen when I used if conditions to prevent this
exact situation?

What I did was that if the index goes into the 'rim' of the image past
y0+L-1 and/or x0+L-1 then the sub image will be forced back into the
image so it does not fall out or range.
Re: IDL out of range error [message #70149 is a reply to message #70148] Tue, 16 March 2010 06:08 Go to previous message
Suguru Amakubo is currently offline  Suguru Amakubo
Messages: 24
Registered: March 2010
Junior Member
Ow dear lord! Yes I saw it now I don't know how I missed that y0+L-1
is completely out of range.

But how did this happen when I used if conditions to prevent this
exact situation?

What I did was that if the index goes into the 'rim' of the image past
y0+L-1 and/or x0+L-1 then the sub image will be forced back into the
image so it does not fall out or range.
Re: IDL out of range error [message #70150 is a reply to message #70149] Tue, 16 March 2010 06:07 Go to previous message
Suguru Amakubo is currently offline  Suguru Amakubo
Messages: 24
Registered: March 2010
Junior Member
Ow dear lord! Yes I saw it now I don't know how I missed that y0+L-1
is completely out of range.

But how did this happen when I used if conditions to prevent this
exact situation?

What I did was that if the index goes into the 'rim' of the image past
y0+L-1 and/or x0+L-1 then the sub image will be forced back into the
image so it does not fall out or range.
Re: IDL out of range error [message #70151 is a reply to message #70150] Tue, 16 March 2010 05:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Suguru Amakubo writes:

> Thank you for your help here is what I get:
>
> IDL> help, new_image2
> NEW_IMAGE2 (BLOCK_MONTE)
> FLOAT = Array[400, 400]
>
> and
>
> IDL> print, x0, x0+L-1, y0, y0+L-1
> 382 411 1 30

Yes, and alarm bells didn't go off for you? :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: IDL out of range error [message #70152 is a reply to message #70151] Tue, 16 March 2010 05:56 Go to previous message
Suguru Amakubo is currently offline  Suguru Amakubo
Messages: 24
Registered: March 2010
Junior Member
Thank you for your help here is what I get:

IDL> help, new_image2
NEW_IMAGE2 (BLOCK_MONTE)
FLOAT = Array[400, 400]

and

IDL> print, x0, x0+L-1, y0, y0+L-1
382 411 1 30
Re: IDL out of range error [message #70153 is a reply to message #70152] Tue, 16 March 2010 05:41 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Suguru Amakubo writes:

> dear David Fanning yes I sincerely agree and I have broken down the
> code in multiple places and the error seems to be present in the line
> with sub definition. I have checked the values but it seems fine I
> cannot comprehend why it is stopping me.

Well, I'll tell you want to do. When your program
stops, send us the results of these commands:

IDL> Help, new_image2
IDL> print, x0, x0_L-1, y0, y0_L-1

Then, we will make some sense of it. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: IDL out of range error [message #70154 is a reply to message #70153] Tue, 16 March 2010 05:31 Go to previous message
Suguru Amakubo is currently offline  Suguru Amakubo
Messages: 24
Registered: March 2010
Junior Member
Thank you for the quick response :)

dear pp the error is at the line which has sub.

The dimension of sub and test when using 'help,' command are both
(L,L) with index on the corner. As for the index I am using x0 and y0
as the bottom left corner.

sub and test are both portions of the new_image2 from different
indexes with fixed dimension (L,L)

dear David Fanning yes I sincerely agree and I have broken down the
code in multiple places and the error seems to be present in the line
with sub definition. I have checked the values but it seems fine I
cannot comprehend why it is stopping me.

Thank you in advance for the kind help. Below is the code that I am
stuck on (I have capitalised the line that is causing me the problem),
hopefully this will explain what I am trying to do clearly:

pro chi_detection,sub

common block_chi, delta, L ,tr_point
common block_monte, size_of_image, new_image, new_image2, mc_point

deltamin = 1e8

nn=n_elements(mc_point(0,*))

tr_point = fltarr(2,nn)


for kk=0L,nn-1 do begin

x0 = mc_point(0,kk)
y0 = mc_point(1,kk)

L = 30
xr=L/2
yr=L/2

SUB = NEW_IMAGE2(X0:X0+L-1, Y0:Y0+L-1)

for i1 = x0-xr+1, x0+xr-1 do begin

for i2 = y0-yr+1, y0+yr-1 do begin

if(i1 le xr) or (i2 le yr) or (i1 ge size_of_image - L - xr) or (i2
ge size_of_image - L -yr) then begin



if i1 lt xr && i2 lt yr then begin

test = new_image2(xr:xr+L-1,yr:yr+L-1)

endif else if i1 lt xr && i2 gt yr && i2 lt (size_of_image - L -yr)
then begin

test = new_image2(xr:L+xr-1, i2:i2+L-1)

endif else if i1 gt xr && i1 le (size_of_image - L -xr) && i2 lt yr
then begin

test = new_image2(i1:i1+L-1, yr:yr+L-1)

endif else if i1 lt xr && i2 ge (size_of_image - L - yr) then begin

test = new_image2(xr:xr+L-1, (size_of_image -L-yr):(size_of_image-
yr-1))

endif else if i1 ge size_of_image -L -xr && i2 ge size_of_image -L -
yr then begin

test = new_image2(size_of_image -L -xr: size_of_image-xr-1,
size_of_image -L -yr:size_of_image-yr-1)

endif else if i1 ge size_of_image -L -xr && i2 le size_of_image - L -
yr && i2 gt yr then begin

test = new_image2(size_of_image -L -xr:size_of_image -xr-1,
i2:i2+L-1)

endif else if i1 le size_of_image -L -xr and i2 le size_of_image -L -
yr and i2 gt yr then begin

test = new_image2(i1:i1+L-1 , size_of_image - L -yr:size_of_image -
yr-1)

endif else if i1 ge (size_of_image - L - xr) && i2 lt yr then begin

test = new_image2((size_of_image -L-xr):(size_of_image-xr-1), yr:yr
+L-1)

endif

endif else begin

test = new_image2(i1:i1+L-1, i2:i2+L-1)


endelse

delta = (total(sub-test))^2


if delta LT deltamin then begin

deltamin = delta
fx0=i1 & fy0=i2

endif

endfor

endfor

tr_point(*,kk) = [fx0,fy0]

deltamin = 1e8

endfor

stop
end
Re: IDL out of range error [message #70157 is a reply to message #70154] Mon, 15 March 2010 18:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Suguru Amakubo writes:

> Hi, I have an error that has been bugging me for 3 weeks that I am
> hoping you could shed some light on.
>
> I am currently trying to create a subset of an image from a bigger
> image and comparing it to another subset of the same dimention.
>
> When I run the program however I recieve an error:
>
> Subscript range values of the form low:high must be >= 0, < size, with
> low <= high:

Three weeks!? And you haven't learned yet how to put a breakpoint
in your program and have a look around?

This kind of error is a user error 100% of the time.
I've never known it to be anything else in 25 years
of IDL programming. You are making an assumption about
your data that isn't true. When the program crashes,
have a look around. Look at the size of the images
you are subscripting, print out the values you are
using as subscripts. Don't assume anything, your assumptions
are wrong. This is an easy error to spot if you check
*everything*. There is no need to wait three more weeks
to solve this. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: IDL out of range error [message #70158 is a reply to message #70157] Mon, 15 March 2010 17:53 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Mar 15, 9:18 pm, Suguru Amakubo <sfa2...@googlemail.com> wrote:
> Subscript range values of the form low:high must be >= 0, < size, with
> low <= high:

That is an easy one. Just check on what line the error occurs (you
were not clear on which line caused the error). Then check what are
the dimensions of the arrays in that line, and compare them to the
values being used for the indexes.

> when I checked both sub and test has the same dimention L and they
> both position in the original image...

It is not really clear what you mean by this. From what you wrote, sub
and test can only be defined in that way if the dimensions of
new_image2 (I will call them new_image2_x and new_image2_y) are such
that:

new_image2_x is at least x0+L, and is at least the maximum i1+L
new_image2_y is at least y0+L, and is at least the maximum i2+L
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: SIGN function: signof(num or array of num)
Next Topic: Re: SIGN function: signof(num or array of num)

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

Current Time: Wed Oct 08 11:35:00 PDT 2025

Total time taken to generate the page: 0.00720 seconds