Mentions légales du service

Skip to content
Snippets Groups Projects
Commit d8d427ee authored by Gildas Cambon's avatar Gildas Cambon
Browse files

RIVERS : bug fixes + cosmetics

- bug fixes in the runoff positionning
- cleaning and cosmetics
parent 54d83443
No related branches found
No related tags found
No related merge requests found
function [j2,i2]=locate_runoff(dir,j,i,mask,masku,maskv)
%
function [j2for_out,i2for_out, j2for,i2for,j2,i2]=locate_runoff(dir,j,i,mask,masku,maskv)
%=======================================================================================================
% input :
% j,i : first guess river position
% dir : direction and sense of the flow
%
% output :
% j2,i2 : index position (eta, xi) at rho-point for runoff, in matlab convention
% in MATLAB, rho, u and v indexing start at 1 !
%
% MATLAB
% |-------- v(i,j) -------|
% | |
% | |
% u(i-1,j) r(i,j) u(i,j)
% | |
% | |
% |-------- v(i,j-1) -----|
%
% j2for, i2for : index position (eta, xi) at rho-point for runoff, in CROCO convention
% in CROCO fortran, rho start at 0, u and v indexing start at 1 !,
%
% zero index is a ghost cell, with no staggerd u-point on right and v point below
%
%
% CROCO fortran
% |-------- v(i,j+1) -----|
% | |
% | |
% u(i,j) r(i,j) u(i+1,j)
% | |
% | |
% |-------- v(i,j) -------|
%
% j2for_out, i2for_out : index for runoff positions, at u and v cells, in CROCO fortran index convention.
% i- and j- are of the u or v cells that are flowing into the target wet cell
%
% It is computed depending :
% - the runoff direction (zonal=0, meridian=1)
% - the sense (east-west/south-north =1 ; west-east/north-south =-1
% - the landmask around ...
%
%=======================================================================================================
if mask(j,i)==1
disp('River positionned in sea')
insea=1;
......@@ -12,76 +50,119 @@ else
end
if dir(1)==0
if insea
if dir(2)==-1 %est - west => TESTED
while masku(j,i)==1
i=i+1;
%disp(['MASKU:',num2str(masku(j,i))])
end
%disp(['--'])
%disp(['MASKU:',num2str(masku(j,i))])
elseif dir(2)==1 % west - est => TESTED
while masku(j,i)==1
if dir(2)==1 % >> : west - east => TESTED
while mask(j,i) == 1
i=i-1;
%disp(['MASKU:',num2str(masku(j,i))])
disp(['MASK:',num2str(mask(j,i))])
end
disp(['--'])
disp(['MASK:',num2str(mask(j,i))])
disp(['MASKU:',num2str(masku(j,i))])
elseif dir(2)==-1 % << : east - west => TESTED
while mask(j,i) == 1
i=i+1;
disp(['MASK:',num2str(mask(j,i))])
end
%disp(['--'])
%disp(['MASKU:',num2str(masku(j,i))])
%in this case add +1 in i to get back into last wet cell
j=j+1;
disp(['--'])
disp(['MASK:',num2str(mask(j,i))])
disp(['MASKU:',num2str(masku(j,i))])
end
else %inland
if dir(2)==1 %west-est => TESTED
while masku(j,i)~=1
if dir(2) == 1 % >> : west-est => TESTED
while mask(j,i) ~= 1
i=i+1;
%disp(['MASKU:',num2str(masku(j,i))])
disp(['MASK:',num2str(mask(j,i))])
end
disp(['--'])
i=i-1
%disp(['MASK:',num2str(masku(j,i))])
elseif dir(2)==-1 %est-west => TESTED
while masku(j,i)~=1
disp(['MASK:',num2str(mask(j,i))])
disp(['MASKU:',num2str(masku(j,i))])
elseif dir(2) == -1 % << : east-west => TESTED
while mask(j,i) ~= 1
i=i-1;
%disp(['MASKU:',num2str(masku(j,i))])
disp(['MASK:',num2str(mask(j,i))])
end
%disp(['--'])
i=i+1;
%disp(['MASKU:',num2str(masku(j,i))])
disp(['--'])
disp(['MASK:',num2str(mask(j,i))])
disp(['MASKU:',num2str(masku(j,i))])
end
end
else %dir(k,1)=1
if insea
if dir(2)==-1 % nord - sud => TESTED
while maskv(j,i)==1
j=j+1;
%disp(['MASKV:',num2str(maskv(j,i))])
end
%disp(['--'])
%disp(['MASKV:',num2str(maskv(j,i))])
elseif dir(2)==1 % sud - nord => TESTED
while maskv(j,i)==1
if dir(2) == 1 % ^ : sud - nord => TESTED
while mask(j,i) == 1
j=j-1;
%disp(['MASKV:',num2str(maskv(j,i))])
disp(['MASK:',num2str(mask(j,i))])
end
%disp(['--'])
%disp(['MASKV:',num2str(maskv(j,i))])
%in this case add +1 in j to get back into last wet cell
j=j+1;
%
disp(['-- ^^ start insea'])
disp(['MASK:',num2str(mask(j,i))])
disp(['MASKV:',num2str(maskv(j,i))])
elseif dir(2) == -1 % v : nord - sud => TESTED
while mask(j,i) == 1
j=j+1;
disp(['MASK:',num2str(mask(j,i))])
end
disp(['--'])
disp(['MASK:',num2str(mask(j,i))])
disp(['MASKV:',num2str(maskv(j,i))])
end
else %inland
if dir(2)==1 %sud-nord => TESTED
while maskv(j,i)~=1
if dir(2) == 1 % ^: sud-nord => TESTED
while mask(j,i) ~= 1
j=j+1;
%disp(['MASKV:',num2str(maskv(j,i))])
disp(['MASK:',num2str(mask(j,i))])
end
%disp(['--'])
j=j-1;
%disp(['MASKV:',num2str(maskv(j,i))])
elseif dir(2)==-1 %nord-sud => TESTED
while maskv(j,i)~=1
disp(['--^^ start inland'])
disp(['MASK:',num2str(mask(j,i))])
disp(['MASKV:',num2str(maskv(j,i))])
elseif dir(2) == -1 % v : nord-sud => TESTED
while mask(j,i) ~= 1
j=j-1;
%disp(['MASKV:',num2str(maskv(j,i))])
disp(['MASK:',num2str(mask(j,i))])
end
%disp(['--'])
j=j+1;
%disp(['MASKV:',num2str(maskv(j,i))])
disp(['--'])
disp(['MASK:',num2str(mask(j,i))])
disp(['MASKV:',num2str(maskv(j,i))])
end
end
end
% from matlab to roms index convention
j2=j; i2=i;
j2for=j-1; i2for=i-1;
% regarding the flow direction, sense and landmask surrounding
% -- toward west >>
if ( dir(1) == 0 & dir(2) == 1 ) ;
j2for_out = j2for ;
i2for_out = i2for ;
end
% -- toward est <<
if ( dir(1) == 0 & dir(2) == -1 );
j2for_out = j2for ;
i2for_out = i2for + 1 ;
end
% -- toward north ^^
if ( dir(1) == 1 & dir(2) == 1 );
j2for_out = j2for ;
i2for_out = i2for ;
end
% -- toward south vv
if ( dir(1) == 1 & dir(2) == -1 );
j2for_out = j2for + 1 ;
i2for_out = i2for ;
end
% j2mat_out is equal to j2for_out
% i2mat_out is equal to j2for_out % I think ...
% j2mat_out = j2for_out
% i2mat_out = i2for_out
return
This diff is collapsed.
......@@ -42,12 +42,9 @@ close(ncriv)
maxmaxflow=(max(max(FLOW_clm)));
maxflow=(max(FLOW_clm)'); % attention transpose
meanflowmax=mean(FLOW_clm(:,1)); % pour amazon
meanflow=nanmean(FLOW_clm(:,:),1)'; % pour les autres
%size(meanflow)
%plot(meanflow)
%size(maxflow)
meanflowmax=mean(FLOW_clm(:,1)); % for the biggest
meanflow=nanmean(FLOW_clm(:,:),1)'; % for others
%
%==========================================================================================================
%% => by default : all rivers in the domain
......@@ -55,12 +52,18 @@ rivdetectype='DEFAULT';
my_riv=find(latriv_mou>=minlat & latriv_mou<=maxlat & lonriv_mou >= minlon & lonriv_mou <= maxlon);
%==
% => megatl : rivers in the boxes + max value >= 20%*max val of the flow amazonia peak)
%rivdetectype='MEGATL';
%thold=0.1;
%thold=0.03;
%my_riv=find(latriv_mou>=minlat & latriv_mou<=maxlat & lonriv_mou >= minlon & lonriv_mou <= maxlon & meanflow >= thold.*meanflowmax);
% % => arvor : rivers in the boxes + max value >= 20%*max val of the flow orinoco peak)
% rivdetectype='ARVOR';
% %thold=0.1;
% thold=0.03;
% my_riv=find(latriv_mou>=minlat & latriv_mou<=maxlat & lonriv_mou >= minlon & lonriv_mou <= maxlon & meanflow >= thold.*meanflowmax);
%========================================
%
disp(['There are ',num2str(length(my_riv)),' rivers in the domain : '])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment