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

Home » Public Forums » archive » Re: rebinning data on new time samples without loops?
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: rebinning data on new time samples without loops? [message #37288 is a reply to message #37285] Fri, 12 December 2003 01:18 Go to previous messageGo to previous message
Chris Lee is currently offline  Chris Lee
Messages: 101
Registered: August 2003
Senior Member
In article <d916d48a.0312111543.8425684@posting.google.com>, "James"
<jbattat@cfa.harvard.edu> wrote:


> Hi there,
> I have a time series of data, y, sampled on an irregular grid, t1. I
> would like to rebin y onto an existing time series (also irregular), t2.
> Right now, I am using a for loop and a where statement to get it done,
> but it is rather slow, and I'm guessing that there's a way to do it
> without a for loop (probably even using Histogram...). The t1 series is
> ~100,000 points and the t2 series is ~3,000 points. On my system, my
> code takes 10-15 mins to run. I'd like to make a faster solution.
> There are basically only 2 requirements. 1. If t1[i] is more than some
> user defined dTMax away from any t2 sample then omit the data point
> 2. I'd like to know how many t1 points went into each t2 bin. Right now
> i do it like this (roughly):
> t1 = original time samples
> y1 = data gridded on t1
> t2 = desired time sampling
> y2 = data gridded on t2
>
> code to ensure overlap between t2 and t1 code to eliminate all points
> that are not part of the overlap
>
> for loop over t1
> dT = t2 - replicate(t1[i],nt2)
> ID = where(dT EQ min(dT))
> dump y1[i] data into y2[ID] if min(dT) < dTMax increment counter[ID]
> endfor loop
>
> then divide y2/counter to get the rebinned value.
> I'm sure there's a better way. I'm curious if there's an efficient way
> in which no loops are used.
> Thanks very much in advance,
> James

Hi,

On your code, do you need the replicate line,
[1,2,3,4] - 3 = [-2,-1,0,1]
[1,2,3,4] - [3,3,3,3] = [-2,-1,0,1]

anyway..

What's wrong with INTERPOLATE or INTERPOL?

y2=interpol(y1, t1, t2)

TRIANGULATE if the data is two dimensional.

If you really want to use your method, I would suggest making a two
dimensional grid from y1 (t1, t2), and using some matrix tricks on it.
Possibly based on the "Vector Comparison" thread a while back

http://groups.google.com/groups?hl=en&lr=&ie=ISO-885 9-1&q=
vector+comparison+idl&btnG=Google+Search

should be one line obviously.

Chris.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Permanently changing shell
Next Topic: Re: Subscripting multidimensional arrays

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

Current Time: Sun Nov 30 15:13:28 PST 2025

Total time taken to generate the page: 0.64152 seconds