0001 function sta = STA_MeanProfile(fitProf,units)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 zPathName = uigetdir('','Select the Directory Containing ASCII Output Data Files (*.txt)');
0012 Files = dir(zPathName);
0013 allFiles = {Files.name};
0014 filefind=strfind(allFiles,'ASC.TXT')';
0015 filesidx=nan(size(filefind,1),1);
0016 for i=1:size(filefind,1)
0017 filesidx(i,1)=size(filefind{i},1);
0018 end
0019 filesidx=find(filesidx>0);
0020 files=allFiles(filesidx);
0021
0022
0023 selection = listdlg('ListSize',[300 300],'ListString', files,'Name','Select Data Files');
0024 zFileName = files(selection);
0025
0026
0027 if isa(zFileName,'cell')
0028 z=size(zFileName,2);
0029 zFileName=sort(zFileName);
0030 else
0031 z=1;
0032 zFileName={zFileName}
0033 end
0034 msgbox('Loading Data...Please Be Patient','Processing Status','help','replace');
0035
0036
0037 j=0;
0038 figure(1); clf
0039
0040
0041 for zi=1:z
0042
0043 if isa(zFileName,'cell')
0044 fileName=strcat(zPathName,'\',zFileName(zi));
0045 fileName=char(fileName);
0046 else
0047 fileName=strcat(zPathName,zFileName);
0048 end
0049
0050
0051 screenData=1;
0052
0053
0054
0055
0056
0057
0058
0059
0060 ignoreBS = 0;
0061 [A]=tfile(fileName,screenData,ignoreBS);
0062
0063 latlon(:,1)=A.Nav.lat_deg(:,:);
0064 latlon(:,2)=A.Nav.long_deg(:,:);
0065
0066 switch A.Sup.units(1,:)
0067 case{'ft'}
0068 error('Units must be metric to start')
0069 end
0070
0071
0072 msgbox('Processing Data...','Processing Status','help','replace');
0073
0074
0075 indx1 = find(abs(latlon(:,1)) > 90);
0076 indx2 = find(abs(latlon(:,2)) > 180);
0077 latlon(indx1,1)=NaN;
0078 latlon(indx2,2)=NaN;
0079
0080 sta.lat = nanmean(latlon(:,1));
0081 sta.lon = nanmean(latlon(:,2));
0082
0083
0084 sta.depth = nanmean(nanmean(A.Nav.depth,2));
0085 sta.vmag = nanmean(A.Wat.vMag,2)./100;
0086 indx = find(~isnan(sta.vmag));
0087 sta.vmag = sta.vmag(indx);
0088 sta.binDepth = nanmean(A.Wat.binDepth,2);
0089 sta.binDepth = sta.binDepth(indx);
0090
0091
0092 sta.z = sta.depth - sta.binDepth;
0093
0094 switch units
0095 case{'metric'}
0096 figure(1); hold on; subplot(ceil(z/3),3,zi)
0097 plot(sta.vmag,sta.z,'ko','MarkerFaceColor','k')
0098 xlabel('Velocity (m/s)')
0099 ylabel('Height above bottom (m)')
0100 ylim([0 ceil(sta.depth)])
0101 case{'english'}
0102 sta.depth = sta.depth*3.281;
0103 sta.vmag = sta.vmag*3.281;
0104 sta.binDepth = sta.binDepth*3.281;
0105 sta.z = sta.z*3.281;
0106 figure(1); hold on; subplot(ceil(z/3),3,zi)
0107 plot(sta.vmag,sta.z,'ko','MarkerFaceColor','k')
0108 xlabel(upper('Velocity, in feet per second'))
0109 ylabel(upper('Height above bottom, in feet'))
0110 ylim([0 ceil(sta.depth)])
0111 end
0112
0113
0114
0115 if fitProf
0116
0117
0118 disp('Log Law Fit')
0119 disp(' u* zo cod ')
0120 [ustar,zo,ks,cod,Xpred,zpred,delta] = fitLogLaw(sta.vmag',sta.z');
0121 sta.ustar(zi) = ustar;
0122 sta.zo(zi) = zo;
0123 sta.ks(zi) = ks;
0124 sta.cod(zi) = cod;
0125 figure(1); hold on; subplot(ceil(z/3),3,zi)
0126
0127 plot(Xpred,zpred,'r-'); hold on
0128
0129
0130 grid on
0131
0132
0133 disp([ustar zo cod])
0134
0135
0136
0137
0138 disp('Fixed Exponent Power Law Fit')
0139 disp(' a n cod ChenProd')
0140
0141 [aii,n,cod,Xpred,zpred,delta] = fitPowerLawFull(sta.vmag'./ustar,sta.z'./zo,1,sta.depth./zo);
0142
0143
0144
0145 figure(1); hold on; subplot(ceil(z/3),3,zi)
0146
0147 plot(Xpred.*ustar,zpred.*zo,'r--'); hold on
0148
0149
0150 chenprod = aii*n*2.718281828*0.41;
0151 disp([aii n cod chenprod])
0152 sta.aii_p1(zi) = aii;
0153 sta.n_p1(zi) = n;
0154 sta.cod_p1(zi) = cod;
0155 sta.cp_p1(zi) = chenprod;
0156
0157
0158
0159 disp('Variable Exponent Power Law Fit')
0160 disp(' a n cod ChenProd')
0161
0162 [aii,n,cod,Xpred,zpred,delta] = fitPowerLawFull(sta.vmag'./ustar,sta.z'./zo,0,sta.depth./zo);
0163
0164 figure(1); hold on; subplot(ceil(z/3),3,zi)
0165
0166 plot(Xpred.*ustar,zpred.*zo,'r:'); hold on
0167
0168
0169 chenprod = aii*n*2.718281828*0.41;
0170 disp([aii n cod chenprod])
0171 sta.aii_p2(zi) = aii;
0172 sta.n_p2(zi) = n;
0173 sta.cod_p2(zi) = cod;
0174 sta.cp_p2(zi) = chenprod;
0175
0176 end
0177
0178 clear A
0179
0180
0181 idx=strfind(fileName,'.');
0182 namecut = fileName(1:idx(1)-5);
0183
0184 clear latlon idx namecut
0185
0186
0187 sta.dam(zi) = -1*VMT_LayerAveMean(sta.z,sta.vmag);
0188 end
0189
0190 msgbox('Processing Complete','Processing Status','help','replace');
0191
0192
0193 end