Code covered by the BSD License  

Highlights from
ProcessNetwork Version 1.0 Software

image thumbnail

ProcessNetwork Version 1.0 Software

by

 

Functions for the delineation of Dynamical Process Networks using Information Theory

[anomalyMat]=removePeriodicMean(signalMat,period,sliderWidth,NoDataCode)
function [anomalyMat]=removePeriodicMean(signalMat,period,sliderWidth,NoDataCode)

%Removes the mean at every timestep from a periodic signal.  For example,
%For several years of daily data, feed in a signal with daily resolution
%and give the "period" parameter as 365.  This will give you the daily
%anomaly.  The slider width is applied to limit the mean to a certain
%number of periods after the data point - making each value the anomaly
%from the mean of the next "sliderWidth" values at the same position in
%subsequent periods.

%signalMat is an n-column matrix where n variables are represented as a
%timeseries- columns are variables, rows are timeseries records

%period is the length of the repeating pattern in the data- if using
%FluxNet data with 30 min resolution, the period is 48 or one day

%sliderWidth is the number of periods to base the anomaly on - for a five
%day moving anomaly, set sliderWidth to 5.

%NoDataCode is a data value that will be ignored. 

[nData,nSignals]=size(signalMat);
newLength=nData-period*sliderWidth-1;
anomalyMat=NaN(newLength,nSignals);
avg=NaN(nData,nSignals);
for i=1:newLength
    for s=1:nSignals

        START=i;
        INTERVAL=period;
        END=i+(sliderWidth*period)-1;

        [avg(i,s)]=getSkipMean(signalMat(START:INTERVAL:END,s),NoDataCode);

        if avg(i,s) == NoDataCode | signalMat(i,s) == NoDataCode
            anomalyMat(i,s)=NoDataCode;
        else
            anomalyMat(i,s)=signalMat(i,s)-avg(i,s);
        end
        
    end
end

Contact us