iluke_update_wavestruct

PURPOSE ^

script iluke_update_wavestruct

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 script iluke_update_wavestruct

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % script iluke_update_wavestruct
0002 %
0003 
0004 %
0005 % clear outdated wavestructs and update list, status
0006 %
0007 
0008 wavestructss(status.wavestructs <= 0) = {[]};
0009 
0010 iwclearmask = ~any(status.wavestructs == 1,2);
0011 wavestructids(iwclearmask,:) = [];
0012 wavestructss(iwclearmask,:) = [];
0013 status.wavestructs(iwclearmask,:) = [];
0014 %
0015 clear iwclearmask
0016 %
0017 % flag_external &  external_wave
0018 %
0019 if isfield(external,'wave'),% include data from external structure if available
0020     if curtime == 0,% treat all times from external structure if available
0021         flag_external = any(intersect(shotimes(status.equil == 1),external.times));
0022     elseif curtime > 0,% select one time from external structure if available
0023         flag_external = any(external.times == shotimes(curtime));
0024     else
0025         flag_external = false;
0026     end
0027 else
0028     flag_external = false;
0029 end 
0030 %
0031 if flag_external,
0032     lukeobj.wavestruct.import.state = 'on';
0033 else
0034     lukeobj.wavestruct.import.state = 'off';
0035 end
0036 %
0037 % display and state properties
0038 %
0039 if isempty(wavestructids) || (curtime > 0 && all(status.wavestructs(:,curtime) <= 0)),% no wavestructs
0040     %
0041     lukeobj.wavestruct.select.visible = 'off';
0042     lukeobj.wavestruct.save.state = 'off';
0043     lukeobj.wavestruct.clear.state = 'off';
0044     lukeobj.spectrum.modify.state = 'off';
0045     lukeobj.spectrum.save.state = 'off';
0046     lukeobj.spectrum.reset.state = 'off';
0047     lukeobj.angles.modify.state = 'off';
0048     lukeobj.angles.save.state = 'off';
0049     lukeobj.angles.reset.state = 'off';
0050     lukeobj.launch.modify.state = 'off';
0051     lukeobj.launch.save.state = 'off';
0052     lukeobj.launch.reset.state = 'off';
0053     lukeobj.c3poparam.modify.state = 'off';
0054     lukeobj.c3poparam.load.state = 'off';
0055     lukeobj.c3poparam.save.state = 'off';
0056     lukeobj.c3poparam.reset.state = 'off';
0057     lukeobj.runc3po.state = 'off';
0058     lukeobj.runc3poall.state = 'off';    
0059     lukeobj.runc3pooptim.state = 'off';    
0060     lukeobj.wsparamtitle.state = 'off';
0061     lukeobj.wsparam.state = 'off';
0062     %
0063     lukeobj.spectrum.text.string = '';
0064     lukeobj.angles.text.string = '';
0065     lukeobj.launch.text.string = '';
0066     lukeobj.c3poparam.text.string = '';
0067     %
0068     if flag_external,
0069         lukeobj.wavestruct.import.highlight = true;
0070         lukeobj.wavestruct.make.highlight = false;
0071     else
0072         lukeobj.wavestruct.make.highlight = true;
0073         lukeobj.wavestruct.import.highlight = false;
0074     end
0075     lukeobj.runc3po.highlight = false;
0076     lukeobj.runc3poall.highlight = false;    
0077     lukeobj.runc3pooptim.highlight = false;    
0078 else
0079     %
0080     % build lukeobj.wavestruct.select.string
0081     %
0082     if lukeobj.wavestruct.select.value > 0,
0083         wavestructid = lukeobj.wavestruct.select.string{lukeobj.wavestruct.select.value};
0084     else
0085         wavestructid = '';
0086     end
0087     %
0088     if curtime > 0,
0089         iw_curtime = find(status.wavestructs(:,curtime) == 1);
0090     else
0091         iw_curtime = 1:length(wavestructids);
0092     end
0093     %
0094     lukeobj.wavestruct.select.string = wavestructids(iw_curtime);
0095     lukeobj.wavestruct.select.value = find(strcmp(lukeobj.wavestruct.select.string,wavestructid));
0096     %
0097     if isempty(lukeobj.wavestruct.select.value),% pre-selected wavestruct does not exist for curtime, or was cleared for all times
0098         lukeobj.wavestruct.select.value = length(lukeobj.wavestruct.select.string);
0099     end
0100     %
0101     iw = iw_curtime(lukeobj.wavestruct.select.value);% current index in wavestructss
0102     %
0103     % wavestruct
0104     %
0105     lukeobj.wavestruct.save.state = 'on';
0106     lukeobj.wavestruct.clear.state = 'on';
0107     %
0108     % c3po run
0109     %
0110     lukeobj.runc3po.state = 'on';
0111     lukeobj.runc3poall.state = 'on';    
0112     %
0113     if strcmp(lukeobj.wavestruct.visible,'on'),
0114         lukeobj.wavestruct.select.visible = 'on';
0115     end
0116     %
0117     lukeobj.wavestruct.import.highlight = false;
0118     lukeobj.wavestruct.make.highlight = false;
0119     lukeobj.runc3po.highlight = true;
0120     lukeobj.runc3poall.highlight = true;    
0121     %
0122     if curtime > 0,
0123         %
0124         wavestruct = wavestructss{iw,curtime};
0125         %
0126         % launch
0127         %
0128         lukeobj.launch.modify.state = 'on';
0129         lukeobj.launch.save.state = 'on';
0130         %
0131         if isfield(wavestruct.launch,'orig'),
0132             lukeobj.launch.reset.state = 'on';
0133         else
0134             lukeobj.launch.reset.state = 'off';
0135         end
0136         %
0137         lukeobj.launch.text.string = [  'ID : ',num2str(wavestruct.launch.id),...
0138             ' ; type : ',num2str(wavestruct.launch.type)];
0139         %
0140         % c3poparam
0141         %
0142         lukeobj.c3poparam.modify.state = 'on';
0143         lukeobj.c3poparam.load.state = 'on';
0144         lukeobj.c3poparam.save.state = 'on';
0145         %
0146         if isfield(wavestruct,'rtparam'),
0147             lukeobj.c3poparam.text.string = wavestruct.rtparam;
0148         end
0149         %
0150         if isfield(wavestruct,'orig'),
0151             lukeobj.c3poparam.reset.state = 'on';
0152         else
0153             lukeobj.c3poparam.reset.state = 'off';
0154         end
0155         %
0156         % c3po dist computing
0157         %
0158         lukeobj.wsparamtitle.state = 'on';
0159         lukeobj.wsparam.state = 'on';
0160         %
0161         if strcmp(wavestruct.launch.type,'LH'),
0162             if isfield(wavestruct.launch,'spectrum'),
0163                 lukeobj.spectrum.modify.state = 'on';
0164                 lukeobj.spectrum.save.state = 'on';
0165                 %
0166                 if isfield(wavestruct.launch.spectrum,'orig'),
0167                     lukeobj.spectrum.reset.state = 'on';
0168                 else
0169                     lukeobj.spectrum.reset.state = 'off';
0170                 end
0171                 %
0172     %             lukeobj.spectrum.text.string = ['ne0_17 = ',num2str(wavestruct.launch.spectrum.plasma.ne0/1e17,3),'',...
0173     %                 ' ; l1 = ',num2str(wavestruct.launch.spectrum.plasma.lambda_n(1)/1e3,3),' mm',...
0174     %                 ' ; l2 = ',num2str(wavestruct.launch.spectrum.plasma.lambda_n(2)/1e3,3),' mm'];
0175                 lukeobj.spectrum.text.string = ['ID : ',wavestruct.launch.spectrum.id,... 
0176                     ' ; #lobes = ',num2str(wavestruct.launch.spectrum.param_tor.nlobes,3),'',...
0177                     ' ; dir = ',num2str(wavestruct.launch.spectrum.param_tor.dir,3),'',...
0178                     ' ; mode = ',num2str(wavestruct.launch.spectrum.param_tor.mode,3),''];
0179                 %
0180             else
0181                 lukeobj.spectrum.modify.state = 'off';
0182                 lukeobj.spectrum.save.state = 'off';
0183                 lukeobj.spectrum.reset.state = 'off';
0184                 lukeobj.spectrum.text.string = '';
0185             end
0186             %
0187             lukeobj.angles.text.string = '';
0188             lukeobj.runc3pooptim.state = 'off';
0189             %
0190             if any(imag(wavestruct.launch.bNpar0) ~= 0),            
0191                 nparstr = 'Nz0';
0192                 npar0disp = imag(wavestruct.launch.bNpar0(find(wavestruct.launch.bPlhtot == max(wavestruct.launch.bPlhtot),1,'first')));
0193             else
0194                 nparstr = 'N//0';
0195                 npar0disp = wavestruct.launch.bNpar0(find(wavestruct.launch.bPlhtot == max(wavestruct.launch.bPlhtot),1,'first'));
0196             end
0197             lukeobj.launch.text.string = [lukeobj.launch.text.string,...
0198                 ' ; ',nparstr,' : ',num2str(npar0disp,3),'',...
0199                 ' ; P = ',num2str(sum(wavestruct.launch.bPlhtot)/1e6,3),' MW'];
0200             %
0201             clear npar0disp
0202             %
0203         elseif strcmp(wavestruct.launch.type,'EC'),
0204             if isfield(wavestruct.launch,'angles'),
0205                 lukeobj.angles.modify.state = 'on';
0206                 lukeobj.angles.save.state = 'on';
0207                 if isfield(wavestruct.launch.angles,'orig'),
0208                     lukeobj.angles.reset.state = 'on';
0209                 else
0210                     lukeobj.angles.reset.state = 'off';
0211                 end
0212                 %
0213                 lukeobj.angles.text.string = [  'ID : ',num2str(wavestruct.launch.angles.id),...
0214                     ' ; P = ',num2str(wavestruct.launch.angles.P0/1e3,3),' kW',...
0215                     ' ; f = ',num2str(wavestruct.launch.angles.freq/1e9,3),' GHz'];
0216                 %
0217             else
0218                 lukeobj.angles.modify.state = 'off';
0219                 lukeobj.angles.save.state = 'off';
0220                 lukeobj.angles.reset.state = 'off';
0221                 lukeobj.angles.text.string = '';
0222             end
0223             %
0224             lukeobj.runc3pooptim.state = 'on';
0225             %
0226             lukeobj.spectrum.text.string = '';
0227             lukeobj.launch.text.string = [lukeobj.launch.text.string,...
0228                 ' ; alpha = ',num2str(wavestruct.launch.yalpha_L*180/pi,3),' °',...
0229                 ' ; beta = ',num2str(wavestruct.launch.ybeta_L*180/pi,3),' °'];
0230             %
0231         end
0232         %
0233         lukeobj.runc3pooptim.highlight = true;    
0234         %
0235         clear wavestruct
0236     else
0237         %
0238         lukeobj.runc3pooptim.state = 'off'; 
0239         lukeobj.runc3pooptim.highlight = false;
0240         %
0241         % launch
0242         %
0243         lukeobj.launch.modify.state = 'off';
0244         lukeobj.launch.save.state = 'on';
0245         lukeobj.launch.reset.state = 'off';
0246         lukeobj.launch.text.string = '< time specific >';
0247         %
0248         % spectrum
0249         %
0250         lukeobj.spectrum.modify.state = 'off';
0251         lukeobj.spectrum.save.state = 'off';
0252         lukeobj.spectrum.reset.state = 'off';
0253         lukeobj.spectrum.text.string = '';
0254         %
0255         % angles
0256         %
0257         lukeobj.angles.modify.state = 'off';
0258         lukeobj.angles.save.state = 'off';
0259         lukeobj.angles.reset.state = 'off';
0260         lukeobj.angles.text.string = '';
0261         %
0262         % c3poparam
0263         %
0264         itlist = find(status.wavestructs(iw,:) == 1);% list of times
0265         rtparam = selectfields_jd(wavestructss{iw,itlist(1)},{'rtparam','rayparam','waveparam','fitparam','C3POparam','C3POdisplay'});
0266         %
0267         comptest = true;
0268         %
0269         for it = 2:length(itlist),
0270             rtparam_comp = selectfields_jd(wavestructss{iw,itlist(it)},{'rtparam','rayparam','waveparam','fitparam','C3POparam','C3POdisplay'});
0271             comptest = comptest && comp_struct_jd(rtparam,rtparam_comp,0);
0272         end
0273         %
0274         if comptest,
0275             lukeobj.c3poparam.modify.state = 'on';
0276             lukeobj.c3poparam.load.state = 'on';
0277             lukeobj.c3poparam.save.state = 'on';
0278             lukeobj.c3poparam.text.string = rtparam.rtparam;
0279             %
0280             if isfield(wavestructss{iw,itlist(1)},'orig'),
0281                 lukeobj.c3poparam.reset.state = 'on';
0282             else
0283                 lukeobj.c3poparam.reset.state = 'off';
0284             end
0285         else
0286             lukeobj.c3poparam.modify.state = 'off';
0287             lukeobj.c3poparam.load.state = 'off';
0288             lukeobj.c3poparam.save.state = 'off';
0289             lukeobj.c3poparam.reset.state = 'off';
0290             lukeobj.c3poparam.text.string = '< time specific >';
0291         end
0292         %
0293         clear itlist iwlist rtparam rtparam_comp comptest
0294     end
0295     %
0296     clear iw_curtime wavestructid
0297     %
0298 end
0299 %
0300 clear flag_external wavestructs iw nw 
0301 %
0302 % upgrade graph status
0303 %
0304 % plotindices = [lukeobj.plot1.gindex,lukeobj.plot2.gindex,lukeobj.plot3.gindex];
0305 % %
0306 % nstr = length('spectrum for ');
0307 % %
0308 % ngraphs = length(graphs);
0309 % for igraph = ngraphs:-1:1,
0310 %     if strcmp(graphs(igraph).tag,'spectrum') && ~any(strcmp(graphs(igraph).info(nstr+1:end),lukeobj.wavestruct.select.string)),% the corresponding wavestruct no longer exists
0311 %         for ich = 1:length(graphs(igraph).handles),
0312 %             delete(graphs(igraph).handles(ich))
0313 %         end
0314 %         graphs(igraph) = [];
0315 %         plotindices(plotindices == igraph) = 0;
0316 %         plotindices(plotindices > igraph) = plotindices(plotindices > igraph) - 1;
0317 %     end
0318 % end
0319 % %
0320 % lukeobj.plot1.gindex = plotindices(1);
0321 % lukeobj.plot2.gindex = plotindices(2);
0322 % lukeobj.plot3.gindex = plotindices(3);
0323 %
0324 clear nstr igraph ngraphs plotindices
0325 
0326 
0327 
0328 
0329 
0330 
0331 
0332 
0333 
0334 
0335

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