/[MITgcm]/MITgcm_contrib/netcdf_matlab_examples/latlon_2d/EH3_notes_latlon_2d.txt
ViewVC logotype

Contents of /MITgcm_contrib/netcdf_matlab_examples/latlon_2d/EH3_notes_latlon_2d.txt

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


Revision 1.1 - (show annotations) (download)
Sat Jan 3 19:46:51 2004 UTC (20 years, 3 months ago) by edhill
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
 o notes about Ingrid's "X", "Y" variable naming oddities
 o add the latlon_2d example of non-lat-lon-aligned grids
 o add simple worldbath example

1 %
2 % Ed Hill
3 % Fri Dec 12 12:09:00 EST 2003
4
5 % Test Ingrid's ability to handle 2D lat-lon grids
6
7 matlab -nojvm
8 clear all
9
10 theta = 15 * pi/180;
11 rot = [ -sin(theta) cos(theta) ; cos(theta) sin(theta) ];
12 nx = 11; lats = [ -30 30 ];
13 ny = 21; lons = [ -30 30 ];
14 lat = zeros(nx,ny);
15 lon = zeros(nx,ny);
16 val = zeros(nx,ny);
17 for i = 1:nx,
18 for j = 1:ny,
19 p(1) = lons(1) + (i-1)*(lons(2)-lons(1))/(nx-1);
20 p(2) = lats(1) + (j-1)*(lats(2)-lats(1))/(ny-1);
21 pr = rot * p';
22 lat(i,j) = pr(1);
23 lon(i,j) = pr(2);
24 val(i,j) = norm(pr);
25 end
26 end
27
28 mesh(lat,lon,val), view(2), axis equal
29 surf(lat,lon,val), view(2), axis equal, shading interp
30
31 idv = 'concentration';
32 idlat = 'lat';
33 idlon = 'lon';
34 units = 'g/m^3';
35
36 desc = [ 'Test of 2D lat-lon grids in Ingrid.' ];
37 ncname = [ 'test_2d.nc' ];
38 nc = netcdf(ncname, 'clobber');
39 nc.reference = desc;
40 nc.author = 'Ed Hill <eh3@mit.edu>';
41 nc.date = 'Dec 30, 2003';
42 nc('X') = nx;
43 nc('Y') = ny;
44 nc{'X'} = 'X';
45 nc{'Y'} = 'Y';
46 nc{ idlon } = { 'Y', 'X' };
47 nc{ idlat } = { 'Y', 'X' };
48 nc{ idv } = { 'Y', 'X' };
49 nc{'X'}.uniquename = 'X';
50 nc{'Y'}.uniquename = 'Y';
51 nc{ idlon }.units = 'degree_east';
52 nc{ idlon }.long_name = 'longitude';
53 nc{ idlat }.units = 'degree_north';
54 nc{ idlat }.long_name = 'latitude';
55 nc{ idv }.units = units;
56 nc{ idv }.coordinates = 'lat lon';
57 nc{ idv }.long_name = idv;
58 nc{ idv }.missing_value = ncdouble(NaN);
59 nc{ idv }.FillValue_ = ncdouble(0.);
60 nc{'X'}(:) = [1:nx];
61 nc{'Y'}(:) = [1:ny];
62 nc{ idlon }(:) = lon';
63 nc{ idlat }(:) = lat';
64 nc{ idv }(:) = val';
65 nc = close(nc);
66
67 ! scp ./test_2d.nc channel.mit.edu:/home/edhill/test_2d/
68
69 % as edhill on channel.mit.edu :
70 mkdir test_2d
71
72 % AS ROOT ON channel.mit.edu :
73 cd /home/benno/ingrid/data/MIT/LOCAL/PEOPLE/EH3
74 mkdir test_2d
75 cd test_2d
76 ln -s /home/edhill/test_2d/* .
77
78
79
80 % ;;; Local Variables: ***
81 % ;;; mode:matlab ***
82 % ;;; End: ***

  ViewVC Help
Powered by ViewVC 1.1.22