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

Home » Public Forums » archive » Re: subset a 2d array
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: subset a 2d array [message #61930 is a reply to message #61929] Thu, 14 August 2008 09:34 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
xiao writes:

> Sorry David, I still got problems here. I printed out all the values
> in the array and i found the center value which is -28.0011 but when I
> tried to do this :
>
> index=where(lat eq -28.0011,count)
> xy = array_indices(lat, index[0])
> subarray = lat[xy[0]-400:xy[0]+400, xy[1]-400:xy[1]+400]
>
>
> It cannot find the index number...Why is that? Thank you?
> PS :THIS ARRAY IS A FLOAT ARRAY.

Yeah, I thought I would let you solve one problem
at a time. :-)

The "problem" is that computers cannot represent numbers
"exactly". At least most numbers they can't. (They do
a reasonable job with integers. :-)

http://www.dfanning.com/math_tips/sky_is_falling.html
http://www.dfanning.com/math_tips/razoredge.html

Typically, if we are looking for floating values, we
have to add/subtract a small "delta" to the number
to be able to find it. How big should the delta be?
Big enough to allow you to find the number you are
looking, but not too big to add ambiguity to your
search. You could try something like this, for example"

delta = 1e-3
index = Where(array GE (2.5-delta) AND array LE (2.5+delta), count)

Or, if you are just looking for the center of the array, you
could always do this:

s = Size(array, /Dimensions)
xcenter = s[0]/2
ycenter = s[1]/2
targetValue = array[xcenter, ycenter]

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how to preserve trailing Shallow dimensions!
Next Topic: Need help with an Iterative solution in IDL (relative newb question)

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

Current Time: Tue Dec 02 18:02:51 PST 2025

Total time taken to generate the page: 0.73010 seconds