annotate private/EDB1editpathlist.m @ 18:2d5f50205527 jabuilder_int tip

Escape the trailing backslash as well
author Chris Cannam
date Tue, 30 Sep 2014 16:23:00 +0100
parents 90220f7249fc
children
rev   line source
tp@0 1 function EDB1editpathlist(edpathsfile,useedges,symmetricedges,pathstokeep)
tp@0 2 % EDB1editpathlist - Does some semi-automatic editing of an edpathsfile.
tp@0 3 % A vector, 'multfactors' is introduced, which will boost or
tp@0 4 % keep or switch off paths in the list of paths.
tp@0 5 %
tp@0 6 % Input parameters:
tp@0 7 % edpathsfile An edpaths file that should be modified.
tp@0 8 % useedges (optional) A list of edges that should be used. All
tp@0 9 % paths that contain an edge which is not this edge will
tp@0 10 % be switched off.
tp@0 11 % symmetricedges (optional) A matrix of edge pairs that are symmetrical
tp@0 12 % around a symmetry plane. If, e.g., edges 2 and 3 are symmetric around the
tp@0 13 % source/receiver plane, then symmetricedges = [2 3]. Several pairs are
tp@0 14 % possible; symmetricedges = [2 3;7 8;9 12];
tp@0 15 % pathstokeep (optional) A matrix of specific diffraction paths to
tp@0 16 % keep.
tp@0 17 % SHOWTEXT (global)
tp@0 18 %
tp@0 19 % ----------------------------------------------------------------------------------------------
tp@0 20 % This file is part of the Edge Diffraction Toolbox by Peter Svensson.
tp@0 21 %
tp@0 22 % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify
tp@0 23 % it under the terms of the GNU General Public License as published by the Free Software
tp@0 24 % Foundation, either version 3 of the License, or (at your option) any later version.
tp@0 25 %
tp@0 26 % The Edge Diffraction Toolbox is distributed in the hope that it will be useful,
tp@0 27 % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
tp@0 28 % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
tp@0 29 %
tp@0 30 % You should have received a copy of the GNU General Public License along with the
tp@0 31 % Edge Diffraction Toolbox. If not, see <http://www.gnu.org/licenses/>.
tp@0 32 % ----------------------------------------------------------------------------------------------
tp@0 33 % Peter Svensson (svensson@iet.ntnu.no) 20050510
tp@0 34 %
tp@0 35 % EDB1editpathlist(edpathsfile,useedges,symmetricedges,pathstokeep);
tp@0 36
tp@0 37 global SHOWTEXT
tp@0 38
tp@0 39 if isempty(symmetricedges)
tp@0 40 dosymmetry = 0;
tp@0 41 else
tp@0 42 dosymmetry = 1;
tp@0 43 end
tp@0 44
tp@0 45 if isempty(pathstokeep)
tp@0 46 dopathpruning = 0;
tp@0 47 else
tp@0 48 dopathpruning = 1;
tp@0 49 end
tp@0 50
tp@0 51 if ~isempty(useedges)
tp@0 52 error(['ERROR: Sorry, the useedges option has not been implemented yet!'])
tp@0 53 end
tp@0 54
tp@0 55 %-------------------------------------------------------------------------
tp@0 56
tp@0 57 nsymmetricedgepairs = size(symmetricedges,1);
tp@0 58
tp@0 59 Varlist = [' S R allspecrows firstdiffrow mainlistguidepattern mainlistguide reflpaths pathtypevec'];
tp@0 60 Varlist = [Varlist,' Sinsideplanenumber Rinsideplanenumber directsoundrow specextradata edgeextradata'];
tp@0 61 if dosymmetry | dopathpruning
tp@0 62 Varlist = [Varlist,' multfactors'];
tp@0 63 end
tp@0 64
tp@0 65 %-------------------------------------------------------------------------
tp@0 66
tp@0 67 eval(['load ',edpathsfile])
tp@0 68 disp(' ')
tp@0 69 disp(['Modifying ',edpathsfile])
tp@0 70 [ncombs,ncols] = size(reflpaths);
tp@0 71 multfactors = ones(ncombs,1);
tp@0 72
tp@0 73 %-------------------------------------------------------------------------
tp@0 74
tp@0 75 if dosymmetry
tp@0 76
tp@0 77 onesvec = ones(ncombs,1);
tp@0 78 for kkk = 1:ncols
tp@0 79 if SHOWTEXT >= 1
tp@0 80 disp([' Diffraction order ',int2str(kkk)])
tp@0 81 end
tp@0 82 irow = sum((mainlistguidepattern=='d').').' == kkk;
tp@0 83 if sum(irow) > 0
tp@0 84 ivselection = [double(mainlistguide(irow,2)):double(mainlistguide(irow,3))].';
tp@0 85 for mmm = 1:nsymmetricedgepairs
tp@0 86 if SHOWTEXT >= 1
tp@0 87 disp([' Symmetry pair ',int2str(mmm)])
tp@0 88 end
tp@0 89 iv = any(reflpaths(ivselection,:).'==symmetricedges(mmm,1));
tp@0 90 if ~isempty(iv)
tp@0 91 iv = ivselection(iv);
tp@0 92 for nnn=1:length(iv)
tp@0 93 reflpathsmatch = reflpaths(iv(nnn),:);
tp@0 94 if multfactors(iv(nnn)) ~= 0
tp@0 95 colstoswitch1 = find(reflpathsmatch==symmetricedges(mmm,1));
tp@0 96 colstoswitch2 = find(reflpathsmatch==symmetricedges(mmm,2));
tp@0 97 reflpathsmatch(colstoswitch1) = symmetricedges(mmm,2);
tp@0 98 reflpathsmatch(colstoswitch2) = symmetricedges(mmm,1);
tp@0 99
tp@0 100 reflpathsmatch = reflpathsmatch(onesvec,:);
tp@0 101
tp@0 102 ivmatch = find(sum( (reflpaths==reflpathsmatch).' ).'==ncols);
tp@0 103 if ~isempty(ivmatch) & multfactors(ivmatch) ~= 0
tp@0 104 multfactors(iv(nnn)) = 2*multfactors(iv(nnn));
tp@0 105 multfactors(ivmatch) = 0;
tp@0 106 if SHOWTEXT >= 2
tp@0 107 disp([' Found symmetric edge pair:'])
tp@0 108 disp([' ',int2str(iv(nnn)),': ',int2str(double(reflpaths(iv(nnn),:)))])
tp@0 109 disp([' ',int2str(ivmatch),': ',int2str(double(reflpaths(ivmatch,:)))])
tp@0 110 end
tp@0 111 end
tp@0 112 end % ... if multfactors(iv(nnn)) ~= 0,
tp@0 113
tp@0 114 end % ... for nnn=1:length(iv)
tp@0 115 end % ... if ~isempty(iv)
tp@0 116 end % for mmm = 1:nsymmetricedgepairs
tp@0 117 end % ...if sum(irow) > 0
tp@0 118 end % ... for kkk = 1:ncols
tp@0 119 end % ...if dosymmetry
tp@0 120
tp@0 121 %-------------------------------------------------------------------------
tp@0 122
tp@0 123 if dopathpruning
tp@0 124 multfactors = multfactors*0;
tp@0 125 for ii = 1:size(pathstokeep,1)
tp@0 126 pathtomatch = pathstokeep(ii,:);
tp@0 127 pathtomatch = pathtomatch(ones(ncombs,1),:);
tp@0 128 ivmatch = find(sum( (reflpaths==pathtomatch).' ).'==ncols);
tp@0 129 multfactors(ivmatch) = 1;
tp@0 130 end
tp@0 131 end
tp@0 132
tp@0 133 %-------------------------------------------------------------------------
tp@0 134
tp@0 135 eval(['save ',edpathsfile,Varlist])