rebinning data on new time samples without loops? [message #37289] |
Thu, 11 December 2003 15:43 |
jbattat
Messages: 8 Registered: November 2003
|
Junior Member |
|
|
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
|
|
|