1 |
gforget |
1.1 |
function [x_out]=netcdf_ecco_GenericgridRotateLon(x_in,lon0_in,lon0_out,lonSyst); |
2 |
|
|
|
3 |
|
|
%lonSyst=1: we use degree east from greenwich |
4 |
|
|
%lonSyst=2: we use degree east/west from greenwich |
5 |
|
|
|
6 |
|
|
%-this routine first set longitude according to lonSyst |
7 |
|
|
%and then change the 0 longitude from lon0_in to lon0_out |
8 |
|
|
%-input: lon0_in is the current 0 longitude, in degree east from greenwich |
9 |
|
|
% lon0_out is the new 0 longitude, in degree east from greenwich |
10 |
|
|
% x_in is longitude relative to lon0_in |
11 |
|
|
%output: x_out is longitude relative to lon0_out |
12 |
|
|
|
13 |
|
|
if lonSyst==2 |
14 |
|
|
tmp1=find(x_in>=180); x_in(tmp1)=x_in(tmp1)-360; |
15 |
|
|
tmp1=find(x_in<-180); x_in(tmp1)=x_in(tmp1)+360; |
16 |
|
|
elseif lonSyst==1 |
17 |
|
|
tmp1=find(x_in<0); x_in(tmp1)=x_in(tmp1)+360; |
18 |
|
|
tmp1=find(x_in>=360); x_in(tmp1)=x_in(tmp1)-360; |
19 |
|
|
else |
20 |
|
|
fprintf('lonSyst must be 1 or 2 => stop \n'); return; end; |
21 |
|
|
x_out=x_in-(lon0_out-lon0_in); |
22 |
|
|
if lonSyst==2 |
23 |
|
|
tmp1=find(x_out>=180); x_out(tmp1)=x_out(tmp1)-360; |
24 |
|
|
tmp1=find(x_out<-180); x_out(tmp1)=x_out(tmp1)+360; |
25 |
|
|
elseif lonSyst==1 |
26 |
|
|
tmp1=find(x_out<0); x_out(tmp1)=x_out(tmp1)+360; |
27 |
|
|
tmp1=find(x_out>=360); x_out(tmp1)=x_out(tmp1)-360; |
28 |
|
|
end |
29 |
|
|
|
30 |
|
|
|