%at the edges of the domain there are stupid values in the overlaps %for the curvilinear grid option (as used by Ian) and we overwrite them %with the neighboring point (actucally inside the domain) long and lat %=> overwrites profilesXCincl1PointOverlap* and profilesYCincl1PointOverlap* dXC = dir('profilesXCincl1PointOverlap*') dYC = dir('profilesYCincl1PointOverlap*') plotthese = 0; for i = 1:size(dXC,1) %for i = 1:1 fxc = dXC(i).name fyc = dYC(i).name sx = str2num(fxc(end-13:end-10)) sy = str2num(fyc(end-8:end-5)) fid = fopen(dXC(i).name,'r','b'); fXC = fread(fid,'float64'); fclose(fid); fid = fopen(dYC(i).name,'r','b'); fYC = fread(fid,'float64'); fclose(fid); fXC = reshape(fXC,[sx+2, sy+2]); fXCo = fXC; fYC = reshape(fYC,[sx+2, sy+2]); fYCo = fYC; if (abs(fXC(2,1) - fXC(2,2)) > 1) fXC(:,1) = fXC(:,2); fYC(:,1) = fYC(:,2); fXC(1,1) = fXC(2,2); fYC(1,1) = fYC(2,2); end if (abs(fXC(2,end) - fXC(2,end-1)) > 1) fXC(:,end) = fXC(:,end-1); fYC(:,end) = fYC(:,end-1); fXC(1,end) = fXC(2,end-1); fYC(1,end) = fYC(2,end-1); end if (abs(fYC(1,2) - fYC(2,2)) > 1) fXC(1,:) = fXC(2,:); fYC(1,:) = fYC(2,:); end if (abs(fYC(end,2) - fYC(end-1,2)) > 1) fXC(end,:) = fXC(end-1,:); fYC(end,:) = fYC(end-1,:); end if plotthese figure(i); subplot(2,2,1); imagesc(fXCo); subplot(2,2,2); imagesc(fXC); subplot(2,2,3); imagesc(fYCo); subplot(2,2,4); imagesc(fYC); else fid = fopen(dXC(i).name,'w','b'); fXC = fwrite(fid,fXC,'float64'); fclose(fid); fid = fopen(dYC(i).name,'w','b'); fYC = fwrite(fid,fYC,'float64'); fclose(fid); end end