forked from colligant/gravity-wave-gui-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an averaging routine after Murphy et al 2014
- Loading branch information
Thomas Henry Colligan IV
committed
May 21, 2019
1 parent
4ff2c56
commit 979874e
Showing
4 changed files
with
52 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function [averagedArray, averagedAlt] = averageToAltitudeResolution(array, altitude, resolution) | ||
%UNTITLED Summary of this function goes here | ||
% Averages a time series of data to a given altitude resolution. Steps: | ||
% walk through the altitude array, keeping a running sum of the values in | ||
% "array" at the same indices. When altBegin - altEnd > resolution, | ||
% divide the sum by the number of indices between altBegin and altEnd, | ||
% and store it in a new array - averagedArray. | ||
|
||
averagedArray = zeros('like', array); | ||
averagedAlt = zeros('like', altitude); | ||
altBegin = altitude(1); | ||
altEnd = altitude(1); | ||
k = 0; | ||
s = 0; | ||
nPoints = 0; | ||
for i=1:size(altitude, 1) | ||
altEnd = altitude(i); | ||
s = s + array(i); | ||
nPoints = nPoints + 1; | ||
if (altEnd - altBegin) >= resolution | ||
k = k + 1; | ||
averagedArray(k) = s / nPoints; | ||
averagedAlt(k) = altBegin + (altEnd - altBegin) / 2; | ||
s = 0; | ||
altBegin = altEnd; | ||
nPoints = 0; | ||
end | ||
end | ||
averagedArray = averagedArray(1:k); | ||
averagedAlt = averagedAlt(1:k); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.