iluke_update

PURPOSE ^

script iluke_update

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

script iluke_update

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %script iluke_update
0002 
0003 %
0004 % UPDATE STATUS
0005 %
0006 
0007 [external,lukeobj.data,cleartags] = iluke_status(external,status.external,lukeobj.data,0,1,cleartags);
0008 
0009 %
0010 % manage the data structures based on status.equil, which refers to each shotime
0011 %
0012 % at this point it is necessary that shotimes, status.equil, and equils all have the same dimension.
0013 %
0014 %   - status.equil(it) = -1 : equil & shotime to be removed
0015 %   - status.equil(it) = 0 : equil to be cleared & shotime kept (external not empty)
0016 %   - status.equil(it) = 1 : equil exists & shotime maintained
0017 %   - status.equil(it) = 2 : new shot time & empty equils
0018 %   - status.equil(it) = 3 : new shot time & full equils
0019 %
0020 if length(status.equil) ~= length(equils),
0021     error('Inconsistency between status.equil & equils')
0022 end
0023 if length(status.equil) ~= length(shotimes),
0024     error('Inconsistency between status.equil & shotimes')
0025 end
0026 %
0027 flag_remove = status.equil == -1;
0028 %
0029 % remove outdated times
0030 %
0031 shotimes(:,flag_remove) = [];
0032 
0033 dkeparams(:,flag_remove) = [];
0034 equils(:,flag_remove) = [];
0035 ohms(:,flag_remove) = [];
0036 transpfastes(:,flag_remove) = [];
0037 ripples(:,flag_remove) = [];
0038 wavess(:,flag_remove) = [];
0039 fluctparams(:,flag_remove) = [];
0040 %
0041 wavestructss(:,flag_remove) = [];
0042 %
0043 jobs(:,flag_remove) = [];
0044 outputs(:,flag_remove) = [];
0045 sdiags(:,flag_remove) = [];
0046 
0047 status.equil(:,flag_remove) = [];
0048 status.ohm(:,flag_remove) = [];
0049 % status.transpfaste(:,flag_remove) = [];
0050 status.ripple(:,flag_remove) = [];
0051 status.waves(:,flag_remove) = [];
0052 status.fluct(:,flag_remove) = [];
0053 status.wavestructs(:,flag_remove) = [];
0054 status.job(:,flag_remove) = [];
0055 status.output(:,flag_remove) = [];
0056 status.sdiag(:,flag_remove) = [];
0057 
0058 % delete outdated graphs
0059 flag_remove_g = find(flag_remove) + 2;% +2 for <new>,<all>
0060 for it = 1:length(flag_remove_g),
0061     %
0062     ngraphs = length(graphss{flag_remove_g(it)});
0063     for igraph = ngraphs:-1:1,% sum over graphs
0064         delete(graphss{flag_remove_g(it)}(igraph).handles);% clear all graph components
0065     end
0066     %
0067 end
0068 graphss(:,flag_remove_g) = [];
0069 cleartags(:,flag_remove_g) = [];
0070 lukeobj.plot1.gindex(:,flag_remove_g) = [];
0071 lukeobj.plot2.gindex(:,flag_remove_g) = [];
0072 lukeobj.plot3.gindex(:,flag_remove_g) = [];
0073 
0074 flag_clear = status.equil == 0;
0075 flag_newempty = status.equil == 2;
0076 flag_newfull = status.equil == 3;
0077 
0078 flag_new = flag_newempty | flag_newfull;% new equils
0079 %
0080 if any(diff(flag_new) < 0),
0081     error('New equils must be added at the end')
0082 end
0083 
0084 %
0085 % add new times
0086 %
0087 nnew = sum(flag_new);%number of new times
0088 
0089 dkeparams(:,end+1:end+nnew) = {[]};
0090 ohms(:,end+1:end+nnew) = {[]};
0091 transpfastes(:,end+1:end+nnew) = {[]};
0092 ripples(:,end+1:end+nnew) = {[]};
0093 wavess(:,end+1:end+nnew) = {{}};
0094 fluctparams(:,end+1:end+nnew) = {[]};
0095 %
0096 wavestructss(:,end+1:end+nnew) = cell(length(wavestructids),nnew);
0097 %
0098 jobs(:,end+1:end+nnew) = {[]};
0099 outputs(:,end+1:end+nnew) = {[]};
0100 sdiags(:,end+1:end+nnew) = {[]};
0101 
0102 status.ohm(:,end+1:end+nnew) = 0;
0103 % status.transpfaste(:,end+1:end+nnew) = 0;
0104 status.ripple(:,end+1:end+nnew) = 0;
0105 status.waves(:,end+1:end+nnew) = 0;
0106 status.fluct(:,end+1:end+nnew) = 0;
0107 status.wavestructs(:,end+1:end+nnew) = zeros(length(wavestructids),nnew);
0108 status.job(:,end+1:end+nnew) = 0;
0109 status.output(:,end+1:end+nnew) = 0;
0110 status.sdiag(:,end+1:end+nnew) = 0;
0111 
0112 graphss(:,end+1:end+nnew) = graphss(1);% fill with empty structures with memory of fields
0113 cleartags(:,end+1:end+nnew) = {{}};
0114 lukeobj.plot1.gindex(:,end+1:end+nnew) = 0;
0115 lukeobj.plot2.gindex(:,end+1:end+nnew) = 0;
0116 lukeobj.plot3.gindex(:,end+1:end+nnew) = 0;
0117 
0118 %
0119 % structures to be cleared
0120 %
0121 % dkeparams(:,flag_clear) = {[]};
0122 equils(:,flag_clear) = {[]};
0123 ohms(:,flag_clear) = {[]};
0124 % transpfastes(:,flag_clear) = {[]};
0125 ripples(:,flag_clear) = {[]};
0126 wavess(:,flag_clear) = {{}};
0127 fluctparams(:,flag_clear) = {[]};
0128 %
0129 wavestructss(:,flag_clear) = {{}};
0130 %
0131 jobs(:,flag_clear) = {[]};
0132 outputs(:,flag_clear) = {[]};
0133 sdiags(:,flag_clear) = {[]};
0134 
0135 flag_clear_g = find(flag_clear) + 2;% +2 for <new>,<all>
0136 cleartags(:,flag_clear_g) = {{'equil','ohm','transpfaste','waves','output','hxrcam'}};% clear all graphs corresponding to cleared times
0137 
0138 status.equil(flag_newempty) = 0;
0139 status.equil(flag_newfull) = 1;
0140 
0141 flag_clear = flag_clear | flag_newempty;
0142 
0143 status.ohm(:,flag_clear) = -1;
0144 % status.transpfaste(:,flag_clear) = -1;
0145 status.ripple(:,flag_clear) = -1;
0146 status.waves(:,flag_clear) = -1;
0147 status.fluct(:,flag_clear) = -1;
0148 status.wavestructs(:,flag_clear) = -1;
0149 status.job(:,flag_clear) = -1;
0150 status.output(:,flag_clear) = -1;
0151 status.sdiag(:,flag_clear) = 0;
0152 
0153 %
0154 % sort times removing previous structures if recurrence
0155 %
0156 [shotimes,mask] = unique(shotimes,'last');
0157 
0158 ntimes = length(shotimes);
0159 
0160 dkeparams = dkeparams(:,mask);
0161 equils = equils(:,mask);
0162 ohms = ohms(:,mask);
0163 transpfastes = transpfastes(:,mask);
0164 ripples = ripples(:,mask);
0165 wavess = wavess(:,mask);
0166 fluctparams = fluctparams(:,mask);
0167 ripples = ripples(:,mask);
0168 %
0169 wavestructss = wavestructss(:,mask);
0170 %
0171 jobs = jobs(:,mask);
0172 outputs = outputs(:,mask);
0173 sdiags = sdiags(:,mask);
0174 
0175 status.equil = status.equil(:,mask);
0176 status.ohm = status.ohm(:,mask);
0177 % status.transpfaste = status.transpfaste(:,mask);
0178 status.ripple = status.ripple(:,mask);
0179 status.waves = status.waves(:,mask);
0180 status.fluct = status.fluct(:,mask);
0181 status.wavestructs = status.wavestructs(:,mask);
0182 status.job = status.job(:,mask);
0183 status.output = status.output(:,mask);
0184 status.sdiag = status.sdiag(:,mask);
0185 
0186 mask_g = [1,2,2+mask(:).'];% 1,2 for <new>,<all>
0187 graphss = graphss(:,mask_g);
0188 cleartags = cleartags(:,mask_g);
0189 lukeobj.plot1.gindex = lukeobj.plot1.gindex(:,mask_g);
0190 lukeobj.plot2.gindex = lukeobj.plot2.gindex(:,mask_g);
0191 lukeobj.plot3.gindex = lukeobj.plot3.gindex(:,mask_g);
0192 
0193 clear flag_remove flag_remove_g flag_clear flag_clear_g flag_newempty flag_newfull flag_new nnew mask mask_g
0194 
0195 if ntimes == 1 && curtime == 0,
0196     curtime = 1;
0197 end
0198 
0199 if ntimes == 0 && curtime > 0,
0200     curtime = 0;
0201 end
0202 
0203 if curtime > 0,
0204     if status.output(curtime) == 0 && isempty(jobs{curtime}),
0205         lukeobj.runluke.highlight = true;
0206     else
0207         lukeobj.runluke.highlight = false;
0208     end            
0209 else% curtime = 0, treat or display all times at once
0210     if all(status.equil == 0),
0211         lukeobj.equil.make.highlight = true;      
0212     else
0213         lukeobj.equil.make.highlight = false;    
0214     end      
0215 end
0216 
0217 %
0218 % UPDATE STATES/STRINGS
0219 %
0220 
0221 [equils,lukeobj.equil,cleartags] = iluke_status(equils,status.equil,lukeobj.equil,-1,curtime,cleartags);
0222 [ohms,lukeobj.ohm,cleartags] = iluke_status(ohms,status.ohm,lukeobj.ohm,0,curtime,cleartags);
0223 % [transpfastes,lukeobj.transp,cleartags] = iluke_status(transpfastes,status.transpfaste,lukeobj.transp,0,curtime,cleartags);
0224 [ripples,lukeobj.ripple,cleartags] = iluke_status(ripples,status.ripple,lukeobj.ripple,0,curtime,cleartags);
0225 [wavess,lukeobj.wave,cleartags] = iluke_status(wavess,status.waves,lukeobj.wave,0,curtime,cleartags);
0226 % [fluctparams,lukeobj.fluct,cleartags] = iluke_status(fluctparams,status.fluct,lukeobj.fluct,0,curtime,cleartags);
0227 
0228 [outputs,lukeobj.luke,cleartags] = iluke_status(outputs,status.output,lukeobj.luke,1,curtime,cleartags);
0229 [sdiags,lukeobj.sdiag,cleartags] = iluke_status(sdiags,status.sdiag,lukeobj.sdiag,2,curtime,cleartags);
0230 
0231 %
0232 % DKEPARAMS
0233 %
0234 
0235 iluke_update_dkeparam;
0236 
0237 %
0238 % TRANSPS
0239 %
0240 
0241 iluke_update_transpfaste;
0242 
0243 %
0244 % FLUCT
0245 %
0246 
0247 iluke_update_fluct;
0248 
0249 %
0250 % WAVESTRUCTS
0251 %
0252 
0253 iluke_update_wavestruct;
0254 
0255 %
0256 % R5X2
0257 %
0258 
0259 iluke_update_hxr;
0260 
0261 if ntimes == 0,
0262     tokamak = '';
0263     shotnum = '';
0264     
0265     status.data = -1;
0266     lukeobj = iluke_info(lukeobj,'startup');% info display
0267     
0268     lukeobj.data.import.highlight = true;
0269     lukeobj.equil.make.highlight = false;
0270 else
0271     lukeobj.data.import.highlight = false;
0272 end
0273 
0274 
0275 if ~isempty(tokamak),
0276     lukeobj.tokamak.string = tokamak;
0277 else
0278     lukeobj.tokamak.string = '< empty >';
0279 end
0280 
0281 if ~isempty(shotnum),
0282     lukeobj.shotnum.string = shotnum;
0283 else
0284     lukeobj.shotnum.string = '< empty >';
0285 end
0286 
0287 lukeobj.shotimes.string = cell(1,ntimes + 2);
0288 lukeobj.shotimes.string{1} = '< new >';
0289 lukeobj.shotimes.string{2} = '< all >';
0290 for it = 1:ntimes,
0291     lukeobj.shotimes.string{it + 2} = num2str(shotimes(it),'%6.4f');
0292 end
0293 
0294 clear it
0295 
0296 if status.data == -1,
0297     lukeobj.simulfile.string = '< no data >';
0298 elseif status.data == 0,
0299     lukeobj.simulfile.string = '< not saved >';
0300 elseif status.data == 2,
0301     lukeobj.simulfile.string = '< outdated >';
0302 end
0303 
0304 %
0305 % SPECIFIC CASES
0306 %
0307 
0308 iluke_manage;
0309 
0310 %
0311 % UPDATE GRAPHS & LISTS
0312 %
0313 
0314 %
0315 % clear tagged graphs and fix indices
0316 %
0317 for it = 1:ntimes+2,
0318     %
0319     % graphs cannot have two parents
0320     %
0321     if lukeobj.plot2.gindex(it) == lukeobj.plot1.gindex(it),
0322         lukeobj.plot2.gindex(it) = 0;
0323     end
0324     if any(lukeobj.plot3.gindex(it) == [lukeobj.plot1.gindex(it),lukeobj.plot2.gindex(it)]),
0325         lukeobj.plot3.gindex(it) = 0;
0326     end
0327     %
0328     plotindices = [lukeobj.plot1.gindex(it),lukeobj.plot2.gindex(it),lukeobj.plot3.gindex(it)];
0329     %
0330     % clear outdated graphs and make others not visible
0331     %
0332     ngraphs = length(graphss{it});
0333     for igraph = ngraphs:-1:1,
0334         if any(strcmp(cleartags{it},'all')) || any(strcmp(graphss{it}(igraph).tag,cleartags{it})),
0335             delete(graphss{it}(igraph).handles)
0336             graphss{it}(igraph) = [];
0337             plotindices(plotindices == igraph) = 0;
0338             plotindices(plotindices > igraph) = plotindices(plotindices > igraph) - 1;
0339         else
0340             recset_jd(graphss{it}(igraph).handles,'Visible','off',true)
0341         end
0342     end
0343     %
0344     lukeobj.plot1.gindex(it) = plotindices(1);
0345     lukeobj.plot2.gindex(it) = plotindices(2);
0346     lukeobj.plot3.gindex(it) = plotindices(3);
0347     %
0348     cleartags{it} = {};% cleartags can be purged
0349     %
0350 end
0351 clear it 
0352 
0353 %
0354 % move and/or show selected graphs
0355 %
0356 graphs = graphss{2+curtime};
0357 ngraphs = length(graphs);
0358 graphsel_string = cell(1,ngraphs+1);
0359 graphsel_string{1} = '';
0360 %
0361 plothandles = [lukeobj.plot1.handle,lukeobj.plot2.handle,lukeobj.plot3.handle];
0362 plotindices = [lukeobj.plot1.gindex(2+curtime),lukeobj.plot2.gindex(2+curtime),lukeobj.plot3.gindex(2+curtime)];
0363 %
0364 for igraph = 1:ngraphs,
0365     graphsel_string{igraph+1} = graphs(igraph).info;
0366     iplot = find(igraph == plotindices);
0367     if ~isempty(iplot),
0368         recset_jd(graphs(igraph).handles,'Parent',plothandles(iplot),false)
0369         recset_jd(graphs(igraph).handles,'Visible','on',true)
0370     end
0371 end
0372 %
0373 lukeobj.graph1sel.string = graphsel_string;
0374 lukeobj.graph2sel.string = graphsel_string;
0375 lukeobj.graph3sel.string = graphsel_string;
0376 %
0377 lukeobj.graph1sel.value = 1 + plotindices(1);
0378 lukeobj.graph2sel.value = 1 + plotindices(2);
0379 lukeobj.graph3sel.value = 1 + plotindices(3);
0380 %
0381 clear plothandles plotindices graphsel_string igraph iplot ich graphs ngraphs
0382 %
0383 if lukeobj.plot1.gindex(2+curtime) > 0,
0384     lukeobj.graph1save.state = 'on';
0385     lukeobj.graph1print.state = 'on';
0386 else
0387     lukeobj.graph1save.state = 'off';
0388     lukeobj.graph1print.state = 'off';
0389 end    
0390 if lukeobj.plot2.gindex(2+curtime) > 0,
0391     lukeobj.graph2save.state = 'on';
0392     lukeobj.graph2print.state = 'on';
0393 else
0394     lukeobj.graph2save.state = 'off';
0395     lukeobj.graph2print.state = 'off';
0396 end    
0397 if lukeobj.plot3.gindex(2+curtime) > 0,
0398     lukeobj.graph3save.state = 'on';
0399     lukeobj.graph3print.state = 'on';
0400 else
0401     lukeobj.graph3save.state = 'off';
0402     lukeobj.graph3print.state = 'off';
0403 end    
0404 
0405 %
0406 % REMOTE
0407 %
0408 
0409 if curtime == 0,
0410     lukeobj.timedep.state = 'on';
0411 else
0412     lukeobj.timedep.state = 'off';
0413 end
0414 
0415 if curtime == 0 && lukeobj.timedep.value,% independent multi time calculation
0416     lukeobj.dist.state = 'on';
0417 else% single time or dependent time calculation
0418     lukeobj.dist.state = 'off';
0419 end
0420 
0421 if lukeobj.remote.select.value > 1,% batch calculation
0422     lukeobj.timeout.state = 'on';
0423 else
0424     lukeobj.timeout.state = 'off';
0425 end
0426 
0427 %
0428 % WORKDIR
0429 %
0430 cd(workdir)
0431 if ~strcmp(workdir(end),filesep),
0432     workdir = [workdir,filesep];
0433 end
0434 lukeobj.workdir.string = workdir;
0435 
0436 %
0437 % UPDATE OBJECTS
0438 %
0439 lukeobj.shotimes.value = 2 + curtime;
0440 
0441 iluke_update_state(lukeobj);

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