Home > reduc > support > getTracks.m

getTracks

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function list=getTracks(field,kp,ex)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 function list=getTracks(field,kp,ex)

 field - field name, ie 'survey', or 'ncp'

 Search Parameters
 =================
 kp  - keeps all tracks that matches the input expressions
     - is only one element then you can enter as string, ie 'c4'
     - if multiple search parameters, enter as string array

 ex  - excludes all tracks that matches the input expressions
     - is only one element then you can enter as string, ie 'c4'
     - if multiple search parameters, enter as string array


 For Example
 ===========
 list=get_tracks('survey')
   will get all files listed in survey.txt


 list{n}(1) - start time
        (2) - stop time
        (3) - schedule name
        (4) - numerical date as string, ie '20060225'

        If two+ list{n}(1) have the same date,
        changes list{n}(4) to '20060225A', '20060225B', etc

  sjcm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function list=getTracks(field,kp,ex)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % function list=getTracks(field,kp,ex)
0005 %
0006 % field - field name, ie 'survey', or 'ncp'
0007 %
0008 % Search Parameters
0009 % =================
0010 % kp  - keeps all tracks that matches the input expressions
0011 %     - is only one element then you can enter as string, ie 'c4'
0012 %     - if multiple search parameters, enter as string array
0013 %
0014 % ex  - excludes all tracks that matches the input expressions
0015 %     - is only one element then you can enter as string, ie 'c4'
0016 %     - if multiple search parameters, enter as string array
0017 %
0018 %
0019 % For Example
0020 % ===========
0021 % list=get_tracks('survey')
0022 %   will get all files listed in survey.txt
0023 %
0024 %
0025 % list{n}(1) - start time
0026 %        (2) - stop time
0027 %        (3) - schedule name
0028 %        (4) - numerical date as string, ie '20060225'
0029 %
0030 %        If two+ list{n}(1) have the same date,
0031 %        changes list{n}(4) to '20060225A', '20060225B', etc
0032 %
0033 %  sjcm
0034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0035 
0036 
0037 list=[];
0038 if (isempty(field))
0039   disp('Variable field is empty!');
0040   return;
0041 end
0042 
0043 if (exist('kp'))
0044   if (~iscell(kp))
0045     buf=kp;
0046     kp=[];
0047     if (~isempty(buf))
0048       kp{1}=buf;
0049     end
0050   end
0051 else
0052   kp=[];
0053 end
0054 
0055 if (exist('ex'))
0056   if (~iscell(ex))
0057     buf=ex;
0058     ex=[];
0059     if (~isempty(buf))
0060       ex{1}=buf;
0061     end
0062   end
0063 else
0064   ex=[];
0065 end
0066    
0067 eval(sprintf('list=readtracks(''%s_tracks.txt'');',field));
0068 
0069 if (~isempty(kp) & ~isempty(list))
0070   list=searchlist(list,kp,'keep');
0071 end
0072 
0073 if (~isempty(ex) & ~isempty(list))
0074   list=searchlist(list,ex,'toss');
0075 end
0076 
0077 % Rename redundant date strings
0078 for m=1:length(list)
0079   dates{m}=list{m}{4};
0080 end
0081 for m=1:length(list)
0082   matches=find(ismember(dates,dates{m})>0);
0083   if (length(matches)>1)
0084     str='A';
0085     for n=1:length(matches)
0086       dates{matches(n)}=[dates{matches(n)},str];
0087       str=char(str+1);
0088     end
0089   end
0090 end
0091 for m=1:length(list)
0092   list{m}{4}=dates{m};
0093 end
0094 
0095 
0096 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0097 function list=searchlist(list,sch,type)
0098 
0099 num=length(list{1});
0100 
0101 match=[];
0102 for i=1:length(sch)
0103   for j=1:length(list)
0104     for k=1:num
0105       f=regexpi(list{j}(k),sch{i},'match');
0106       if (~isempty(f{1}))
0107     match=[match j];
0108     break;
0109       end
0110     end
0111   end
0112 end
0113 
0114 match=unique(match);
0115 
0116 switch type
0117   case 'keep'
0118     list=list(match);
0119     
0120   case 'toss'
0121     list(match)=[];
0122 end
0123

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005