001 function [f,Hrms,Vrms,fA,fB] = ohhspdf(Hd,Scf,Hm0,def,normalizedInput, ...
002 condon)
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047 error(nargchk(3,6,nargin))
048 if (nargin < 6|isempty(condon)), condon = 0;end
049 if (nargin < 5|isempty(normalizedInput)), normalizedInput = 0;end
050 if (nargin < 4|isempty(def)), def=1;end
051
052 multipleSeaStates = any(prod(size(Hm0))>1);
053 if multipleSeaStates
054 [errorcode, Scf,Hd,Hm0] = comnsize(Scf,Hd,Hm0);
055 else
056 [errorcode, Scf,Hd] = comnsize(Scf,Hd);
057 end
058 if errorcode > 0
059 error('Requires non-scalar arguments to match in size.');
060 end
061
062 if any(Hm0>12| Hm0<=0.5)
063 disp('Warning: Hm0 is outside the valid range')
064 disp('The validity of the Hd distribution is questionable')
065 end
066
067 if def>11|def<1
068 Warning('DEF is outside the valid range')
069 def = mod(def-1,11)+1;
070 end
071
072 global OHHSPAR
073 if isempty(OHHSPAR)
074 OHHSPAR = load('ohhspar.mat');
075 end
076
077
078
079
080
081
082 Hm00 = OHHSPAR.Hm0;
083
084 if normalizedInput,
085 Hrms = 1;
086 Vrms = 1;
087 else
088 method = 'cubic';
089 Tm020 = OHHSPAR.Tm02;
090 Hrms = Hm0/sqrt(2);
091 Tm02 = interp1(Hm00,Tm020(:,def),Hm0,method);
092 Vrms = 1.25*Hm0./(Tm02.^2);
093 end
094
095
096 h = Hd./Hrms;
097 v = Scf./Vrms;
098 cSize = size(h);
099
100
101 A11 = squeeze(OHHSPAR.A11s(:,def,:));
102 B11 = squeeze(OHHSPAR.B11s(:,def,:));
103
104 h2 = OHHSPAR.h2;
105 [E2 H2] = meshgrid(Hm00,h2);
106 method = '*cubic';
107 if multipleSeaStates
108 h = h(:);
109 v = v(:);
110 Hm0 = Hm0(:);
111 A1 = zeros(length(h),1);
112 B1 = A1;
113 [Hm0u,ix,jx] = unique(Hm0);
114 numSeaStates = length(ix);
115 Nh2 = length(h2);
116 Hm0i = zeros(Nh2,1);
117 for iz=1:numSeaStates
118 k = find(jx==iz);
119 Hm0i(:) = Hm0u(iz);
120 A1(k) = exp(smooth(h2,interp2(E2,H2,A11.',Hm0i,h2,method),...
121 1,h(k),1));
122 B1(k) = (smooth(h2,interp2(E2,H2,exp(B11).',Hm0i,h2,method),...
123 1,h(k),1));
124 end
125 else
126 Hm0i = Hm0(ones(size(h2)));
127 A1 = exp(smooth(h2,interp2(E2,H2,A11.', ...
128 Hm0i,h2,method),1,h,1));
129 B1 = (smooth(h2,interp2(E2,H2,exp(B11).', ...
130 Hm0i,h2,method),1,h,1));
131 end
132
133
134
135
136 [A0 B0 C0] = ohhgparfun(Hm0,def,'time');
137
138
139 switch condon,
140 case 0,
141 f = wggampdf(h,A0,B0,C0).*wweibpdf(v,A1,B1);
142 case 1,
143 f = wweibpdf(v,A1,B1);
144 case 3,
145 f = v.*wweibpdf(v,A1,B1);
146 case 4,
147 f = v.^2.*wweibpdf(v,A1,B1);
148 case 5,
149 f = wggampdf(h,A0,B0,C0).*wweibcdf(v,A1,B1);
150 case 6,
151 f = wweibcdf(v,A1,B1);
152 case 7,
153 f = wggampdf(h,A0,B0,C0).*(1-wweibcdf(v,A1,B1));
154 otherwise error('unknown option')
155 end
156 if multipleSeaStates
157 f = reshape(f,cSize);
158 end
159
160 if condon~=6
161 f = f./Hrms./Vrms;
162 end
163 f(find(isnan(f)|isinf(f) ))=0;
164 if any(size(f)~=cSize)
165 disp('Wrong size')
166 end
167 if nargout>3,
168 fA = createpdf(2);
169 fA.f = A11;
170 fA.x = {Hm00, h2};
171 fA.labx = {'Hm0', 'h'};
172 fA.note = sprintf('%s \n',...
173 'The conditonal Weibull distribution Parameter',...
174 'A(h)/Hrms for wave heigth as a function of',...
175 'h=Hd/Hrms and Hm0 for the ohspec2 spectrum, ',...
176 sprintf('given def = %d.',def));
177
178 ra = range(A11(:));
179 st = round(min(A11(:))*100)/100;
180 en = max(A11(:));
181 fA.cl = st:ra/20:en;
182 end
183 if nargout>4,
184 fB = createpdf(2);
185 fB.f = B11;
186 fB.x = {Hm00,h2};
187 fB.labx = {'Hm0','h'};
188 fB.note = sprintf('%s \n',...
189 'The conditonal Weibull distribution Parameter',...
190 'B(h)/Hrms for wave heigth as a function of',...
191 'h=Hd/Hrms and Hm0 for the ohspec2 spectrum, ',...
192 sprintf('given def = %d.',def));
193 ra = range(B11(:));
194 st = round(min(B11(:))*100)/100;
195 en = max(B11(:));
196 fB.cl = st:ra/20:en;
197 end
198 return
199
200
201
202
203
204
205
206 return
207 Fh = wggampdf(h(:)/Hrms,A0,B0,C0);
208
209
210
211
212
213
214 [V1 A1] = meshgrid(v/Vrms,A1);
215 [V1 B1] = meshgrid(v/Vrms,B1);
216
217
218 f = createpdf(2);
219 f.title = 'Joint distribution of (Hd,Scf) in time';
220 if norm==0
221 f.f = repmat(Fh/Hrms,[1 length(v)]).*wweibpdf(V1,A1,B1)/Vrms;
222 f.x = {v,h};
223 f.norm=0;
224 f.labx={'Scf', 'Hd [m]'};
225 else
226 f.f = repmat(Fh,[1 length(v)]).*wweibpdf(V1,A1,B1);
227 f.x = {v/Vrms,h/Hrms};
228 f.labx={'Scf', 'Hd'};
229 f.norm = 1;
230 end
231 f.note = ['Ochi-Hubble Hm0=' num2str(Hm0) ' def = ' num2str(def)];
232 if 1,
233 f.f(isinf(f.f)|isnan(f.f))=0;
234
235
236 [f.cl,f.pl] = qlevels(f.f);
237 end
238