Re: More fun [message #22481] |
Mon, 20 November 2000 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Martin Schultz (martin.schultz@dkrz.de) writes:
> But I am sure there is a way to do this with histogram ;-)
I misplaced my copy of "101 Weekend Projects with the Histogram
Function" at the last IDL EPA meeting. Has anyone seen it. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: More fun [message #22483 is a reply to message #22481] |
Mon, 20 November 2000 00:00  |
Jaco van Gorkom
Messages: 97 Registered: November 2000
|
Member |
|
|
How about:
nv = n_elements(v)/interv
result = 0.5 * rebin(v+shift(v, -interv+1), nv, /sample)
cheers,
Jaco
"Martin Schultz" <martin.schultz@dkrz.de> wrote in message
news:3A1969E0.175876A8@dkrz.de...
> "J.D. Smith" wrote:
>>
>> 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[0]+v[4])/2, (v[5]+v[9])/2, (v[10]+v[14])/2, ...]
>>
>> Rebin by itself can't work, I don't think.
>>
>> Takers?
>>
>> JD
>>
>> P.S. No for loops please. Bonus points if you don't build an explicit
>> index list.
>>
>> --
>> J.D. Smith | WORK: (607) 255-6263
>> Cornell Dept. of Astronomy | (607) 255-5842
>> 304 Space Sciences Bldg. | FAX: (607) 255-5875
>> Ithaca, NY 14853 |
>
>
> Missing the bonus, I would suggest
> nv=N_Elements(v)/5
> res=0.5*( v[lindgen(nv)*5] + v[lindgen(nv)*5+4] )
>
> But I am sure there is a way to do this with histogram ;-)
>
> Cheers,
> Martin
>
> --
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
> [[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
> [[ Bundesstr. 55, 20146 Hamburg [[
> [[ phone: +49 40 41173-308 [[
> [[ fax: +49 40 41173-298 [[
> [[ martin.schultz@dkrz.de [[
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|
Re: More fun [message #22484 is a reply to message #22481] |
Mon, 20 November 2000 00:00  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
"J.D. Smith" <jdsmith@astro.cornell.edu> 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[0]+v[4])/2, (v[5]+v[9])/2, (v[10]+v[14])/2, ...]
> Rebin by itself can't work, I don't think.
> Takers?
> JD
> P.S. No for loops please. Bonus points if you don't build an explicit
> index list.
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.
William Thompson
|
|
|
Re: More fun [message #22486 is a reply to message #22481] |
Mon, 20 November 2000 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
"J.D. Smith" wrote:
>
> 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.
>
> Takers?
>
> JD
>
> P.S. No for loops please. Bonus points if you don't build an explicit
> index list.
>
> --
> J.D. Smith | WORK: (607) 255-6263
> Cornell Dept. of Astronomy | (607) 255-5842
> 304 Space Sciences Bldg. | FAX: (607) 255-5875
> Ithaca, NY 14853 |
Missing the bonus, I would suggest
nv=N_Elements(v)/5
res=0.5*( v[lindgen(nv)*5] + v[lindgen(nv)*5+4] )
But I am sure there is a way to do this with histogram ;-)
Cheers,
Martin
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|