Home > wafo > wavemodels > thgparfun.m

thgparfun

PURPOSE ^

Wave height, Hd, distribution parameters for Torsethaugen spectra.

SYNOPSIS ^

[A0,B0,C0]= thgparfun(Hm0,Tp,dim)

DESCRIPTION ^

 THGPARFUN Wave height, Hd, distribution parameters for Torsethaugen spectra. 
  
  CALL [a b c] = thgparfun(Hm0,Tp,dim) 
  
  Hm0 = significant wave height [m]. 
  Tp  = peak period [s] 
  dim = 'time'  : Hd distribution parameters in time (default) 
        'space' : Hd distribution parameters in space 
  
   THGPARFUN returns the Generalized gamma distribution parameters which 
   approximates the marginal PDF of Hd/Hrms, i.e., 
   zero-downcrossing wave height, for a Gaussian process with a  
   Torsethaugen spectral density (torsethaugen).   
  
   The empirical parameters of the model is fitted by 
   least squares to simulated Hd data for 600 classes of Hm0 and Tp. 
   Between 50000 and 150000 zero-downcrossing waves were simulated for 
   each class of Hm0 and Tp for DIM=='time'. 
   Between 100000 and 1000000 zero-downcrossing waves were 
   simulated for each class of Hm0 and Tp for DIM=='space'. 
   THGPARFUN is restricted to the following range for Hm0 and Tp:  
   0.5 < Hm0 [m] < 12,  3.5 < Tp [s] < 20,  and  Hm0 < (Tp-2)*12/11. 
   
   Example: 
   Hm0 = 6;Tp = 8;Hrms = Hm0/sqrt(2); 
   [a b c] = thgparfun(Hm0,Tp); 
   h = linspace(0,4*Hrms)';  
   F = wggamcdf(h/Hrms,a,b,c); 
   f = wggampdf(h/Hrms,a,b,c)/Hrms; 
   dt = 0.4; w = linspace(0,2*pi/dt,256)'; 
   S = torsethaugen(w,[Hm0 Tp]); 
   xs = spec2sdat(S,20000,dt); rate=8; method=1; 
   [S,H] = dat2steep(xs,rate,method); 
   subplot(2,1,1) 
   empdistr(H,[h,F],1) 
   fk = kdebin(H,'epan',[],[],.5,128); 
   subplot(2,1,2) 
   plot(h,f), hold on, pdfplot(fk,'r'), hold off 
   
   See also  thpdf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [A0,B0,C0]= thgparfun(Hm0,Tp,dim) 
002 %THGPARFUN Wave height, Hd, distribution parameters for Torsethaugen spectra. 
003 % 
004 % CALL [a b c] = thgparfun(Hm0,Tp,dim) 
005 % 
006 % Hm0 = significant wave height [m]. 
007 % Tp  = peak period [s] 
008 % dim = 'time'  : Hd distribution parameters in time (default) 
009 %       'space' : Hd distribution parameters in space 
010 % 
011 %  THGPARFUN returns the Generalized gamma distribution parameters which 
012 %  approximates the marginal PDF of Hd/Hrms, i.e., 
013 %  zero-downcrossing wave height, for a Gaussian process with a  
014 %  Torsethaugen spectral density (torsethaugen).   
015 % 
016 %  The empirical parameters of the model is fitted by 
017 %  least squares to simulated Hd data for 600 classes of Hm0 and Tp. 
018 %  Between 50000 and 150000 zero-downcrossing waves were simulated for 
019 %  each class of Hm0 and Tp for DIM=='time'. 
020 %  Between 100000 and 1000000 zero-downcrossing waves were 
021 %  simulated for each class of Hm0 and Tp for DIM=='space'. 
022 %  THGPARFUN is restricted to the following range for Hm0 and Tp:  
023 %  0.5 < Hm0 [m] < 12,  3.5 < Tp [s] < 20,  and  Hm0 < (Tp-2)*12/11. 
024 %  
025 %  Example: 
026 %  Hm0 = 6;Tp = 8;Hrms = Hm0/sqrt(2); 
027 %  [a b c] = thgparfun(Hm0,Tp); 
028 %  h = linspace(0,4*Hrms)';  
029 %  F = wggamcdf(h/Hrms,a,b,c); 
030 %  f = wggampdf(h/Hrms,a,b,c)/Hrms; 
031 %  dt = 0.4; w = linspace(0,2*pi/dt,256)'; 
032 %  S = torsethaugen(w,[Hm0 Tp]); 
033 %  xs = spec2sdat(S,20000,dt); rate=8; method=1; 
034 %  [S,H] = dat2steep(xs,rate,method); 
035 %  subplot(2,1,1) 
036 %  empdistr(H,[h,F],1) 
037 %  fk = kdebin(H,'epan',[],[],.5,128); 
038 %  subplot(2,1,2) 
039 %  plot(h,f), hold on, pdfplot(fk,'r'), hold off 
040 %  
041 %  See also  thpdf  
042  
043  
044 % History: 
045 % by pab 29.11.2002 
046  
047 error(nargchk(2,3,nargin)) 
048 if nargin<3|isempty(dim), dim = 'time';end 
049  
050 if  Hm0<=0.5 | 12<Hm0 
051   disp('Warning: Hm0 is outside the valid range') 
052   disp('The validity of the parameters returned are questionable') 
053 end 
054 if Tp<3.5 | 20<Tp 
055   disp('Warning: Tp is outside the valid range') 
056   disp('The validity of the parameters returned are questionable') 
057 end 
058  
059 if Hm0 > (Tp-2)*12/11 
060   disp('Warning: Hm0 is too large compared to Tp!') 
061   disp('The validity of the parameters returned are questionable') 
062 end 
063  
064 pardef = 1; 
065 switch pardef 
066   case 1, 
067     if strncmpi(dim,'t',1), % Waveheight distribution in time 
068       disp('Note: truncated weibull distribution gives better fit') 
069       disp('than this, see thwparfun for details!') 
070        
071       global THGPAR 
072       if isempty(THGPAR) 
073     THGPAR = load('thgpar.mat'); 
074       end 
075       % Generalized Gamma  distribution parameters as a function of Tp, Hm0  
076       A00 = THGPAR.A00s; 
077       B00 = THGPAR.B00s; 
078       C00 = THGPAR.C00s; 
079  
080       Tpp  = THGPAR.Tp; 
081       Hm00 = THGPAR.Hm0; 
082     else,% Waveheight distribution in space 
083       global THSSPAR 
084       if isempty(THSSPAR) 
085     THSSPAR = load('thsspar.mat'); 
086       end 
087       % Generalized Gamma  distribution parameters as a function of Tp, Hm0  
088       A00 = THSSPAR.A00s; 
089       B00 = THSSPAR.B00s; 
090       C00 = THSSPAR.C00s; 
091  
092       Tpp  = THSSPAR.Tp; 
093       Hm00 = THSSPAR.Hm0;      
094     end 
095     [E1, H1] = meshgrid(Tpp,Hm00); 
096     method = '*cubic'; 
097     A0 = interp2(E1,H1,A00,Tp,Hm0,method); 
098     B0 = interp2(E1,H1,B00,Tp,Hm0,method); 
099     C0 = interp2(E1,H1,C00,Tp,Hm0,method); 
100 end 
101

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003