forked from T-Carlotto/MRCPtool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLyneHollickM.m
More file actions
77 lines (58 loc) · 2.62 KB
/
Copy pathLyneHollickM.m
File metadata and controls
77 lines (58 loc) · 2.62 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% *************************************************************************
% Lyne-Hollick's numeric filter
% *************************************************************************
% Authors: Tomas Carlotto and Pedro Luiz Borges Chaffe
% Developer: Tomas Carlotto
% Contact address: thomas.carl@hotmail.com
% *************************************************************************
% This code or any part of it may be used as long as the authors are cited.
% Under no circumstances will authors or copyright holders be liable for any claims,
% damages or other liability arising from the use any part of related code.
% *************************************************************************
% INPUTS:
% data: Matrix of n rows 2 columns, where: column 1 are the flows and
% column 2 are the precipitations (optional, the current version does not use);
% beta: parameter (exp(-dt/K))
% (hObject, eventdata, handles): connection functions for the interface;
%
% OUTPUTS:
% LHCalMat: Baseflow;
function [LHCalMat] = LyneHollickM(dados,beta,hObject, eventdata, handles)
%% =======================================================================
%Selection of entries
%Precipt = dados(:,2);
Q = dados(:,1);
%% =======================================
%% 3-point moving average
%% =======================================
med_on=0;
if med_on==1
n = 5; % Number of 3-point moving average applications
Qtot = Q';
Qajust = (Qtot(1:length(Qtot)) + [Qtot(1) Qtot(1:length(Qtot)-1)] + [Qtot(2:length(Qtot)) Qtot(length(Qtot))])/3;
% ========================================
for i =1:n
Qtot = Qajust;
Qajust = (Qtot(1:length(Qtot)) + [Qtot(1) Qtot(1:length(Qtot)-1)] + [Qtot(2:length(Qtot)) Qtot(length(Qtot))])/3;
end
Q = Qajust';
end
%==========================================
DIM = length(Q);
Beta = beta;
%Beta = 0.925;
LHCalMat = zeros(DIM,1);
LHCalMat(1,1) = Q(1);%((Beta*Q(1))+(((1+Beta)./2)*(Q(2)-Q(1))));
for ii=2:DIM
if isnan(Q(ii))
LHCalMat(ii,1) = NaN;
else
LHCal1 = ((Beta*LHCalMat(ii-1,1))+(((1-Beta)./2)*(Q(ii)+Q(ii-1))));
if LHCal1 <= Q(ii)
LHCalMat(ii,1) = LHCal1;%((Beta*LHCalMat(ii-1,1))+(((1-Beta)./2)*(Q(ii)+Q(ii-1))));
else
LHCalMat(ii,1) = Q(ii);
end
end
end
end