X/Y convert to lat/lon [message #75649] |
Mon, 14 March 2011 21:53 |
teddyallen
Messages: 5 Registered: September 2010
|
Junior Member |
|
|
I am reluctant to post this since it seems like a very easy task, but
unfortunately, I cannot manage to figure it out on my own nor with any
online search help. ( I am away from home and my trusty IDL books are
not on pdf....bummer!)
Problem: I have a standard 144,73 NCEP/NCAR Reanalysis array at 2.5
degree grid spacing. All I want to be able to do is to subset data
from the array given LATITUDE and LONGITUDE dimensions and NOT x and y
values.
How do I get from subsetting an array from array[x,y] to
array[lon,lat]. It is much easier for me to subset various geographic
locations knowing the general lat/lon dimensions rather than stopping
to consider where in the world x=136 and y=28 are. It is easier to
just consider where lon = 340 and lat = 20 (the same location as
x=136,y=28). . I can manage the above, but the real trouble arises
when the lat and lon are not evenly spaced in 2.5 degree increments.
I need to be able to subset an array based on lat and lon values that
do not fall within multiple of 2.5. My lines below show what happens
when the above occurs....I get a value of -1 for my longitude array
subset value.
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
|
|
|