Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/longitude.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
ca96c02aee Alis*0001 function [X] = longitude(x)
                0002 % X=longitude(x);
                0003 %
                0004 % tries to determine best range of longitude (e.g. -180<180 or 0<360)
                0005 % so that coordinate (x) doesn't span a discontinuity.
                0006 %
                0007 
                0008 % also works for radians which are assumed if range of x<=2*pi
                0009 
                0010 minx=min(min(min(x)));
                0011 maxx=max(max(max(x)));
                0012 %if maxx-minx < 2.2*pi
                0013 % units=180/pi;
                0014 %else
                0015  units=1;
                0016 %end
                0017 minx=min(min(min(x*units)));
                0018 maxx=max(max(max(x*units)));
                0019 
                0020 X=mod(720+x*units,360);
                0021 maxP=max(max(max(X)));
                0022 minP=min(min(min(X)));
                0023 
                0024 XX=mod(X+180,360)-180;
                0025 maxM=max(max(max(XX)));
                0026 minM=min(min(min(XX)));
                0027 
                0028 if maxP-minP > maxM-minM
                0029  X=XX;
                0030 end