Home > robbins > whp_bots.m

whp_bots

PURPOSE ^

WHP_BOTS loads multiple woce *.HY2 and *.SEA files

SYNOPSIS ^

function [b,p,u] = whp_bots(a1,a2,a3,a4,a5,a6,a7,a8,a9);

DESCRIPTION ^

 WHP_BOTS loads multiple woce *.HY2 and *.SEA files

 Usage: [bot,props,units] = whp_bots(fname1,fname2,...., fname9)

 merges data using column property titles and units.  If some files have
 extra properties or units don't match then the additional data is appended
 as an additional columns.   Files missing properties have appropriate
 columns padded with nan's
 
 Currently set to disregard data flagged as 'bad' or 'questionable'
 
 Paul E Robbins, copywrite 1995

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [b,p,u] = whp_bots(a1,a2,a3,a4,a5,a6,a7,a8,a9);
0002 
0003 % WHP_BOTS loads multiple woce *.HY2 and *.SEA files
0004 %
0005 % Usage: [bot,props,units] = whp_bots(fname1,fname2,...., fname9)
0006 %
0007 % merges data using column property titles and units.  If some files have
0008 % extra properties or units don't match then the additional data is appended
0009 % as an additional columns.   Files missing properties have appropriate
0010 % columns padded with nan's
0011 %
0012 % Currently set to disregard data flagged as 'bad' or 'questionable'
0013 %
0014 % Paul E Robbins, copywrite 1995
0015 
0016 %  needs to call woce_bot.m
0017 
0018 [b,p,u] = whp_bot(a1);
0019 [b,p,u] = std_bot(b,p,u);
0020 b = [ones(size(b,1),1) b];
0021 p = str2mat('CRSNUM',p);
0022 u = str2mat('  ',u);
0023 
0024 for n = 2:nargin
0025   bo = b; po = p; uo = u;  
0026   eval(['fname = a',num2str(n),';'])
0027   [bn,pn,un] = whp_bot(fname,3);
0028   [bn,pn,un] = std_bot(bn,pn,un);
0029 
0030   bn = [n*ones(size(bn,1),1) bn];  
0031   pn = str2mat('CRSNUM',pn);   un = str2mat('  ',un);
0032   %
0033   % create new block of data sized for both sets but with nan's for new set
0034   b = [bo; n*ones(size(bn,1),1)  nan*ones(size(bn,1),size(bo,2)-1)];
0035   %go through all the variables and check to get properties to line up and
0036   % to  see if units are same
0037   
0038   %keyboard
0039   matched = 0*ones(1,size(pn,1));matched(1) =1;
0040   for i = 2:size(po,1);
0041 
0042     for j = 1:size(pn,1)
0043       if strcmp(po(i,:),pn(j,:))
0044     %if a match is found then add in appropriate column
0045       matched(j) = 1;       
0046       b(b(:,1)==n,i) = bn(:,j);
0047       if ~strcmp(uo(i,:),un(j,:))
0048         disp(['Warning! Units mismatch: ',pn(j,:),' has units ',un(j,:),...
0049                  ' in file ',fname])
0050             disp([ '     Previous file had units ',uo(i,:)])
0051           end
0052         break
0053       end
0054     end
0055   end
0056   if any(matched==0)
0057     for j = find(matched == 0)
0058     %if no match is found append a column to end
0059       b = [b nan*ones(size(b,1),1)];
0060       b(b(:,1)==n,size(b,2)) = bn(:,j);
0061       p = str2mat(p,pn(j,:));
0062       u = str2mat(u,un(j,:));   
0063     end
0064   end
0065 end
0066 
0067 
0068 
0069 
0070

Generated on Wed 30-Nov-2005 15:40:09 by m2html © 2003