/[MITgcm]/MITgcm_contrib/high_res_cube/matlab-grid-generator/map_xyz2lonlat.m
ViewVC logotype

Annotation of /MITgcm_contrib/high_res_cube/matlab-grid-generator/map_xyz2lonlat.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Tue Nov 11 18:08:08 2003 UTC (21 years, 8 months ago) by cnh
Branch point for: MAIN, initial
Initial revision

1 cnh 1.1 function [lon,lat]=map_xyz2lonlat(x,y,z)
2     % Convert 3-D coordinates [x,y,z] to [lon,lat]
3     %
4     % Assumes "lat" is positive with "z", equatorial plane
5     % falls at z=0 and "lon" is measured anti-clockwise (eastward)
6     % from x-axis (y=0) about z-axis.
7    
8     % Latitude
9     Req=sqrt( x.^2 + y.^2 );
10     Z=z;
11     ii=find(Req == 0);
12     Z(ii)=Z(ii)*Inf;
13     Req(ii)=1;
14     lat=atan( Z ./ Req );
15    
16     % Longitude
17     X=x;
18     Y=y;
19     ii=find(x == 0);
20     Y(ii)=Inf;
21     X(ii)=1;
22     lon=atan( Y ./ X );
23    
24     ii=find(x<0 & y>=0);
25     lon(ii)=pi+lon(ii);
26     ii=find(x<=0 & y<0);
27     lon(ii)=-pi+lon(ii);

  ViewVC Help
Powered by ViewVC 1.1.22