[Thread Prev][Thread Next][Index]
Re: [ferret_users] Two interpolation syntax questions
Hi Steve,
Your second attempt is much more the preferred way to do this kind of
thing in Ferret. It uses the grid mindset of Ferret to work with the
variable as a whole and apply Ferret transformations or other operations
to do what you want. Either the @WEQ or @EVNT transform will locate your
point, and the variable you define
let test = lat*time[x=@weq:1030]
let nlat = test[x=1:48@sum]
should be the latitude at the time point that you've specified, computed
by linear interpolation. When you define a variable
myvar = time[x=@weq:1030]
the @WEQ result returns the weights for the points on either side of the
specified value. It finds where the variable "time" crosses the
specified value and and gives the corresponding weights. There are no
other places where the variable crosses the value 1030, so the field is
missing everywhere else. Doing a calculation based on the value of your
variable "test" will give you the latitude just where time crosses 1030,
which is what you want. If you want to ignore the weights and do
something else, you could for example define a new variable
let mytimes = 1 + 0*time[x=@weq:1030]
and the value would be 1 on each side of where TIME crosses 1030 and
missing elsewhere.
Or, the output of time[x=@EVNT:1030] is 0 until the variable crosses the
specified value, then 1 until it crosses it again, (and would take on
the value 2 if it crossed again).
(For the general question about IF statements, the thing to understand
is that the expression inside the IF needs to be a scalar or string,
that evaluates to a simple TRUE or 1, or FALSE or 0. There is not an
AND clause but something like this could be done with nested IF's. It is
cumbersome, which is a good reason to use Ferret expressions like the
ones above instead.
repeat/i=1:48 (let di = day[i=`i`]; let ti = time[i=`i`]; if `20 eq
di` then if `0325 gt ti` then if `0325 lt ti` then ...)
Steve Guimond wrote:
Dear Ferreters:
I have two separate, but related questions. I have latitudes,
longitudes and times for the
positions of several tropical cyclones and need to co-locate with some
satellite data.
Basically, just need to do a simple interpolation to find the position of
the storm at satellite
overpass. So, the positions of the storm are at 20.50,53.50 at 0000Z and
21.34,52.10 at
0600Z and the satellite overpass is at 0325Z.
Data looks like:
day i=1:48
time i=1:48
lat i=1:48
lon i=1:48
I wanted to find the appropriate "i" position in the array that 0325Z
was between and then
apply my own interpolation calculations, but found this difficult. In
fortran I would code:
do i=1,48
if ( 0325 .gt. time(i) .and. 0325 .lt. time(i+1) ) then
complete interpolation
endif
enddo
I tried this in ferret by saying:
repeat/range=1:48:1/name=a (if 20 eq day[i=`a`] and 0325 gt time[i=`a`]
and 0325 lt
time[i=`a`+1] then complete interpolation)
I tried various sequences, but could not get the equivalent of my fortran
code in ferret to
work.
Additionally, I tried using the @weq transformation as:
let test = lat*time[x=@weq:1030] !trying a different time here
let nlat = test[x=1:48@sum]
This worked for the first time in the array between 0000Z and 0600Z, but
did not produce a
field of coefficients for the rest of the times that I needed. This is
what I got from listing test
and time together...
time test
1/1: 600. 3.173
2/2:1200. 8.027
3/3:1800. ....
4/4: 0. ....
5/5: 600. ....
6/6:1200. ....
etc.......
why are there not coefficients for the rest of the times at 1030?
Can anyone help to clear up (1) how to cycle through data element by
element like fortran
for the statement above and (2) how to get coefficients for all the times
and not just the first
instance of 1030 like I showed above?
Many thanks...
Steve Guimond
*****************************************
Stephen R. Guimond
Graduate Research Assistant
Center for Ocean-Atmospheric Prediction Studies
*****************************************
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement