forked from ProcessNetwork/ProcessNetwork_Software
-
Notifications
You must be signed in to change notification settings - Fork 2
/
preProcess.m
36 lines (29 loc) · 945 Bytes
/
preProcess.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [Data] = preProcess(opts,Data)
% Run the preprocessing options, currently includes data trimming and
% transformation
%
% ----------- Inputs -----------
% opts...
%
% ---------- Outputs -----------
% rawData = the preprocessed data
%
% ------------------------------
% Turn NoDataCode into NaN
Data(Data == opts.NoDataCode) = NaN;
% Trim rows where there is missing data
if opts.trimTheData
Data(sum(isnan(Data),2) > 0,:) = NaN;
end
% Apply transformation
if opts.transformation == 1
% Apply anomaly filter
Data = removePeriodicMean(Data,opts.anomalyPeriodInData,opts.anomalyMovingAveragePeriodNumber,NaN);
elseif opts.transformation == 2
% Apply wavelet transform
if sum(isnan(Data(:))) == 0
Data = waveletTransform(Data,opts.waveN,opts.waveName,opts.waveDorS,opts.parallelWorkers);
else
logwrite('Warning: Wavelet transform not applied. Gap-free data required.',1);
end
end