Home > wafo > papers > wafodemo > wafoinit.m

wafoinit

PURPOSE ^

setup all global variables of the WAFODEMO

SYNOPSIS ^

wafoinit

DESCRIPTION ^

 WAFOINIT  setup all global variables of the WAFODEMO

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function wafoinit
002 %WAFOINIT  setup all global variables of the WAFODEMO
003 
004 % Since the calculations are in a very small extent dependent on eachother,
005 % most of the calculations are located in the wafofigXX.m files.
006 % Some minor calculations and all the initializations of variables are
007 % are done here.
008 
009 % GLOBAL WAFOFIGNUM 
010 %
011 % wafoXXXX functions only recalculates the values of empty 
012 % variables ==> saves alot of computation time
013 
014 % TODO % needs to complete the fatigue , cycles and Markov models figures
015 
016 %revised pab april2004  
017 % fixed a bug: options to spec2sdat changed.  
018 %revised pab Feb2004
019 % By pab 28.01.2000
020 
021 % Figure parameter:
022 %~~~~~~~~~~~~~~~~~~
023 global WAFOFIGNUM  
024 if isempty(WAFOFIGNUM)
025   disp('You must start wafodemo in order to run this script')
026   clear global WAFOFIGNUM
027   return
028 end
029 
030 global pwdstr  wafomenulabels Jxn Nxr 
031 
032 if isempty(pwdstr)
033   pwdstr=pwd; % save path to where the demo was started
034 end
035 Nfigs=10;
036 if isempty(wafomenulabels) % automatic generation of menu labels
037   cd(fullfile(waforoot,'papers','wafodemo'));  
038   wafomenulabels=cell(Nfigs,1);
039   for ix=1:Nfigs
040     wafomenulabels{ix} = geth1line(['wafofig' num2str(ix)],1);   
041   end
042   cd(pwdstr)
043 end
044 
045 if isempty(Nxr) % load if not already loaded 
046   Nxr=load('gfaksr89.dat');
047   %xn=xn(1:10000,:); % used for debugging 
048 end
049 
050 if isempty(Jxn) % load if not already loaded 
051   jfile='yura87.dat';
052   Jxn=load(jfile);
053   if strcmp(jfile,'yura87.dat'), %Selecting only a part of the data
054     Jxn=Jxn(5000:55000,[1 3]);
055     Jxn(:,2)=detrendma(Jxn(:,2),1500); % remove the trend
056  %   Jxn=Jxn(5000:55000,:);
057   end
058   %xn=xn(1:10000,:); % used for debugging 
059 end
060 
061 
062 
063 if 0 % this is not in paper but could be included
064   if isempty(Jmap)
065     disp('Loading map over the Japan Sea...')
066     Jmap = load('japansea.dat');
067   end
068   if isempty(Nmap)
069     disp('Loading map over the North Sea...')
070     Nmap = load('northsea.dat');
071   end
072 end
073 
074 
075 % Define Globals used (that the user also  might change)
076 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
077 global Fs                          % sampling frequency for torsethaugen
078 global St Hm0 Tp                   % torsethaugen output, input Fig 2
079 global xt Nsim Iseed               % spec2sdat output , input    Fig1
080 global Ste L                       % dat2spec output, input      Fig2
081 global fTt fTte u Np nit speed     % spec2thpdf output, input    Fig3  
082 global Tt rate                     % dat2wa output, input        Fig3
083 global ma mb sp                    % spreading input             Fig4
084 
085 global fTcfAc NNp Nh Nnit Nspeed   % spec2thpdf output, input    Fig5  
086 global NVcf NHd Nrate              % dat2steep output, input     Fig5
087 
088 global fTcfAcTc JNp Jh Jnit Jspeed % spec2thpdf output, input    Fig6  
089 global JTcf JAc Jind Jrate         % dat2steep output, input     Fig6
090 
091 global kdeTt kernel hs L2          % kdebin input: kernel, smoothing  (Fig3)
092 global kdeVcfHd Nkernel Nhs NL2    % and transformation  parameter,   (Fig5)
093 global kdeTcfAcTc Jkernel Jhs JL2  % respectively                     (Fig6)
094 
095 % Set torsethaugen default values: 
096 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
097 if isempty(Hm0),     Hm0 = 6;                end
098 if isempty(Tp),       Tp = 8;                end
099 if isempty(Fs),       Fs = 0.95238095238095; end % sampling frequency
100 w = linspace(0,pi*Fs,257).';
101 % fig4
102 if isempty(sp),       sp = 15;               end
103 if isempty(ma),       ma = 5;                end
104 if isempty(mb),       mb = -2.5;             end
105 
106 
107 % Set spec2sdat and dat2spec default values: 
108 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109 if isempty(Nsim),   Nsim = 1000;             end % 
110 if isempty(Iseed), Iseed = 1000;             end % seed for simulation
111 if isempty(L),         L = 80;               end
112 
113 % Set dat2wa and dat2steep default values: 
114 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115 if isempty(rate),   rate = 8;end %fig3
116 if isempty(Nrate), Nrate = 8;end %fig5
117 if isempty(Jrate), Jrate = 8;end %fig6
118 
119 % Set spec2thpdf default values: 
120 %~~~~~~~~~~~~~~~~~~~~~~~~~~~
121 %Fig3
122 if isempty(u),           u = 0;   end
123 if isempty(Np),         Np = 33;  end
124 if isempty(nit),       nit = 4;   end
125 if isempty(speed),   speed = 5;   end
126 % fig5
127 if isempty(NNp),        NNp = 33;  end
128 if isempty(Nnit),     Nnit = -1;  end
129 if isempty(Nspeed), Nspeed = 7;   end
130 if isempty(Nh),         Nh = linspace(0,8,31);;end
131 % fig6
132 if isempty(JNp),        JNp = 33;  end
133 if isempty(Jnit),     Jnit = 4;   end
134 if isempty(Jspeed), Jspeed = 5;   end
135 if isempty(Jh),         Jh = linspace(0,6,31);end
136 
137 
138 % Set kdebin default values: 
139 %~~~~~~~~~~~~~~~~~~~~~~~~~~~
140 %Fig3
141 if isempty(kernel),     kernel = 'epan';  end
142 if isempty(L2),             L2 = .5;      end
143 %Fig5
144 if isempty(Nkernel),   Nkernel = 'epan';  end
145 if isempty(NL2),           NL2 = [.5 .5]; end
146 %Fig6
147 if isempty(Jkernel),   Jkernel = 'epan';  end
148 if isempty(JL2),           JL2 = [1 .5];  end % used
149 % if hs, Nhs Jhs is empty then kdebin uses the 
150 % default values calculated  from the data (this is default)
151 
152 
153 
154 % Initialization:
155 %~~~~~~~~~~~~~~~~
156 
157 if isempty(St),
158   St=torsethaugen(w,[Hm0 ,Tp]);
159 end
160 if isempty(xt)
161   xt=spec2sdat(St,[Nsim,1],[],Iseed);
162 end
163 if isempty(Ste)
164   Ste=dat2spec(xt,L,[],[],0.95);  % estimated Spectrum
165 end
166 
167 
168 
169 
170 
171 
172

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