/[MITgcm]/MITgcm_contrib/netcdf_matlab_examples/WOCE_climatology/EH3_notes_WOCE.txt
ViewVC logotype

Contents of /MITgcm_contrib/netcdf_matlab_examples/WOCE_climatology/EH3_notes_WOCE.txt

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


Revision 1.1 - (show annotations) (download)
Tue Feb 10 14:35:30 2004 UTC (20 years, 1 month ago) by edhill
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
 o initial check-in of WOCE netcdf example

1 %
2 % Ed Hill
3 % Fri Feb 6 13:00:31 EST 2004
4
5 % Convert WOCE climatology data (ASCII *.fld files) to NetCDF for
6 % inclusion within Ingrid.
7
8 %
9 % [ Edit the mine.f file slightly to create eh3_mine.f and then use it
10 % to create the "wghc????" files with the following commands: ]
11 %
12 % make eh3_mine
13 % for i in wghc*.fld ; do
14 % echo $i | ./eh3_mine
15 % mv fort.10 `echo $i | cut -d '-' -f1`
16 % done
17
18
19 matlab -nojvm
20 clear all
21
22 nx = 720;
23 ny = 341;
24 nz = 45;
25 xvals = 360.0*[0:(nx-1)]/nx;
26 yvals = linspace(-80, 90, ny);
27 zvals = [ ...
28 0 10 20 30 40 50 75 100 ...
29 125 150 175 200 250 300 ...
30 350 400 500 600 700 800 ...
31 900 1000 1100 1200 1300 ...
32 1400 1500 1750 2000 2250 ...
33 2500 2750 3000 3250 3500 ...
34 3750 4000 4250 4500 4750 ...
35 5000 5250 5500 5750 6000 ];
36
37 iv = 1
38 idvall = [ ...
39 'pressure '; ...
40 'in-situ_temperature '; ...
41 'potential_temperature'; ...
42 'salinity '; ...
43 'oxygen '; ...
44 'silicate '; ...
45 'nitrate '; ...
46 'phosphate ' ]
47 idunits = [ ...
48 'dbar '; ...
49 'deg_C '; ...
50 'deg_C '; ...
51 'salinity '; ...
52 'ml/l '; ...
53 'umol/kg '; ...
54 'umol/kg '; ...
55 'umol/kg ' ]
56
57 all = NaN * ones(nx,ny,nz);
58
59 for iv = 1:8
60
61 all = NaN * all;
62
63 k = [ 0 4 8 12 16 20 24 28 32 ];
64 j = 1
65 for j = 1:length(k)
66 c = sprintf('load wghc%02d00; a=wghc%02d00; clear wghc%02d00', ...
67 k(j), k(j), k(j));
68 disp(c);
69 eval(c)
70 io = 80*(j-1)
71 for i = 1:size(a,1)
72 all(io+a(i,1),a(i,2),a(i,3)) = a(i,7+iv);
73 end
74 end
75
76 idv = deblank(idvall(iv,:));
77 units = deblank(idunits(iv,:));
78 idlat = 'lat';
79 idlon = 'lon';
80
81 desc = [ 'WOCE : ' idv ];
82 ncname = sprintf('WOCE_%02d.nc',iv);
83 nc = netcdf(ncname, 'clobber');
84 nc.reference = desc;
85 nc.author = 'Ed Hill <eh3@mit.edu>';
86 nc.date = 'Feb 8, 2004';
87 nc('X') = nx;
88 nc('Y') = ny;
89 nc('Z') = nz;
90 nc{'X'} = 'X';
91 nc{'Y'} = 'Y';
92 nc{'Z'} = 'Z';
93 nc{ idv } = { 'Z', 'Y', 'X' };
94 nc{'X'}.uniquename = 'X';
95 nc{'Y'}.uniquename = 'Y';
96 nc{'Z'}.uniquename = 'Z';
97 nc{'X'}.uniquename = 'X';
98 nc{'X'}.long_name = 'longitude';
99 nc{'X'}.gridtype = ncint(1);
100 nc{'X'}.units = 'degree_east';
101 nc{'Y'}.uniquename = 'Y';
102 nc{'Y'}.long_name = 'latitude';
103 nc{'Y'}.gridtype = ncint(0);
104 nc{'Y'}.units = 'degree_north';
105 nc{'Z'}.uniquename = 'Z';
106 nc{'Z'}.long_name = 'depth';
107 nc{'Z'}.gridtype = ncint(0);
108 nc{'Z'}.units = 'm';
109 nc{ idv }.units = units;
110 nc{ idv }.long_name = idv;
111 nc{ idv }.missing_value = ncdouble(-9999.0);
112 nc{ idv }.FillValue_ = ncdouble(-9999.);
113 nc{'X'}(:) = xvals;
114 nc{'Y'}(:) = yvals;
115 nc{'Z'}(:) = zvals;
116 % p = permute(all,[ 3 2 1 ]);
117 % nc{ idv }(:) = p;
118 nc{ idv }(:) = permute(all,[ 3 2 1 ]);
119 nc = close(nc);
120
121 end
122
123 ! scp WOCE_*.nc channel.mit.edu:ADD/WOCE/
124
125 % On channel.mit.edu, run:
126 mv WOCE_01.nc pressure.nc
127 mv WOCE_02.nc t_in-situ.nc
128 mv WOCE_03.nc theta.nc
129 mv WOCE_04.nc salinity.nc
130 mv WOCE_05.nc oxygen.nc
131 mv WOCE_06.nc silicate.nc
132 mv WOCE_07.nc nitrate.nc
133 mv WOCE_08.nc phosphate.nc
134
135
136 % ;;; Local Variables: ***
137 % ;;; mode:matlab ***
138 % ;;; End: ***

  ViewVC Help
Powered by ViewVC 1.1.22