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

Home » Public Forums » archive » Re: X/Y convert to lat/lon
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: X/Y convert to lat/lon [message #75648 is a reply to message #75647] Tue, 15 March 2011 00:33 Go to previous message
Fabzou is currently offline  Fabzou
Messages: 76
Registered: November 2010
Member
On 03/15/2011 05:53 AM, teddyallen wrote:
> longitude = findgen(144)*2.5 ;creates a 144 element array with values
> evenly spaced between 0 -> 357.5
> latitude = ((findgen(73)*2.5)-90.)*(-1.) ;creates a 73 element array
> with values evenly spaced between -90 -> +90
> xlon = 342 ;this is the longitude value I would like to subset the
> array with
> xlat = 35; this is the latitude value I would like to subset the array
> with
> lon1= where(longitude eq xlon) ; provides the longitude index
> dimension for array
> lat1=where(latitude eq xlat)
> test = array[lon1,lat1] ; results in the subset of the arry given
> xlon and xlat
>
> The xlon value should be associated with the nearest 2.5 multiple,
> which in this case would be xlon=342.5.....obviously not -1.
> Any suggestions?
> Thank you

Well, where() is really not supposed to do so. It looks for exact
matches... where(longitude eq 342.5) MAY work, but only if the sky is
not falling (http://www.idlcoyote.com/math_tips/sky_is_falling.html).

One method would be:
IDL> longitude = findgen(144)*2.5
IDL> m = min(abs(longitude - 342), p)
IDL> print, longitude[p]
342.500

But this is not always exact and there are plenty of better methods,
especially when you are located on the "sphere"
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: journal files
Next Topic: color and tvellipse

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

Current Time: Wed Oct 08 19:59:09 PDT 2025

Total time taken to generate the page: 0.00449 seconds