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

Home » Public Forums » archive » Interpolation
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Interpolation [message #84944] Wed, 19 June 2013 08:01 Go to next message
bongzno1 is currently offline  bongzno1
Messages: 1
Registered: June 2013
Junior Member
Hi all,
I have a problem here. I have a 4 column data:hr min sec velocity
The sampling rate of the data is 3 sec. I need to interpolate it where the velocity is zero. The data is over a 10 hr period. Any suggestions please, I'm new in programming.
The program looks like this

Read,datalines
Fitacf=DBLARR(4,datalines)
Hr=0.000
Min=0.000
Sec=0.000
Vel=0.000
OPENR,1,’filename’
For i=0, (datalines-1) do begin
Readf,1,hr,min,sec,b12
Readf,1,vel
Fitacf(0,i)=hr
Fitacf(1,i)=min
Fitacf(2,i)=sec
Fitacf(3,i)=vel
Endfor
Close,1

My progam is working but not interpolating.
Thank you in advance for your time.

Bongz
Re: Interpolation [message #84946 is a reply to message #84944] Wed, 19 June 2013 09:41 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Wednesday, June 19, 2013 11:01:51 AM UTC-4, bong...@gmail.com wrote:
> Hi all,
>
> I have a problem here. I have a 4 column data:hr min sec velocity
>
> The sampling rate of the data is 3 sec. I need to interpolate it where the velocity is zero. The data is over a 10 hr period. Any suggestions please, I'm new in programming.
>
> The program looks like this
...
>
> My progam is working but not interpolating.

Well, there's no instructions in the code to do any interpolation, so that's not a big surprise.

Your first problem is that your time is in hours minutes and seconds. Usually you need a smoothly varying single time variable for interpolation. The expression,
T = (HR*60 + MIN)*60 + SEC
the new variable T is the number of seconds since the start of the day or your your experiment.

I would check for missing velocity values by using
WHMISSING = WHERE(VEL EQ 0, NMISSING)

The complement of that is all the good velocity values,
WHGOOD = WHERE(VEL NE 0, NGOOD)

To actually do interpolation you need to decide what kind of interpolation algorithm you want. Just for brevity's sake you can use INTERPOL()
VEL[WHMISSING] = INTERPOL( VEL[WHGOOD], T[WHGOOD], T[WHBAD] )

This says: given a grid of good points T[WHGOOD], VEL[WHGOOD], please provide interpolants at the times of my bad points T[WHBAD].

There are lots of other interpolation routines to check out. Also I'm skipping some of the error checking you should normally do. (for example, what happens if there are no bad points? no good points?)

Craig
Re: Interpolation [message #84947 is a reply to message #84944] Wed, 19 June 2013 11:14 Go to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
Just building on what Craig said. You write: "... interpolate it where the velocity is zero...." Does that mean you're looking for the time where the velocity goes to zero? If so, then there's a few ways to skin this cat.

You will need to do what Craig said about the time.
You might need to do what Craig said about good/bad data.
But then you will want to use interpol, but turn it around. Something like:

t0 = interpol(t,velocity,0.0)

would interpolate the times at the point where velocity equals zero. Now the catch is many-folded...

(1) do you have multiple zeros in the v(t) function?
(2) is the data noisy (if so, then then you could have an issue of noise-spikes spoofing multiple zeros).
(3) there might be better ways at this (for example, this would tell you a crude estimate of the time. but you could "refine" that estimate by then fitting some smooth polynomial to the velocities around this time and then invert that polynomial. I'd wager that the points around the v(t)=0 point are somewhat parabolic, so maybe a 2nd order would be fine --- and it's easy to invert. But, w/o seeing the data there's no way to know).
(4) there are several optional inputs to interpol (lsquadratic, quadratic, spline), you'll have to guess which is right for you.

-Russell



On Wednesday, June 19, 2013 11:01:51 AM UTC-4, bong...@gmail.com wrote:
> Hi all,
>
> I have a problem here. I have a 4 column data:hr min sec velocity
>
> The sampling rate of the data is 3 sec. I need to interpolate it where the velocity is zero. The data is over a 10 hr period. Any suggestions please, I'm new in programming.
>
> The program looks like this
>
>
>
> Read,datalines
>
> Fitacf=DBLARR(4,datalines)
>
> Hr=0.000
>
> Min=0.000
>
> Sec=0.000
>
> Vel=0.000
>
> OPENR,1,’filename’
>
> For i=0, (datalines-1) do begin
>
> Readf,1,hr,min,sec,b12
>
> Readf,1,vel
>
> Fitacf(0,i)=hr
>
> Fitacf(1,i)=min
>
> Fitacf(2,i)=sec
>
> Fitacf(3,i)=vel
>
> Endfor
>
> Close,1
>
>
>
> My progam is working but not interpolating.
>
> Thank you in advance for your time.
>
>
>
> Bongz
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: how to calculate mcnemar statistics based on confusion matrix
Next Topic: Using subroutines

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

Current Time: Wed Oct 08 13:33:50 PDT 2025

Total time taken to generate the page: 0.00466 seconds