Skip to content

Commit

Permalink
md
Browse files Browse the repository at this point in the history
Merge branch 'TINY2'
  • Loading branch information
jiggyjig committed May 27, 2014
2 parents 6fa08f2 + df2b059 commit 4061362
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
64 changes: 64 additions & 0 deletions S06a_getMeanU.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
%%%%%%%%%
% Created: 08-Apr-2014 19:50:46
% Computer: GLNX86
% Matlab: 7.9
% Author: NK
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function S06a_getMeanU
%% init
DD=initialise;
%% find files
[file]=findVelFiles(DD);
%% get dims
[d,pos,dim]=getDims(file,DD);
%% means
means=getMeans(d,pos,dim,file,DD); %#ok<NASGU>
%% save
save([DD.path.meanU.file], 'means')
end
function means=getMeans(d,pos,dim,file,DD)
for kk=1:numel(file)
U(:,:,kk)=squeeze(nc_varget(file(1).U,'UVEL',dim.start,dim.length))/100; %#ok<*AGROW>
V(:,:,kk)=squeeze(nc_varget(file(1).V,'VVEL',dim.start,dim.length))/100;
end
U(U<-1e33)=nan; % missing values
V(V<-1e33)=nan; % missing values
means.zonal=nanmean(U,3);
means.merid=nanmean(V,3);
means.total=hypot(means.zonal,means.merid);
means.direc=azimuth(zeros(size(means.zonal)),zeros(size(means.zonal)),means.merid,means.zonal);
means.depth=d(pos.z.start);
%%
lin=extractfield(load(DD.path.protoMaps.file),'idx');
means.small.zonal=nan(DD.dim.Y,DD.dim.X);
for li=unique(lin(lin~=0 & ~isnan(lin)))
means.small.zonal(li)=nanmean(means.zonal(lin==li));
end

end
function [d,pos,dim]=getDims(file,DD)
dWanted=DD.parameters.depthRossby;
d=nc_varget(file(1).U,'depth_t');
[~,pos.z.start]=min(abs(d-dWanted));
pos.z.length=1;
pos.x.start=DD.map.window.limits.west;
pos.x.length=DD.map.window.size.X;
pos.y.start=DD.map.window.limits.south;
pos.y.length=DD.map.window.size.Y;
dim.start = [0 pos.z.start pos.y.start pos.x.start];
dim.length = [inf pos.z.length pos.y.length pos.x.length ];
end
function [file]=findVelFiles(DD)
%% find the U and V files
ucc=0; vcc=0;
for kk=1:numel(DD.path.TempSalt.files)
if ~isempty(strfind(DD.path.TempSalt.files(kk).name,'UVEL'))
ucc=ucc+1;
file(ucc).U=[DD.path.TempSalt.name DD.path.TempSalt.files(kk).name]; %#ok<AGROW>
end
if ~isempty(strfind(DD.path.TempSalt.files(kk).name,'VVEL'))
vcc=vcc+1;
file(vcc).V=[DD.path.TempSalt.name DD.path.TempSalt.files(kk).name]; %#ok<AGROW>
end
end
end
2 changes: 1 addition & 1 deletion S07_drawPlots.m
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function mapstuff(maps,vecs,DD,ticks,lo,la)
VV=maps.(sen).radius.toRo;
pcolor(lo,la,VV);shading flat
caxis([ticks.radiusToRo(1) ticks.radiusToRo(2)])
decorate('radiusToRo',ticks,DD,sen,'Radius/(2*L_R)',' ',1,1);
decorate('radiusToRo',ticks,DD,sen,'Radius/(2 L_R)',' ',1,1);
savefig(DD.path.plots,ticks.rez,ticks.width,ticks.height,[sen,'_MapRadToRo']);

end
Expand Down

0 comments on commit 4061362

Please sign in to comment.