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

Contents of /MITgcm_contrib/high_res_cube/matlab-grid-generator/map_xy2xyz.m

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


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Nov 11 18:08:08 2003 UTC (20 years, 9 months ago) by cnh
Branch: MAIN, initial
CVS Tags: baseline, HEAD
Changes since 1.1: +0 -0 lines
Checking in work done with Dimitri on high-resolution cube gridding and parallel 
communications. 
   o code is in a contrib experiment for now so we can continue collaborating
     on it. However most code is general and will be moved into main branch once 
     it is fully hardened.
   o There are README files in the contrib root and in the subdirectories that
     explain the contents

1 function [X,Y,Z] = cmap_xy2xyz(x,y);
2 % Conformal mapping of a cube onto a sphere
3 % maps (x,y) on the north-pole face of a cube
4 % to (X,Y,Z) coordinates in physical space
5 %
6 % Based on f77 code from Jim Purser & Misha Rancic.
7 %
8 % Face is oriented normal to Z-axis with
9 % X and Y increasing with x and y
10 %
11 % valid ranges: -1 < x < 1 -1 < y < 1
12
13 if size(x) ~= size(y)
14 error('Arguments x,y should be same size');
15 end
16
17 xc=abs(x);
18 yc=abs(y);
19
20 kx=find(x<0);
21 ky=find(y<0);
22 kxy=find(yc>xc);
23
24 X=xc;
25 Y=yc;
26 xc=1-xc;
27 yc=1-yc;
28 xc(kxy)=1-Y(kxy);
29 yc(kxy)=1-X(kxy);
30
31 z=((xc+i*yc)/2).^4;
32 W=WofZ(z);
33
34 thrd=1/3;
35 i3=i^thrd;
36 ra=sqrt(3)-1;
37 cb=i-1;
38 cc=ra*cb/2;
39
40 W=i3*(W*i).^thrd;
41 W=(W-ra)./(cb+cc*W);
42 X=real(W);
43 Y=imag(W);
44 H=2./(1+X.^2+Y.^2);
45 X=X.*H;
46 Y=Y.*H;
47 Z=H-1;
48
49 T=X;
50 X(kxy)=Y(kxy);
51 Y(kxy)=T(kxy);
52
53 Y(ky)=-Y(ky);
54 X(kx)=-X(kx);
55
56 % Fix truncation for x=0 or y=0 (aja)
57 X(find(x==0))=0;
58 Y(find(y==0))=0;
59
60 function [w] = WofZ(z);
61 % evaluates the Taylor series W(z)
62
63 A=Acoeffs;
64
65 w=0;
66 for j=30:-1:1,
67 w=(w+A(j)).*z;
68 end
69 stats(abs(z))
70
71 function [A] = Acoeffs;
72 % Taylor coefficients for W(z)
73 %aja changed -0.00895884801823 to -0.01895884801823 (coeff #4)
74 A=[1.47713057321600
75 -0.38183513110512
76 -0.05573055466344
77 -0.01895884801823
78 -0.00791314396396
79 -0.00486626515498
80 -0.00329250387158
81 -0.00235482619663
82 -0.00175869000970
83 -0.00135682443774
84 -0.00107458043205
85 -0.00086946107050
86 -0.00071604933286
87 -0.00059869243613
88 -0.00050696402446
89 -0.00043418115349
90 -0.00037537743098
91 -0.00032745130951
92 -0.00028769063795
93 -0.00025464473946
94 -0.00022659577923
95 -0.00020297175587
96 -0.00018247947703
97 -0.00016510295548
98 -0.00014967258633
99 -0.00013660647356
100 -0.00012466390509
101 -0.00011468147908
102 -0.00010518717478
103 -0.00009749136078
104 ];
105
106 function [B] = Bcoeffs
107 % Taylor coefficients for Z(w)
108 B=[0.67698822171341
109 0.11847295533659
110 0.05317179075349
111 0.02965811274764
112 0.01912447871071
113 0.01342566129383
114 0.00998873721022
115 0.00774869352561
116 0.00620347278164
117 0.00509011141874
118 0.00425981415542
119 0.00362309163280
120 0.00312341651697
121 0.00272361113245
122 0.00239838233411
123 0.00213002038153
124 0.00190581436893
125 0.00171644267546
126 0.00155493871562
127 0.00141600812949
128 0.00129556691848
129 0.00119042232809
130 0.00109804804853
131 0.00101642312253
132 0.00094391466713
133 0.00087919127990
134 0.00082115825576
135 0.00076890854394
136 0.00072168520663
137 0.00067885239089
138 ];

  ViewVC Help
Powered by ViewVC 1.1.22