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 end
0052
0053 Fr = vwin;
0054
0055 Fc = hwin;
0056
0057 if Fr == 0 & Fc ~= 0
0058 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.' );
0059 elseif Fr ~= 0 & Fc == 0
0060 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.');
0061 end
0062
0063 for i = 1:numel(var)
0064 switch var{i}
0065 case{'streamwise'}
0066 if Fr == 0 & Fc == 0
0067 V.uSmooth = V.u;
0068 else
0069 if use_smooth2a
0070 [V.uSmooth] = smooth2a(V.u,Fr,Fc);
0071 else
0072 [V.uSmooth] = nanmoving_average2(V.u,Fr,Fc);
0073 end
0074 end
0075
0076 case{'transverse'}
0077 if Fr == 0 & Fc == 0
0078 V.vSmooth = V.v;
0079 else
0080 if use_smooth2a
0081 [V.vSmooth] = smooth2a(V.v,Fr,Fc);
0082 else
0083 [V.vSmooth] = nanmoving_average2(V.v,Fr,Fc);
0084 end
0085 end
0086 case{'mag'}
0087 if Fr == 0 & Fc == 0
0088 V.mcsMagSmooth = V.mcsMag;
0089 else
0090 if use_smooth2a
0091
0092
0093
0094 V.mcsEastSmooth = smooth2a(V.mcsEast,Fr,Fc);
0095 V.mcsNorthSmooth = smooth2a(V.mcsNorth,Fr,Fc);
0096 else
0097
0098 V.mcsEastSmooth = nanmoving_average2(V.mcsEast,Fr,Fc);
0099 V.mcsNorthSmooth = nanmoving_average2(V.mcsNorth,Fr,Fc);
0100 end
0101 [V.mcsMagSmooth] = sqrt(V.mcsEastSmooth .^2 + V.mcsNorthSmooth.^2);
0102 end
0103 case{'primary_zsd'}
0104 if Fr == 0 & Fc == 0
0105 V.vpSmooth = V.vp;
0106 else
0107 if use_smooth2a
0108 [V.vpSmooth] = smooth2a(V.vp,Fr,Fc);
0109 else
0110 [V.vpSmooth] = nanmoving_average2(V.vp,Fr,Fc);
0111 end
0112 end
0113 case{'secondary_zsd'}
0114 if Fr == 0 & Fc == 0
0115 V.vsSmooth = V.vs;
0116 else
0117 if use_smooth2a
0118 [V.vsSmooth] = smooth2a(V.vs,Fr,Fc);
0119 else
0120 [V.vsSmooth] = nanmoving_average2(V.vs,Fr,Fc);
0121 end
0122 end
0123 case{'primary_roz'}
0124 if Fr == 0 & Fc == 0
0125 V.Roz.upSmooth = V.Roz.up;
0126 else
0127 if use_smooth2a
0128 [V.Roz.upSmooth] = smooth2a(V.Roz.up,Fr,Fc);
0129 else
0130 [V.Roz.upSmooth] = nanmoving_average2(V.Roz.up,Fr,Fc);
0131 end
0132 end
0133 case{'secondary_roz'}
0134 if Fr == 0 & Fc == 0
0135 V.Roz.usSmooth = V.Roz.us;
0136 else
0137 if use_smooth2a
0138 [V.Roz.usSmooth] = smooth2a(V.Roz.us,Fr,Fc);
0139 else
0140 [V.Roz.usSmooth] = nanmoving_average2(V.Roz.us,Fr,Fc);
0141 end
0142 end
0143 case{'primary_roz_x'}
0144 if Fr == 0 & Fc == 0
0145 V.Roz.upxSmooth = V.Roz.upx;
0146 else
0147 if use_smooth2a
0148 [V.Roz.upxSmooth] = smooth2a(V.Roz.upx,Fr,Fc);
0149 else
0150 [V.Roz.upxSmooth] = nanmoving_average2(V.Roz.upx,Fr,Fc);
0151 end
0152 end
0153 case{'primary_roz_y'}
0154 if Fr == 0 & Fc == 0
0155 V.Roz.upySmooth = V.Roz.upy;
0156 else
0157 if use_smooth2a
0158 [V.Roz.upySmooth] = smooth2a(V.Roz.upy,Fr,Fc);
0159 else
0160 [V.Roz.upySmooth] = nanmoving_average2(V.Roz.upy,Fr,Fc);
0161 end
0162 end
0163 case{'secondary_roz_x'}
0164 if Fr == 0 & Fc == 0
0165 V.Roz.usxSmooth = V.Roz.usx;
0166 else
0167 if use_smooth2a
0168 [V.Roz.usxSmooth] = smooth2a(V.Roz.usx,Fr,Fc);
0169 else
0170 [V.Roz.usxSmooth] = nanmoving_average2(V.Roz.usx,Fr,Fc);
0171 end
0172 end
0173 case{'secondary_roz_y'}
0174 if Fr == 0 & Fc == 0
0175 V.Roz.usySmooth = V.Roz.usy;
0176 else
0177 if use_smooth2a
0178 [V.Roz.usySmooth] = smooth2a(V.Roz.usy,Fr,Fc);
0179 else
0180 [V.Roz.usySmooth] = nanmoving_average2(V.Roz.usy,Fr,Fc);
0181 end
0182 end
0183 case{'backscatter'}
0184 if Fr == 0 & Fc == 0
0185 V.mcsBackSmooth = V.mcsBack;
0186 else
0187 if use_smooth2a
0188 [V.mcsBackSmooth] = smooth2a(V.mcsBack,Fr,Fc);
0189 else
0190 [V.mcsBackSmooth] = nanmoving_average2(V.mcsBack,Fr,Fc);
0191 end
0192
0193 end
0194 case{'flowangle'}
0195 if Fr == 0 & Fc == 0
0196 V.mcsDirSmooth = V.mcsDir;
0197 else
0198
0199 if use_smooth2a
0200 V.mcsNorthSmooth = smooth2a(V.mcsNorth,Fr,Fc);
0201 V.mcsEastSmooth = smooth2a(V.mcsEast,Fr,Fc);
0202 else
0203 V.mcsNorthSmooth = nanmoving_average2(V.mcsNorth,Fr,Fc);
0204 V.mcsEastSmooth = nanmoving_average2(V.mcsEast,Fr,Fc);
0205 end
0206 V.mcsDirSmooth = 90 - (atan2(V.mcsNorthSmooth, V.mcsEastSmooth))*180/pi;
0207 qindx = find(V.mcsDirSmooth < 0);
0208 if ~isempty(qindx)
0209 V.mcsDirSmooth(qindx) = V.mcsDirSmooth(qindx) + 360;
0210 end
0211 end
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242 end
0243 end
0244
0245
0246
0247 if Fr == 0 & Fc == 0
0248 V.wSmooth = V.w;
0249 else
0250 if use_smooth2a
0251 [V.wSmooth] = smooth2a(V.w,Fr,Fc);
0252 else
0253 [V.wSmooth] = nanmoving_average2(V.w,Fr,Fc);
0254 end
0255 end
0256
0257
0258 warning on
0259