0001 function [V] = VMT_SmoothVar(V,hwin,vwin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 warning off
0014
0015 use_smooth2a = 1;
0016
0017
0018
0019 if V.probeType == 'RG'
0020 var ={...
0021 'streamwise';...
0022 'transverse';...
0023 'mag';...
0024 'primary_zsd';...
0025 'secondary_zsd';...
0026 'primary_roz';...
0027 'secondary_roz';...
0028 'primary_roz_x';...
0029 'primary_roz_y';...
0030 'secondary_roz_x';...
0031 'secondary_roz_y';...
0032 'backscatter';...
0033 'flowangle';...
0034 };
0035 elseif V.probeType == 'M9'
0036 var ={...
0037 'streamwise';...
0038 'transverse';...
0039 'mag';...
0040 'primary_zsd';...
0041 'secondary_zsd';...
0042 'primary_roz';...
0043 'secondary_roz';...
0044 'primary_roz_x';...
0045 'primary_roz_y';...
0046 'secondary_roz_x';...
0047 'secondary_roz_y';...
0048 ...
0049 'flowangle';...
0050 };
0051 elseif V.probeType == 'RR'
0052 var ={...
0053 'streamwise';...
0054 'transverse';...
0055 'mag';...
0056 'primary_zsd';...
0057 'secondary_zsd';...
0058 'primary_roz';...
0059 'secondary_roz';...
0060 'primary_roz_x';...
0061 'primary_roz_y';...
0062 'secondary_roz_x';...
0063 'secondary_roz_y';...
0064 'backscatter';...
0065 'flowangle';...
0066 };
0067 end
0068
0069 Fr = vwin;
0070
0071 Fc = hwin;
0072
0073 if Fr == 0 & Fc ~= 0
0074 errordlg('Both Vertical Smoothing Window and Horizontal Smoothing Window must be set to zero to turn off smoothing. Smoothing cannot be turned off in one direction only.' );
0075 elseif Fr ~= 0 & Fc == 0
0076 errordlg('Both Vertical Smoothing Window and Horizontal Smoothing Window must be set to zero to turn off smoothing. Smoothing cannot be turned off in one direction only.');
0077 end
0078
0079 for i = 1:numel(var)
0080 switch var{i}
0081 case{'streamwise'}
0082 if Fr == 0 & Fc == 0
0083 V.uSmooth = V.u;
0084 else
0085 if use_smooth2a
0086 [V.uSmooth] = smooth2a(V.u,Fr,Fc);
0087 else
0088 [V.uSmooth] = nanmoving_average2(V.u,Fr,Fc);
0089 end
0090 end
0091
0092 case{'transverse'}
0093 if Fr == 0 & Fc == 0
0094 V.vSmooth = V.v;
0095 else
0096 if use_smooth2a
0097 [V.vSmooth] = smooth2a(V.v,Fr,Fc);
0098 else
0099 [V.vSmooth] = nanmoving_average2(V.v,Fr,Fc);
0100 end
0101 end
0102 case{'mag'}
0103 if Fr == 0 & Fc == 0
0104 V.mcsMagSmooth = V.mcsMag;
0105 else
0106 if use_smooth2a
0107
0108
0109
0110 V.mcsEastSmooth = smooth2a(V.mcsEast,Fr,Fc);
0111 V.mcsNorthSmooth = smooth2a(V.mcsNorth,Fr,Fc);
0112 else
0113
0114 V.mcsEastSmooth = nanmoving_average2(V.mcsEast,Fr,Fc);
0115 V.mcsNorthSmooth = nanmoving_average2(V.mcsNorth,Fr,Fc);
0116 end
0117 [V.mcsMagSmooth] = sqrt(V.mcsEastSmooth .^2 + V.mcsNorthSmooth.^2);
0118 end
0119 case{'primary_zsd'}
0120 if Fr == 0 & Fc == 0
0121 V.vpSmooth = V.vp;
0122 else
0123 if use_smooth2a
0124 [V.vpSmooth] = smooth2a(V.vp,Fr,Fc);
0125 else
0126 [V.vpSmooth] = nanmoving_average2(V.vp,Fr,Fc);
0127 end
0128 end
0129 case{'secondary_zsd'}
0130 if Fr == 0 & Fc == 0
0131 V.vsSmooth = V.vs;
0132 else
0133 if use_smooth2a
0134 [V.vsSmooth] = smooth2a(V.vs,Fr,Fc);
0135 else
0136 [V.vsSmooth] = nanmoving_average2(V.vs,Fr,Fc);
0137 end
0138 end
0139 case{'primary_roz'}
0140 if Fr == 0 & Fc == 0
0141 V.Roz.upSmooth = V.Roz.up;
0142 else
0143 if use_smooth2a
0144 [V.Roz.upSmooth] = smooth2a(V.Roz.up,Fr,Fc);
0145 else
0146 [V.Roz.upSmooth] = nanmoving_average2(V.Roz.up,Fr,Fc);
0147 end
0148 end
0149 case{'secondary_roz'}
0150 if Fr == 0 & Fc == 0
0151 V.Roz.usSmooth = V.Roz.us;
0152 else
0153 if use_smooth2a
0154 [V.Roz.usSmooth] = smooth2a(V.Roz.us,Fr,Fc);
0155 else
0156 [V.Roz.usSmooth] = nanmoving_average2(V.Roz.us,Fr,Fc);
0157 end
0158 end
0159 case{'primary_roz_x'}
0160 if Fr == 0 & Fc == 0
0161 V.Roz.upxSmooth = V.Roz.upx;
0162 else
0163 if use_smooth2a
0164 [V.Roz.upxSmooth] = smooth2a(V.Roz.upx,Fr,Fc);
0165 else
0166 [V.Roz.upxSmooth] = nanmoving_average2(V.Roz.upx,Fr,Fc);
0167 end
0168 end
0169 case{'primary_roz_y'}
0170 if Fr == 0 & Fc == 0
0171 V.Roz.upySmooth = V.Roz.upy;
0172 else
0173 if use_smooth2a
0174 [V.Roz.upySmooth] = smooth2a(V.Roz.upy,Fr,Fc);
0175 else
0176 [V.Roz.upySmooth] = nanmoving_average2(V.Roz.upy,Fr,Fc);
0177 end
0178 end
0179 case{'secondary_roz_x'}
0180 if Fr == 0 & Fc == 0
0181 V.Roz.usxSmooth = V.Roz.usx;
0182 else
0183 if use_smooth2a
0184 [V.Roz.usxSmooth] = smooth2a(V.Roz.usx,Fr,Fc);
0185 else
0186 [V.Roz.usxSmooth] = nanmoving_average2(V.Roz.usx,Fr,Fc);
0187 end
0188 end
0189 case{'secondary_roz_y'}
0190 if Fr == 0 & Fc == 0
0191 V.Roz.usySmooth = V.Roz.usy;
0192 else
0193 if use_smooth2a
0194 [V.Roz.usySmooth] = smooth2a(V.Roz.usy,Fr,Fc);
0195 else
0196 [V.Roz.usySmooth] = nanmoving_average2(V.Roz.usy,Fr,Fc);
0197 end
0198 end
0199 case{'backscatter'}
0200 if Fr == 0 & Fc == 0
0201 V.mcsBackSmooth = V.mcsBack;
0202 else
0203 if use_smooth2a
0204 [V.mcsBackSmooth] = smooth2a(V.mcsBack,Fr,Fc);
0205 else
0206 [V.mcsBackSmooth] = nanmoving_average2(V.mcsBack,Fr,Fc);
0207 end
0208
0209 end
0210 case{'flowangle'}
0211 if Fr == 0 & Fc == 0
0212 V.mcsDirSmooth = V.mcsDir;
0213 else
0214
0215 if use_smooth2a
0216 V.mcsNorthSmooth = smooth2a(V.mcsNorth,Fr,Fc);
0217 V.mcsEastSmooth = smooth2a(V.mcsEast,Fr,Fc);
0218 else
0219 V.mcsNorthSmooth = nanmoving_average2(V.mcsNorth,Fr,Fc);
0220 V.mcsEastSmooth = nanmoving_average2(V.mcsEast,Fr,Fc);
0221 end
0222 V.mcsDirSmooth = 90 - (atan2(V.mcsNorthSmooth, V.mcsEastSmooth))*180/pi;
0223 qindx = find(V.mcsDirSmooth < 0);
0224 if ~isempty(qindx)
0225 V.mcsDirSmooth(qindx) = V.mcsDirSmooth(qindx) + 360;
0226 end
0227 end
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258 end
0259 end
0260
0261
0262
0263 if Fr == 0 & Fc == 0
0264 V.wSmooth = V.w;
0265 else
0266 if use_smooth2a
0267 [V.wSmooth] = smooth2a(V.w,Fr,Fc);
0268 else
0269 [V.wSmooth] = nanmoving_average2(V.w,Fr,Fc);
0270 end
0271 end
0272
0273
0274 if Fr == 0 & Fc == 0
0275 V.mcsErrorSmooth = V.mcsError;
0276 else
0277 if use_smooth2a
0278 [V.mcsErrorSmooth] = smooth2a(V.mcsError,Fr,Fc);
0279 else
0280 [V.mcsErrorSmooth] = nanmoving_average2(V.mcsError,Fr,Fc);
0281 end
0282 end
0283
0284
0285 warning on
0286