0001 function [waves,byisel] = wave_power_jd(dkeparam,wavefiles,byPnonabs)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if nargin < 2,
0013 error('Wrong number of input arguments in wave_distribution_yp.m.');
0014 end
0015
0016 if nargin < 3,
0017 byPnonabs = NaN;
0018 end
0019
0020 nw = length(wavefiles);
0021
0022 waves = cell(1,nw);
0023
0024 for iw = 1:nw,
0025 data = load(wavefiles{iw});
0026 waves{iw} = data.wave;
0027 end
0028
0029 if isfield(dkeparam,'enforcepower') && dkeparam.enforcepower,
0030
0031
0032
0033 ny = zeros(1,nw);
0034 yPtot_inj = cell(1,nw);
0035
0036 for iw = 1:nw,
0037
0038 wave = waves{iw};
0039
0040
0041
0042 if isfield(wave.rayinit.launch,'bPlhtot'),
0043 ny(iw) = length(wave.rayinit.launch.bPlhtot);
0044 yPtot_inj{iw} = wave.rayinit.launch.bPlhtot;
0045 elseif isfield(wave.rayinit.launch,'yP_L'),
0046 ny(iw) = length(wave.rayinit.launch.yP_L);
0047 yPtot_inj{iw} = wave.rayinit.launch.yP_L;
0048 end
0049 end
0050
0051
0052
0053 if ~iscell(byPnonabs),
0054 byPnonabs = cell(1,nw);
0055 for iw = 1:nw,
0056 byPnonabs{iw} = zeros(1,ny(iw));
0057 end
0058 end
0059
0060
0061
0062 if iscell(byPnonabs),
0063 for iw = 1:nw,
0064 waves{iw} = mod_wave_power_jd(waves{iw},yPtot_inj{iw} + byPnonabs{iw});
0065 end
0066 end
0067
0068
0069
0070 byisel = cell(1,nw);
0071 iray = 0;
0072 for iw = 1:nw,
0073 wave = waves{iw};
0074
0075 byisel{iw} = cell(1,ny);
0076
0077 for iy = 1:ny,
0078 byisel{iw}{iy} = [];
0079 end
0080
0081
0082
0083
0084 for ib = 1:length(wave.rays),
0085 iray = iray+1;
0086
0087 iy = wave.rays{ib}.rayinits{1}.yib;
0088
0089 byisel{iw}{iy} = [byisel{iw}{iy},iray];
0090 end
0091 end
0092 else
0093 byisel = NaN;
0094 end
0095