build_spectrum_from_aloha

PURPOSE ^

SYNOPSIS ^

function launch = build_spectrum_from_aloha(external,basestr,signs,opt_gui,select)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function launch = build_spectrum_from_aloha(external,basestr,signs,opt_gui,select)
0002 %
0003 if nargin < 5,
0004     select = struct;
0005     %
0006     if ~isfield(select,'style'),
0007         select.style = struct;
0008     end
0009 end
0010 %
0011 if nargin < 4,
0012     opt_gui = true;
0013 end
0014 %
0015 spectrum = struct;
0016 %
0017 if ~isfield(select,'style'),
0018     select.style = struct;
0019 end
0020 %
0021 if isfield(external.antenna,'id'),
0022     spectrum.id = external.antenna.id;
0023 end
0024 %
0025 if iscell(external.antenna.aloha.results.dP_nz)
0026     spectrum.dP_nz = real(external.antenna.aloha.results.dP_nz{1});
0027     %
0028     if length(external.antenna.aloha.results.dP_nz) > 1
0029     for ii=2:length(external.antenna.aloha.results.dP_nz)
0030         spectrum.dP_nz = spectrum.dP_nz + real(external.antenna.aloha.results.dP_nz{ii});
0031     end
0032 end
0033 else
0034     spectrum.dP_nz = real(external.antenna.aloha.results.dP_nz);
0035 end
0036 %
0037 spectrum.nz = external.antenna.aloha.results.nz;
0038 spectrum.ny = external.antenna.aloha.results.ny;
0039 %
0040 disp('********************************************************************************************')
0041 disp('WARNING: check that the ALOHA power spectrum generates a co-current or a counter current. ')
0042 disp('Co-current:      Npar0(main peak) < 0 if sign(Ip)*sign(Bt) > 0');
0043 disp('Counter-current: Npar0(main peak) > 0 if sign(Ip)*sign(Bt) < 0');
0044 disp(['Ip sign: ',num2str(signs.ip),', Bt0 sign: ',num2str(signs.b0),' (see LUKE signe conventions in documentation)']);
0045 disp('********************************************************************************************')
0046 %
0047 if signs.ip*signs.b0 > 0
0048     if spectrum.nz(find(spectrum.dP_nz==max(spectrum.dP_nz))) < 0
0049         opt_spectrum = input_dke_yp('Main lobe of the power spectrum generates co-current.  Would you like to change the power spectrum for generating counter-current (yes:1,no:0)',0,[0,1]) == 1;
0050     else 
0051         opt_spectrum = input_dke_yp('Main lobe of the power spectrum generates counter-current.  Would you like to change the power spectrum for generating co-current (yes:1,no:0)',0,[0,1]) == 1;
0052     end
0053 else
0054     if spectrum.nz(find(spectrum.dP_nz==max(spectrum.dP_nz))) > 0
0055         opt_spectrum = input_dke_yp('Main lobe of the power spectrum generates co-current. Would you like to change the power spectrum for generating counter-current (yes:1,no:0)',0,[0,1]) == 1;
0056     else 
0057         opt_spectrum = input_dke_yp('Main lobe of the power spectrum generates counter-current. Would you like to change the power spectrum for generating co-current (yes:1,no:0)',0,[0,1]) == 1;
0058         
0059     end
0060 end
0061 %
0062 if opt_spectrum == 1, 
0063     spectrum.dP_nz = fliplr(spectrum.dP_nz);%for co- or counter- current generation depending upon reltive signs of ip and bt0
0064 end
0065 %
0066 while 1,
0067     opt_module = iselect_jd({'full antenna','upper module','lower module'},'This ALOHA spectrum corresponds to :',opt_gui,select.style,1);
0068     %
0069     if opt_module > 1,
0070         pfac = 1/2;
0071         pstr = ' (half antenna)';
0072     else
0073         pfac = 1;
0074         pstr = '';
0075     end                
0076     %
0077     val(1) = sum(spectrum.dP_nz*external.antenna.aloha.results.dnz);
0078     s{1} = ['Power from ALOHA spectrum',pstr,'        : PLH = ',num2str(val(1)/1e6),' MW'];
0079     %
0080     s{end+1} = 'Specify power manually';
0081     %
0082     locstyle = select.style;
0083     locstyle.textwidth = 600;
0084     %
0085     opt_Plhtot = iselect_jd(s,['LH power associated with this spectrum',pstr,' :'],opt_gui,locstyle,length(s)-1);
0086     %
0087     if opt_Plhtot < length(s),
0088         spectrum.Plhtot = val(opt_Plhtot);
0089     else
0090         spectrum.Plhtot = 1e6*iselect_jd({},['Specify LH power',pstr,' (MW) :'],opt_gui,select.style,val(1)/1e6);
0091     end
0092     %
0093     data = struct;
0094     data.spectrum = spectrum;
0095     select.mode = 2;%display fitted ALOHA spectra
0096     %
0097     launch = imake_launch_LH_jd(basestr,signs,data,opt_gui,select);
0098     %
0099     if opt_module == 2,
0100         launch.rZ0 = launch.rZ0(launch.rZ0 >= 0);
0101     elseif opt_module == 3,
0102         launch.rZ0 = launch.rZ0(launch.rZ0 <= 0);
0103     end 
0104     %
0105     disp('------------------------------------------------');
0106     for ib = 1:length(launch.bNpar0),
0107         disp(['Npar0 = ',num2str(launch.bNpar0(ib)),' - Power = ',num2str(launch.bPlhtot(ib)/1e6),' (MW)']);
0108     end
0109     disp(' ');disp('------------------------------------------------');
0110     disp(['Total LH power in the launched spectrum (',int2str(length(launch.bNpar0)),' rays) : ',num2str(sum(launch.bPlhtot)/1e6),' (MW)']);
0111     disp('------------------------------------------------');disp(' ');
0112     %
0113     opt_OK = iselect_jd({'Yes','No'},'Confirm the LH power spectrum deduced from ALOHA:',opt_gui,select.style,1);
0114     %
0115     if opt_OK == 1,
0116         break
0117     else
0118         clear('s');
0119     end                       
0120 end
0121 %
0122 launch.antenna = external.antenna;
0123 launch.id = [launch.id,'_',make_aloha_simulid_yp(external.antenna.aloha)];
0124 launch.bNpar0 = imag(launch.bNpar0);
0125 %

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.