Warning, /verification/fizhi-cs-aqualev20/scripts/APEprocess2.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit 7ae8fb32 on 2006-04-03 20:55:29 UTC
7ae8fb32b5 Andr*0001 function [APEprocess2] = APEprocess2(dirsuffix)
0002 % Complete processing of APE second moment decomposition
0003 load mncdirlist
0004 nsegments = size(mncdirlist,1);
0005 eval(['cd ' 'mnc_out_',num2str(mncdirlist(1))])
0006 griddata = rdmnc('grid.*');
0007 XC = griddata.XC;
0008 YC = griddata.YC;
0009 XG = griddata.XG; XG = XG(1:end-1,1:end-1);
0010 YG = griddata.YG; YG = YG(1:end-1,1:end-1);
0011 dxC = griddata.dxC;
0012 dyC = griddata.dyC;
0013 dxG = griddata.dxG;
0014 dyG = griddata.dyG;
0015 RAC = griddata.rA;
0016 HFacC = griddata.HFacC;
0017 HFacW = griddata.HFacW;
0018 HFacS = griddata.HFacS;
0019 ZC = griddata.RC;
0020 ZF = griddata.RF;
0021 drC = griddata.drC;
0022 drF = griddata.drF;
0023 undef=1.e15;
0024 eval(['cd ../'])
0025 %
0026 nx = size(HFacC,1);
0027 ny = size(HFacC,2);
0028 %nr = size(HFacC,3);
0029 nr = 17;
0030 nPg = nx*ny;
0031 nlats = 64;
0032 %
0033 % load COS & SIN of rotation angle:
0034 fid=fopen('/u/molod/proj_cs32_2uEvN.bin','r','b'); uvEN=fread(fid,nx*ny*2,'real*8'); fclose(fid);
0035 uvEN=reshape(uvEN,[nPg 2]);
0036 AngleCS=uvEN(:,1);
0037 AngleSN=uvEN(:,2);
0038 %
0039 tempz=zeros(nlats,nr);
0040 uzav=zeros(nlats,nr);
0041 vzav=zeros(nlats,nr);
0042 wzav=zeros(nlats,nr);
0043 thetazav=zeros(nlats,nr);
0044 saltzav=zeros(nlats,nr);
0045 phizav=zeros(nlats,nr);
0046 %
0047 temp=zeros(nx,ny,nr);
0048 uave=zeros(nx,ny,nr);
0049 vave=zeros(nx,ny,nr);
0050 wave=zeros(nx,ny,nr);
0051 thetaave=zeros(nx,ny,nr);
0052 saltave=zeros(nx,ny,nr);
0053 phiave=zeros(nx,ny,nr);
0054 hfactot=zeros(nx,ny,nr);
0055 %
0056 usqz=zeros(nlats,nr);
0057 vsqz=zeros(nlats,nr);
0058 thetasqz=zeros(nlats,nr);
0059 phisqz=zeros(nlats,nr);
0060 omegasqz=zeros(nlats,nr);
0061 qsqz=zeros(nlats,nr);
0062 uvz=zeros(nlats,nr);
0063 uomegaz=zeros(nlats,nr);
0064 vomegaz=zeros(nlats,nr);
0065 vthetaz=zeros(nlats,nr);
0066 omegathetaz=zeros(nlats,nr);
0067 vqz=zeros(nlats,nr);
0068 omegaqz=zeros(nlats,nr);
0069 vphiz=zeros(nlats,nr);
0070 %
0071 UVtotz=zeros(nlats,nr);
0072 U2totz=zeros(nlats,nr);
0073 V2totz=zeros(nlats,nr);
0074 wvelsqz=zeros(nlats,nr);
0075 potempsqz=zeros(nlats,nr);
0076 phihydsqz=zeros(nlats,nr);
0077 saltsqz=zeros(nlats,nr);
0078 wuEz=zeros(nlats,nr);
0079 wvNz=zeros(nlats,nr);
0080 vNthz=zeros(nlats,nr);
0081 wvelthz=zeros(nlats,nr);
0082 vNsltz=zeros(nlats,nr);
0083 wvelsltz=zeros(nlats,nr);
0084 vNphiz=zeros(nlats,nr);
0085 hfacztot1=zeros(nlats,nr);
0086 hfacztot2=zeros(nlats,nr);
0087 %
0088 % To do while leafing through all the 10-day segments:
0089 for it = 1:nsegments
0090 eval(['cd ' 'mnc_out_',num2str(mncdirlist(it))])
0091 pwd
0092 %
0093 % 1) Stationary Mean: Products of zonal mean, time mean first moments
0094 % Read in the time mean of zonal mean first moments:
0095 % Compute running 3-year mean of zonal mean first moments:
0096 %
0097 fid=fopen('hfacztot1.interim','r','b');hfacz1=fread(fid,[nlats nr],'real*8');fclose(fid);hfacztot1 = hfacztot1 + hfacz1;
0098 fid=fopen('thetazon.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);thetazav=thetazav+tempz.*hfacz1;
0099 fid=fopen('uzon.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);uzav=uzav+tempz.*hfacz1;
0100 fid=fopen('vzon.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vzav=vzav+tempz.*hfacz1;
0101 fid=fopen('wzon.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);wzav=wzav+tempz.*hfacz1;
0102 fid=fopen('saltzon.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);saltzav=saltzav+tempz.*hfacz1;
0103 fid=fopen('phizon.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);phizav=phizav+tempz.*hfacz1;
0104 %
0105 % 2) Stationary Eddies: Total Stationary minus Stationary Mean
0106 % Need zonal mean of products of 3-year mean first moments
0107 % Read in time averages of first moments
0108 % Compute running 3-year mean of first moments:
0109 %
0110 fid=fopen('hfactot1.interim','r','b');temp=fread(fid,[nx*ny nr],'real*8');fclose(fid);hfac=reshape(temp,[nx ny nr]);hfactot = hfactot + hfac;
0111 fid=fopen('thetaave.interim','r','b');temp=fread(fid,[nx*ny nr],'real*8');fclose(fid);temp=reshape(temp,[nx ny nr]);thetaave=thetaave+temp.*hfac;
0112 fid=fopen('uave.interim','r','b');temp=fread(fid,[nx*ny nr],'real*8');fclose(fid);temp=reshape(temp,[nx ny nr]);uave=uave+temp.*hfac;
0113 fid=fopen('vave.interim','r','b');temp=fread(fid,[nx*ny nr],'real*8');fclose(fid);temp=reshape(temp,[nx ny nr]);vave=vave+temp.*hfac;
0114 fid=fopen('wave.interim','r','b');temp=fread(fid,[nx*ny nr],'real*8');fclose(fid);temp=reshape(temp,[nx ny nr]);wave=wave+temp.*hfac;
0115 fid=fopen('saltave.interim','r','b');temp=fread(fid,[nx*ny nr],'real*8');fclose(fid);temp=reshape(temp,[nx ny nr]);saltave=saltave+temp.*hfac;
0116 fid=fopen('phiave.interim','r','b');temp=fread(fid,[nx*ny nr],'real*8');fclose(fid);temp=reshape(temp,[nx ny nr]);phiave=phiave+temp.*hfac;
0117 %
0118 % 3) Transient Mean: Total Mean minus Stationary Mean
0119 % Need time mean of products of zonal mean first moments
0120 % Read in (time averaged) products of zonal means
0121 % Compute running 3-year mean of products of zonal means
0122 %
0123 fid=fopen('thetasqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);thetasqz=thetasqz+tempz.*hfacz1;
0124 fid=fopen('usqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);usqz=usqz+tempz.*hfacz1;
0125 fid=fopen('vsqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vsqz=vsqz+tempz.*hfacz1;
0126 fid=fopen('phisqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);phisqz=phisqz+tempz.*hfacz1;
0127 fid=fopen('omegasqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);omegasqz=omegasqz+tempz.*hfacz1;
0128 fid=fopen('qsqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);qsqz=qsqz+tempz.*hfacz1;
0129 fid=fopen('uvz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);uvz=uvz+tempz.*hfacz1;
0130 fid=fopen('uomegaz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);uomegaz=uomegaz+tempz.*hfacz1;
0131 fid=fopen('vomegaz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vomegaz=vomegaz+tempz.*hfacz1;
0132 fid=fopen('vthetaz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vthetaz=vthetaz+tempz.*hfacz1;
0133 fid=fopen('omegathetaz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);omegathetaz=omegathetaz+tempz.*hfacz1;
0134 fid=fopen('vqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vqz=vqz+tempz.*hfacz1;
0135 fid=fopen('omegaqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);omegaqz=omegaqz+tempz.*hfacz1;
0136 fid=fopen('vphiz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vphiz=vphiz+tempz.*hfacz1;
0137 %
0138 % 4) Transient Eddy: Total Second Moment minus Total Mean minus Stationary Eddy
0139 % Need time mean of zonal mean second moments
0140 % Read in (time averaged) zonal mean second moments
0141 % Compute running 3-year mean of zonal mean second moments
0142 %
0143 % Read in time averages of zonal mean second moments
0144 fid=fopen('hfacztot2.interim','r','b');hfacz2=fread(fid,[nlats nr],'real*8');fclose(fid);hfacztot2 = hfacztot2 + hfacz2;
0145 fid=fopen('potempsqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);potempsqz=potempsqz+tempz.*hfacz2;
0146 fid=fopen('uvtotz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);UVtotz=UVtotz+tempz.*hfacz2;
0147 fid=fopen('u2totz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);U2totz=U2totz+tempz.*hfacz2;
0148 fid=fopen('v2totz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);V2totz=V2totz+tempz.*hfacz2;
0149 fid=fopen('wvelsqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);wvelsqz=wvelsqz+tempz.*hfacz2;
0150 fid=fopen('phihydsqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);phihydsqz=phihydsqz+tempz.*hfacz2;
0151 fid=fopen('saltsqz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);saltsqz=saltsqz+tempz.*hfacz2;
0152 fid=fopen('wuEz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);wuEz=wuEz+tempz.*hfacz2;
0153 fid=fopen('wvNz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);wvNz=wvNz+tempz.*hfacz2;
0154 fid=fopen('vNthz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vNthz=vNthz+tempz.*hfacz2;
0155 fid=fopen('wvelthz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);wvelthz=wvelthz+tempz.*hfacz2;
0156 fid=fopen('vNsltz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vNsltz=vNsltz+tempz.*hfacz2;
0157 fid=fopen('wvelsltz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);wvelsltz=wvelsltz+tempz.*hfacz2;
0158 fid=fopen('vNphiz.interim','r','b');tempz=fread(fid,[nlats nr],'real*8');fclose(fid);vNphiz=vNphiz+tempz.*hfacz2;
0159 eval(['cd ../'])
0160 % End segment loop
0161 end
0162 % Divide by the appropriate counter to compute 3-year time average
0163 inds1=find(hfactot~=0);
0164 thetaave(inds1)=thetaave(inds1) ./ hfactot(inds1);
0165 uave(inds1)=uave(inds1) ./ hfactot(inds1);
0166 vave(inds1)=vave(inds1) ./ hfactot(inds1);
0167 wave(inds1)=wave(inds1) ./ hfactot(inds1);
0168 saltave(inds1)=saltave(inds1) ./ hfactot(inds1);
0169 phiave(inds1)=phiave(inds1) ./ hfactot(inds1);
0170 %
0171 inds2=find(hfacztot1~=0);
0172 thetazav(inds2)=thetazav(inds2) ./ hfacztot1(inds2);
0173 uzav(inds2)=uzav(inds2) ./ hfacztot1(inds2);
0174 vzav(inds2)=vzav(inds2) ./ hfacztot1(inds2);
0175 wzav(inds2)=wzav(inds2) ./ hfacztot1(inds2);
0176 saltzav(inds2)=saltzav(inds2) ./ hfacztot1(inds2);
0177 phizav(inds2)=phizav(inds2) ./ hfacztot1(inds2);
0178 usqz(inds2)=usqz(inds2) ./ hfacztot2(inds2);
0179 vsqz(inds2)=vsqz(inds2) ./ hfacztot2(inds2);
0180 thetasqz(inds2)=thetasqz(inds2) ./ hfacztot2(inds2);
0181 phisqz(inds2)=phisqz(inds2) ./ hfacztot2(inds2);
0182 omegasqz(inds2)=omegasqz(inds2) ./ hfacztot2(inds2);
0183 qsqz(inds2)=qsqz(inds2) ./ hfacztot2(inds2);
0184 uvz(inds2)=uvz(inds2) ./ hfacztot2(inds2);
0185 uomegaz(inds2)=uomegaz(inds2) ./ hfacztot2(inds2);
0186 vomegaz(inds2)=vomegaz(inds2) ./ hfacztot2(inds2);
0187 vthetaz(inds2)=vthetaz(inds2) ./ hfacztot2(inds2);
0188 omegathetaz(inds2)=omegathetaz(inds2) ./ hfacztot2(inds2);
0189 vqz(inds2)=vqz(inds2) ./ hfacztot2(inds2);
0190 omegaqz(inds2)=omegaqz(inds2) ./ hfacztot2(inds2);
0191 vphiz(inds2)=vphiz(inds2) ./ hfacztot2(inds2);
0192 %
0193 inds3=find(hfacztot2~=0);
0194 UVtotz(inds3)=UVtotz(inds3) ./ hfacztot2(inds3);
0195 U2totz(inds3)=U2totz(inds3) ./ hfacztot2(inds3);
0196 V2totz(inds3)=V2totz(inds3) ./ hfacztot2(inds3);
0197 wvelsqz(inds3)=wvelsqz(inds3) ./ hfacztot2(inds3);
0198 potempsqz(inds3)=potempsqz(inds3) ./ hfacztot2(inds3);
0199 phihydsqz(inds3)=phihydsqz(inds3) ./ hfacztot2(inds3);
0200 saltsqz(inds3)=saltsqz(inds3) ./ hfacztot2(inds3);
0201 wuEz(inds3)=wuEz(inds3) ./ hfacztot2(inds3);
0202 wvNz(inds3)=wvNz(inds3) ./ hfacztot2(inds3);
0203 vNthz(inds3)=vNthz(inds3) ./ hfacztot2(inds3);
0204 wvelthz(inds3)=wvelthz(inds3) ./ hfacztot2(inds3);
0205 vNsltz(inds3)=vNsltz(inds3) ./ hfacztot2(inds3);
0206 wvelsltz(inds3)=wvelsltz(inds3) ./ hfacztot2(inds3);
0207 vNphiz(inds3)=vNphiz(inds3) ./ hfacztot2(inds3);
0208 %
0209 % To do after leafing through all the 10-day segments:
0210 % Stationary Mean:
0211 % 1a) Compute products of time mean zonal mean first moments
0212 smusq = uzav.*uzav;
0213 smvsq = vzav.*vzav;
0214 smtsq = thetazav.*thetazav;
0215 smwsq = wzav.*wzav;
0216 smphisq = phizav.*phizav;
0217 smqsq = saltzav.*saltzav;
0218 smuv = uzav.*vzav;
0219 smuw = uzav.*wzav;
0220 smvw = vzav.*wzav;
0221 smvt = vzav.*thetazav;
0222 smwt = wzav.*thetazav;
0223 smvq = vzav.*saltzav;
0224 smwq = wzav.*saltzav;
0225 smvphi = vzav.*phizav;
0226 %
0227 % Transient Mean: Time mean of products of zonal mean first moments minus Stationary Mean
0228 tmusq = usqz - smusq;
0229 tmvsq = vsqz - smvsq;
0230 tmtsq = thetasqz - smtsq;
0231 tmwsq = omegasqz - smwsq;
0232 tmphisq = phisqz - smphisq;
0233 tmqsq = qsqz - smqsq;
0234 tmuv = uvz - smuv;
0235 tmuw = uomegaz - smuw;
0236 tmvw = vomegaz - smvw;
0237 tmvt = vthetaz - smvt;
0238 tmwt = omegathetaz - smwt;
0239 tmvq = vqz - smvq;
0240 tmwq = omegaqz - smwq;
0241 tmvphi = vphiz - smvphi;
0242 %
0243 % Stationary Eddy:
0244 % 2a) Compute products of time mean first moments
0245 % 2b) Compute zonal mean of products of time mean first moments
0246 % 2c) Compute SE as zonal mean of products of time mean first moments minus stationary mean
0247 hfac4calcz = hfactot ./ nsegments;
0248 [uEave,vNave] = rotate_uv2uvEN(uave,vave,AngleCS,AngleSN);
0249 temp=uEave.*uEave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);seusq=tempZ(:,:,1)-smusq;
0250 temp=vNave.*vNave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sevsq=tempZ(:,:,1)-smvsq;
0251 temp=thetaave.*thetaave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);setsq=tempZ(:,:,1)-smtsq;
0252 temp=wave.*wave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sewsq=tempZ(:,:,1)-smwsq;
0253 temp=phiave.*phiave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sephisq=tempZ(:,:,1)-smphisq;
0254 temp=saltave.*saltave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);seqsq=tempZ(:,:,1)-smqsq;
0255 temp=uEave.*vNave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);seuv=tempZ(:,:,1)-smuv;
0256 temp=uEave.*wave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);seuw=tempZ(:,:,1)-smuw;
0257 temp=vNave.*wave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sevw=tempZ(:,:,1)-smvw;
0258 temp=vNave.*thetaave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sevt=tempZ(:,:,1)-smvt;
0259 temp=wave.*thetaave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sewt=tempZ(:,:,1)-smwt;
0260 temp=vNave.*saltave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sevq=tempZ(:,:,1)-smvq;
0261 temp=wave.*saltave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sewq=tempZ(:,:,1)-smwq;
0262 temp=vNave.*phiave;[tempZ,dum1,dum2]=calc_ZonAv_CS(temp,1,1,0,XC,YC,XG,YG,RAC,'./',hfac4calcz);sevphi=tempZ(:,:,1)-smvphi;
0263 %
0264 % Transient Eddy: Time mean of zonal mean second moments minus Transient Mean minus Stationary Eddy
0265 teusq = U2totz - usqz - seusq;
0266 tevsq = V2totz - vsqz - sevsq;
0267 tetsq = potempsqz - thetasqz - setsq;
0268 tewsq = wvelsqz - omegasqz - sewsq;
0269 tephisq = phihydsqz - phisqz - sephisq;
0270 teqsq = saltsqz - qsqz - seqsq;
0271 teuv = UVtotz - uvz - seuv;
0272 teuw = wuEz - uomegaz - seuw;
0273 tevw = wvNz - vomegaz - sevw;
0274 tevt = vNthz - vthetaz - sevt;
0275 tewt = wvelthz - omegathetaz - sewt;
0276 tevq = vNsltz - vqz - sevq;
0277 tewq = wvelsltz - omegaqz - sewq;
0278 tevphi = vNphiz - vphiz - sevphi;
0279 %
0280 % Write out all the terms
0281 eval(['cd mnc_out_processed'])
0282 %
0283 % Total:
0284 fid = fopen('uvtotz.bin','w','b'); UVtotz(find(isnan(UVtotz)))=undef; fwrite(fid,UVtotz,'real*8'); fclose(fid);
0285 fid = fopen('u2totz.bin','w','b'); U2totz(find(isnan(U2totz)))=undef; fwrite(fid,U2totz,'real*8'); fclose(fid);
0286 fid = fopen('v2totz.bin','w','b'); V2totz(find(isnan(V2totz)))=undef; fwrite(fid,V2totz,'real*8'); fclose(fid);
0287 fid = fopen('wvelsqz.bin','w','b'); wvelsqz(find(isnan(wvelsqz)))=undef; fwrite(fid,wvelsqz,'real*8'); fclose(fid);
0288 fid = fopen('potempsqz.bin','w','b'); potempsqz(find(isnan(potempsqz)))=undef; fwrite(fid,potempsqz,'real*8'); fclose(fid);
0289 fid = fopen('phihydsqz.bin','w','b'); phihydsqz(find(isnan(phihydsqz)))=undef; fwrite(fid,phihydsqz,'real*8'); fclose(fid);
0290 fid = fopen('saltsqz.bin','w','b'); saltsqz(find(isnan(saltsqz)))=undef; fwrite(fid,saltsqz,'real*8'); fclose(fid);
0291 fid = fopen('wuEz.bin','w','b'); wuEz(find(isnan(wuEz)))=undef; fwrite(fid,wuEz,'real*8'); fclose(fid);
0292 fid = fopen('wvNz.bin','w','b'); wvNz(find(isnan(wvNz)))=undef; fwrite(fid,wvNz,'real*8'); fclose(fid);
0293 fid = fopen('vNthz.bin','w','b'); vNthz(find(isnan(vNthz)))=undef; fwrite(fid,vNthz,'real*8'); fclose(fid);
0294 fid = fopen('wvelthz.bin','w','b'); wvelthz(find(isnan(wvelthz)))=undef; fwrite(fid,wvelthz,'real*8'); fclose(fid);
0295 fid = fopen('vNsltz.bin','w','b'); vNsltz(find(isnan(vNsltz)))=undef; fwrite(fid,vNsltz,'real*8'); fclose(fid);
0296 fid = fopen('wvelsltz.bin','w','b'); wvelsltz(find(isnan(wvelsltz)))=undef; fwrite(fid,wvelsltz,'real*8'); fclose(fid);
0297 fid = fopen('vNphiz.bin','w','b'); vNphiz(find(isnan(vNphiz)))=undef; fwrite(fid,vNphiz,'real*8'); fclose(fid);
0298 %
0299 % Some additional filtering to set some inconsistent values to undefined
0300 %
0301 indusq = find(smusq>U2totz); smusq(indusq)=undef;seusq(indusq)=undef;tmusq(indusq)=undef;teusq(indusq)=undef;
0302 indvsq = find(smvsq>V2totz); smvsq(indvsq)=undef;sevsq(indvsq)=undef;tmvsq(indvsq)=undef;tevsq(indvsq)=undef;
0303 indwsq = find(smwsq>wvelsqz); smwsq(indwsq)=undef;sewsq(indwsq)=undef;tmwsq(indwsq)=undef;tewsq(indwsq)=undef;
0304 indtsq = find(smtsq>potempsqz); smtsq(indtsq)=undef;setsq(indtsq)=undef;tmtsq(indtsq)=undef;tetsq(indtsq)=undef;
0305 indpsq = find(smphisq>phihydsqz); smphisq(indpsq)=undef;sephisq(indpsq)=undef;tmphisq(indpsq)=undef;tephisq(indpsq)=undef;
0306 indqsq = find(smqsq>saltsqz); smqsq(indqsq)=undef;seqsq(indqsq)=undef;tmqsq(indqsq)=undef;teqsq(indqsq)=undef;
0307 %
0308 % Stationary Mean:
0309 fid = fopen('smusq.bin','w','b'); smusq(find(isnan(smusq)))=undef; fwrite(fid,smusq,'real*8'); fclose(fid);
0310 fid = fopen('smvsq.bin','w','b'); smvsq(find(isnan(smvsq)))=undef; fwrite(fid,smvsq,'real*8'); fclose(fid);
0311 fid = fopen('smtsq.bin','w','b'); smtsq(find(isnan(smtsq)))=undef; fwrite(fid,smtsq,'real*8'); fclose(fid);
0312 fid = fopen('smwsq.bin','w','b'); smwsq(find(isnan(smwsq)))=undef; fwrite(fid,smwsq,'real*8'); fclose(fid);
0313 fid = fopen('smphisq.bin','w','b'); smphisq(find(isnan(smphisq)))=undef; fwrite(fid,smphisq,'real*8'); fclose(fid);
0314 fid = fopen('smqsq.bin','w','b'); smqsq(find(isnan(smqsq)))=undef; fwrite(fid,smqsq,'real*8'); fclose(fid);
0315 fid = fopen('smuv.bin','w','b'); smuv(find(isnan(smuv)))=undef; fwrite(fid,smuv,'real*8'); fclose(fid);
0316 fid = fopen('smuw.bin','w','b'); smuw(find(isnan(smuw)))=undef; fwrite(fid,smuw,'real*8'); fclose(fid);
0317 fid = fopen('smvw.bin','w','b'); smvw(find(isnan(smvw)))=undef; fwrite(fid,smvw,'real*8'); fclose(fid);
0318 fid = fopen('smvt.bin','w','b'); smvt(find(isnan(smvt)))=undef; fwrite(fid,smvt,'real*8'); fclose(fid);
0319 fid = fopen('smwt.bin','w','b'); smwt(find(isnan(smwt)))=undef; fwrite(fid,smwt,'real*8'); fclose(fid);
0320 fid = fopen('smvq.bin','w','b'); smvq(find(isnan(smvq)))=undef; fwrite(fid,smvq,'real*8'); fclose(fid);
0321 fid = fopen('smwq.bin','w','b'); smwq(find(isnan(smwq)))=undef; fwrite(fid,smwq,'real*8'); fclose(fid);
0322 fid = fopen('smvphi.bin','w','b'); smvphi(find(isnan(smvphi)))=undef; fwrite(fid,smvphi,'real*8'); fclose(fid);
0323 %
0324 % Stationary Eddy:
0325 fid = fopen('seusq.bin','w','b'); seusq(find(isnan(seusq)))=undef; fwrite(fid,seusq,'real*8'); fclose(fid);
0326 fid = fopen('sevsq.bin','w','b'); sevsq(find(isnan(sevsq)))=undef; fwrite(fid,sevsq,'real*8'); fclose(fid);
0327 fid = fopen('setsq.bin','w','b'); setsq(find(isnan(setsq)))=undef; fwrite(fid,setsq,'real*8'); fclose(fid);
0328 fid = fopen('sewsq.bin','w','b'); sewsq(find(isnan(sewsq)))=undef; fwrite(fid,sewsq,'real*8'); fclose(fid);
0329 fid = fopen('sephisq.bin','w','b'); sephisq(find(isnan(sephisq)))=undef; fwrite(fid,sephisq,'real*8'); fclose(fid);
0330 fid = fopen('seqsq.bin','w','b'); seqsq(find(isnan(seqsq)))=undef; fwrite(fid,seqsq,'real*8'); fclose(fid);
0331 fid = fopen('seuv.bin','w','b'); seuv(find(isnan(seuv)))=undef; fwrite(fid,seuv,'real*8'); fclose(fid);
0332 fid = fopen('seuw.bin','w','b'); seuw(find(isnan(seuw)))=undef; fwrite(fid,seuw,'real*8'); fclose(fid);
0333 fid = fopen('sevw.bin','w','b'); sevw(find(isnan(sevw)))=undef; fwrite(fid,sevw,'real*8'); fclose(fid);
0334 fid = fopen('sevt.bin','w','b'); sevt(find(isnan(sevt)))=undef; fwrite(fid,sevt,'real*8'); fclose(fid);
0335 fid = fopen('sewt.bin','w','b'); sewt(find(isnan(sewt)))=undef; fwrite(fid,sewt,'real*8'); fclose(fid);
0336 fid = fopen('sevq.bin','w','b'); sevq(find(isnan(sevq)))=undef; fwrite(fid,sevq,'real*8'); fclose(fid);
0337 fid = fopen('sewq.bin','w','b'); sewq(find(isnan(sewq)))=undef; fwrite(fid,sewq,'real*8'); fclose(fid);
0338 fid = fopen('sevphi.bin','w','b'); sevphi(find(isnan(sevphi)))=undef; fwrite(fid,sevphi,'real*8'); fclose(fid);
0339 %
0340 % Transient Mean:
0341 fid = fopen('tmusq.bin','w','b'); tmusq(find(isnan(tmusq)))=undef; fwrite(fid,tmusq,'real*8'); fclose(fid);
0342 fid = fopen('tmvsq.bin','w','b'); tmvsq(find(isnan(tmvsq)))=undef; fwrite(fid,tmvsq,'real*8'); fclose(fid);
0343 fid = fopen('tmtsq.bin','w','b'); tmtsq(find(isnan(tmtsq)))=undef; fwrite(fid,tmtsq,'real*8'); fclose(fid);
0344 fid = fopen('tmwsq.bin','w','b'); tmwsq(find(isnan(tmwsq)))=undef; fwrite(fid,tmwsq,'real*8'); fclose(fid);
0345 fid = fopen('tmphisq.bin','w','b'); tmphisq(find(isnan(tmphisq)))=undef; fwrite(fid,tmphisq,'real*8'); fclose(fid);
0346 fid = fopen('tmqsq.bin','w','b'); tmqsq(find(isnan(tmqsq)))=undef; fwrite(fid,tmqsq,'real*8'); fclose(fid);
0347 fid = fopen('tmuv.bin','w','b'); tmuv(find(isnan(tmuv)))=undef; fwrite(fid,tmuv,'real*8'); fclose(fid);
0348 fid = fopen('tmuw.bin','w','b'); tmuw(find(isnan(tmuw)))=undef; fwrite(fid,tmuw,'real*8'); fclose(fid);
0349 fid = fopen('tmvw.bin','w','b'); tmvw(find(isnan(tmvw)))=undef; fwrite(fid,tmvw,'real*8'); fclose(fid);
0350 fid = fopen('tmvt.bin','w','b'); tmvt(find(isnan(tmvt)))=undef; fwrite(fid,tmvt,'real*8'); fclose(fid);
0351 fid = fopen('tmwt.bin','w','b'); tmwt(find(isnan(tmwt)))=undef; fwrite(fid,tmwt,'real*8'); fclose(fid);
0352 fid = fopen('tmvq.bin','w','b'); tmvq(find(isnan(tmvq)))=undef; fwrite(fid,tmvq,'real*8'); fclose(fid);
0353 fid = fopen('tmwq.bin','w','b'); tmwq(find(isnan(tmwq)))=undef; fwrite(fid,tmwq,'real*8'); fclose(fid);
0354 fid = fopen('tmvphi.bin','w','b'); tmvphi(find(isnan(tmvphi)))=undef; fwrite(fid,tmvphi,'real*8'); fclose(fid);
0355 %
0356 % Transient Eddy:
0357 fid = fopen('teusq.bin','w','b'); teusq(find(isnan(teusq)))=undef; fwrite(fid,teusq,'real*8'); fclose(fid);
0358 fid = fopen('tevsq.bin','w','b'); tevsq(find(isnan(tevsq)))=undef; fwrite(fid,tevsq,'real*8'); fclose(fid);
0359 fid = fopen('tetsq.bin','w','b'); tetsq(find(isnan(tetsq)))=undef; fwrite(fid,tetsq,'real*8'); fclose(fid);
0360 fid = fopen('tewsq.bin','w','b'); tewsq(find(isnan(tewsq)))=undef; fwrite(fid,tewsq,'real*8'); fclose(fid);
0361 fid = fopen('tephisq.bin','w','b'); tephisq(find(isnan(tephisq)))=undef; fwrite(fid,tephisq,'real*8'); fclose(fid);
0362 fid = fopen('teqsq.bin','w','b'); teqsq(find(isnan(teqsq)))=undef; fwrite(fid,teqsq,'real*8'); fclose(fid);
0363 fid = fopen('teuv.bin','w','b'); teuv(find(isnan(teuv)))=undef; fwrite(fid,teuv,'real*8'); fclose(fid);
0364 fid = fopen('teuw.bin','w','b'); teuw(find(isnan(teuw)))=undef; fwrite(fid,teuw,'real*8'); fclose(fid);
0365 fid = fopen('tevw.bin','w','b'); tevw(find(isnan(tevw)))=undef; fwrite(fid,tevw,'real*8'); fclose(fid);
0366 fid = fopen('tevt.bin','w','b'); tevt(find(isnan(tevt)))=undef; fwrite(fid,tevt,'real*8'); fclose(fid);
0367 fid = fopen('tewt.bin','w','b'); tewt(find(isnan(tewt)))=undef; fwrite(fid,tewt,'real*8'); fclose(fid);
0368 fid = fopen('tevq.bin','w','b'); tevq(find(isnan(tevq)))=undef; fwrite(fid,tevq,'real*8'); fclose(fid);
0369 fid = fopen('tewq.bin','w','b'); tewq(find(isnan(tewq)))=undef; fwrite(fid,tewq,'real*8'); fclose(fid);
0370 fid = fopen('tevphi.bin','w','b'); tevphi(find(isnan(tevphi)))=undef; fwrite(fid,tevphi,'real*8'); fclose(fid);
0371 %