Re: Interpolation [message #90340 is a reply to message #90339] |
Sun, 22 February 2015 15:01   |
siumtesfai
Messages: 62 Registered: April 2013
|
Member |
|
|
On Sunday, February 22, 2015 at 5:00:57 PM UTC-5, David Fanning wrote:
> siumtesfai@gmail.com writes:
>
>> The location of my stations are random.
>
> Yes, these are the locations for which you are seeking fractional
> indices, right? Otherwise, your grid is regular in latitude and
> longitude.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
As you have suggested, I did the interpolation for station data
Do you think I have issue with Value_locate for latitude because my latitude ranges from -90 to 90 degree ?
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++
; Original model data at 192 X 96 degree spatial resolution
; Data = Array[lon,lat,pressure, time]
; data=Array[192, 96, 17, 1872]
; Extract one pressure level (e.g 850hPa) and interpolate to 2.5 X 2.5 degree spatial resolution
; Interpolated one pressure level data (WS)
WS=fltarr(144,73,n_elements(time))
; Now Interpolate again to a station data
slon = findgen(144)*2.5
slat = findgen(73)*2.5-90
; Station location example, at longitude 190 and latitude 37
; Find longitude fractional index.
slonval = 190
slonstep = slon[1] - slon[0]
closeIndex = Value_Locate(slon, slonval)
slonFracIndex = closeIndex + ((slonval - slon[closeIndex]) / slonstep)
; Find latitude fractional index.
slatval = 37
slatstep = slat[1] - slat[0]
closeIndex = Value_Locate(slat, slatval)
slatFracIndex = closeIndex + ((slatval - slat[closeIndex]) / slatstep)
interpValue=fltarr(ntime)+1E20
FOR i =0,n_elements(time)-1 do begin
griddedArray=reform(WS(*,*,i))
interpValue(i) = Interpolate(griddedArray, slonFracIndex, slatFracIndex)
ENDFOR
end
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++
|
|
|