iluke_newwavestructs

PURPOSE ^

script iluke_newwavestructs

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 script iluke_newwavestructs

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % script iluke_newwavestructs
0002 %
0003 replaceopts = repmat({[]},size(wavestructids));
0004 %
0005 newwavestructids = cell(0,1);
0006 newwavestructsstatus = zeros(0,ntimes);
0007 newwavestructss = cell(0,ntimes);
0008 %
0009 nt = length(flag_shotimes);
0010 for it = 1:nt,
0011     for iw = 1:length(launchs{it});
0012         %
0013         wavestruct = imake_wavestructs_jd(equils{flag_shotimes(it)},launchs{it}{iw});
0014         %
0015         isel = find(strcmp(wavestruct.id,wavestructids));% compare with existing wavestructids
0016         if isempty(isel),% wavestruct id is not listed in existing wavestructids
0017             %
0018             status.data = 2;
0019             %
0020             newisel = find(strcmp(wavestruct.id,newwavestructids));% compare with existing newwavestructids
0021             if isempty(newisel),% new wavestruct id
0022                 newwavestructids{end+1,1} = wavestruct.id;
0023                 %
0024                 newwavestructsstatus(end+1,:) = zeros(1,ntimes);
0025                 newwavestructss(end+1,:) = cell(1,ntimes);
0026                 %
0027                 newwavestructsstatus(end,flag_shotimes(it)) = 1;
0028                 newwavestructss{end,flag_shotimes(it)} = wavestruct;
0029             else% wavestruct id listed in existing newwavestructids
0030                 if newwavestructsstatus(newisel,flag_shotimes(it)) == 1,
0031                     disp(['Warning : replacing an existing new wavestructs with id ',wavestruct.id])
0032                 end
0033                 newwavestructsstatus(newisel,flag_shotimes(it)) = 1;
0034                 newwavestructss{newisel,flag_shotimes(it)} = wavestruct;
0035             end
0036             %
0037         else% wavestruct id is listed in existing wavestructids
0038             %
0039             if isempty(replaceopts{isel})% prompt for action
0040                 %
0041                 replaceopt = iselect_jd({...
0042                     'Discard new wavestruct',...
0043                     'Fill or replace existing wavestructss cell',...
0044                     'Modify new wavestruct id'},...                                    
0045                     ['The wavestruct id ',wavestruct.id,' is already referenced :'],lukeobj.infopanel.handle,style.buttonselectstyle,3,'buttongroup');
0046                 %
0047                 if replaceopt == 2,% replace
0048                     %
0049                     status.data = 2;
0050                     %
0051                     wavestructss{isel,flag_shotimes(it)} = wavestruct;
0052                     status.wavestructs(isel,flag_shotimes(it)) = 1;
0053                 elseif replaceopt == 3,% create new wavestruct id
0054                     %
0055                     status.data = 2;
0056                     %
0057                     while any(strcmp(wavestruct.id,wavestructids)),
0058                         wavestruct.id = iselect_jd({},'New wavestruct id : ',lukeobj.infopanel.handle,style.editselectstyle,wavestruct.id,'edit');
0059                     end
0060                     newwavestructids{end+1} = wavestruct.id;
0061                     %
0062                     newwavestructsstatus(end+1,:) = zeros(1,ntimes);
0063                     newwavestructss(end+1,:) = cell(1,ntimes);
0064                     %
0065                     newwavestructsstatus(end,flag_shotimes(it)) = 1;
0066                     newwavestructss{end,flag_shotimes(it)} = wavestruct;
0067                 end
0068                 %
0069                 if nt > 1,% prompt to apply same to all shot times
0070                     %
0071                     allopt = iselect_jd({'Yes','No'},'Apply to all times ?',lukeobj.infopanel.handle,style.buttonselectstyle,1,'buttongroup');
0072                     %
0073                     if allopt == 1,
0074                         %
0075                         if replaceopt == 1,% discard all
0076                             replaceopts{isel} = false;
0077                         elseif replaceopt == 2,% replace all
0078                             replaceopts{isel} = true;
0079                         else% modify wavestruct id
0080                             replaceopts{isel} = wavestruct.id;
0081                         end
0082                     end
0083                     %
0084                     clear allopt
0085                     %
0086                 end
0087                 %
0088                 clear replaceopt 
0089                 %
0090             elseif islogical(replaceopts{isel}) && replaceopts{isel},% fill or replace all with new
0091                 %
0092                 status.data = 2;
0093                 %
0094                 wavestructss{isel,flag_shotimes(it)} = wavestruct;
0095                 status.wavestructs(isel,flag_shotimes(it)) = 1;
0096                 %
0097             elseif ischar(replaceopts{isel}), %use this id as new id
0098                 %
0099                 status.data = 2;
0100                 %
0101                 wavestruct.id = replaceopts{isel};
0102                 newisel = find(strcmp(wavestruct.id,newwavestructids));
0103                 newwavestructss{newisel,flag_shotimes(it)} = wavestruct;
0104                 newwavestructsstatus(newisel,flag_shotimes(it)) = 1;
0105             end
0106         end
0107     end
0108 end
0109 %
0110 wavestructids = [wavestructids;newwavestructids];
0111 status.wavestructs = [status.wavestructs;newwavestructsstatus];
0112 wavestructss = [wavestructss;newwavestructss];
0113 %
0114 clear replaceopts wavestruct newwavestructids newwavestructsstatus newwavestructss it nt iw isel newisel

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