[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More fun
"J.D. Smith" <firstname.lastname@example.org> writes:
>Here's one I just came up against. Suppose you want to rebin a vector
>to some smaller size, an integer factor smaller. E.g. 100 elements to
>20 elements. Now, rather than the average of those elements in each
>interval, etc., you want merely the average of the first and last member
>of that interval. E.g., you want:
>[(v+v)/2, (v+v)/2, (v+v)/2, ...]
>Rebin by itself can't work, I don't think.
>P.S. No for loops please. Bonus points if you don't build an explicit
If the number of elements in the array is evenly divisible by the rebin factor
(such as 100 is evenly divisible by 5), then the following should work
TEMP = REFORM(ARRAY, M, N_ELEMENTS(ARRAY)/M)
RESULT = REFORM(TEMP(0,*) + TEMP(M-1,*)) / 2.