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 #75647 is a reply to message #75637] Tue, 15 March 2011 02:36 Go to previous messageGo to previous message
teddyallen is currently offline  teddyallen
Messages: 5
Registered: September 2010
Junior Member
On Mar 15, 3:33 am, Fabzou <fabien.mauss...@tu-berlin.de> wrote:
> 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"- Hide quoted text -
>
> - Show quoted text -

Dear Fabzou,
THANK YOU so much! I knew the resolution would rest in a few short
lines. I can now add these lines to my growing tank of IDL knowledge.
Let me know if you are ever in Miami and lunch is one me!
cheers,
teddy
[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:56:09 PDT 2025

Total time taken to generate the page: 0.00481 seconds