select_shotimes_jd

PURPOSE ^

SYNOPSIS ^

function [shotimes,isel] = select_shotimes_jd(str_before,str_after,path_simul,shotimes)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [shotimes,isel] = select_shotimes_jd(str_before,str_after,path_simul,shotimes)
0002 %
0003 if nargin < 4,
0004     shotimes = {};
0005 end
0006 %
0007 if nargin < 3,
0008     path_simul = './';
0009 end
0010 %
0011 % list shot times
0012 %
0013 matlabfiles = what(path_simul);
0014 dirshotimes = {};
0015 if ~isempty(matlabfiles),
0016     matfiles = matlabfiles.mat;
0017     nfiles = length(matfiles);
0018     nstr = length(str_before);
0019     for imatfile = 1:nfiles,
0020         matfile = matfiles{imatfile};
0021         istr_before = strfind(matfile,str_before);
0022         istr_after = strfind(matfile,str_after);
0023         if ~isempty(istr_before) && ~isempty(istr_after),
0024             dirshotimes = [dirshotimes,matfile(istr_before+nstr:istr_after-1)];
0025         end
0026     end
0027 end
0028 %
0029 %dirshotimes = unique(dirshotimes);
0030 [dummy,isel] = unique(str2double(dirshotimes));dirshotimes = dirshotimes(isel);
0031 %
0032 % select shot times
0033 %
0034 if isempty(shotimes),% all shot times
0035     shotimes = dirshotimes;
0036     isel = NaN;
0037 elseif iscell(shotimes),
0038     nshots = length(shotimes);
0039     isel = zeros(1,nshots);
0040     for ishotime = 1:nshots,
0041         if any(strcmp(shotimes{ishotime},dirshotimes))
0042             isel(ishotime) = 1;
0043             disp(['The data file for shot time ',shotimes{ishotime},' was found'])
0044         else
0045             disp(['WARNING : The data file for shot time ',shotimes{ishotime},' was not found'])
0046             disp(['str_before : ',str_before])
0047             disp(['str_after : ',str_after])
0048             disp(['path_simul : ',path_simul])
0049         end
0050     end
0051     isel = find(isel);
0052     shotimes = shotimes(isel); 
0053     %
0054 else
0055     nshots = length(dirshotimes);
0056     iseldir = [];
0057     for ishotime = 1:nshots,
0058         t = str2num(dirshotimes{ishotime});
0059         if t >= shotimes(1) && t <= shotimes(2),
0060             iseldir = [iseldir,ishotime];
0061         end
0062     end
0063     shotimes = dirshotimes(iseldir);
0064     isel = NaN;    
0065 end

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