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

Home » Public Forums » archive » Averaging values in an array
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
Averaging values in an array [message #91501] Tue, 21 July 2015 09:50 Go to next message
wdolan is currently offline  wdolan
Messages: 29
Registered: June 2015
Junior Member
So I've got an array called 'topscans' which is [333,9], so I am looking through 9 different scans, and each scan has 333 spectral points. I want to average each spectral point for the 9 scans. For example I want to average the first spectral point for all 9 runs, then the 2nd, then the third etc. So that in the end I have a set of 333 spectral points which represents an average of all 9 scans.

Thanks for your help!
Re: Averaging values in an array [message #91502 is a reply to message #91501] Tue, 21 July 2015 09:56 Go to previous messageGo to next message
a146397258 is currently offline  a146397258
Messages: 7
Registered: July 2015
Junior Member
Something like:

result=fltarr(333)
for i=0,332 do begin
result[i]=(array[i,0]+array[i,1]+...+array[i,8])/8
endfor

Maybe? I might have messed up something with zero indexing, but something that follows that general idea should work.
Re: Averaging values in an array [message #91503 is a reply to message #91501] Tue, 21 July 2015 09:58 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
It sounds like you want

IDL> topscans_avg = mean(topscans,dimension=2)

On Tuesday, July 21, 2015 at 12:50:10 PM UTC-4, Wayana Dolan wrote:
> So I've got an array called 'topscans' which is [333,9], so I am looking through 9 different scans, and each scan has 333 spectral points. I want to average each spectral point for the 9 scans. For example I want to average the first spectral point for all 9 runs, then the 2nd, then the third etc. So that in the end I have a set of 333 spectral points which represents an average of all 9 scans.
>
> Thanks for your help!
Re: Averaging values in an array [message #91505 is a reply to message #91503] Wed, 22 July 2015 08:10 Go to previous message
wdolan is currently offline  wdolan
Messages: 29
Registered: June 2015
Junior Member
Great, thank you, it worked!

On Tuesday, July 21, 2015 at 9:58:48 AM UTC-7, wlandsman wrote:
> It sounds like you want
>
> IDL> topscans_avg = mean(topscans,dimension=2)
>
> On Tuesday, July 21, 2015 at 12:50:10 PM UTC-4, Wayana Dolan wrote:
>> So I've got an array called 'topscans' which is [333,9], so I am looking through 9 different scans, and each scan has 333 spectral points. I want to average each spectral point for the 9 scans. For example I want to average the first spectral point for all 9 runs, then the 2nd, then the third etc. So that in the end I have a set of 333 spectral points which represents an average of all 9 scans.
>>
>> Thanks for your help!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: map projection
Next Topic: Array is empty after for loop

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

Current Time: Wed Oct 08 09:17:51 PDT 2025

Total time taken to generate the page: 0.00381 seconds