10478
|
1 function ncarray_example_file(filename,data) |
|
2 |
|
3 nc = netcdf(filename,'c'); |
|
4 |
|
5 % dimensions |
|
6 |
|
7 nc('x') = size(data,1); |
|
8 nc('y') = size(data,2); |
|
9 nc('time') = size(data,3); |
|
10 |
|
11 % variables |
|
12 |
|
13 nc{'lon'} = ncfloat('y','x'); % 31680 elements |
|
14 nc{'lon'}.long_name = ncchar('Longitude'); |
|
15 nc{'lon'}.units = ncchar('degrees_east'); |
|
16 |
|
17 nc{'lat'} = ncfloat('y','x'); % 31680 elements |
|
18 nc{'lat'}.long_name = ncchar('Latitude'); |
|
19 nc{'lat'}.units = ncchar('degrees_north'); |
|
20 |
|
21 nc{'time'} = ncfloat('time'); % 1 elements |
|
22 nc{'time'}.long_name = ncchar('Time'); |
|
23 nc{'time'}.units = ncchar('days since 1858-11-17 00:00:00 GMT'); |
|
24 |
|
25 nc{'SST'} = ncfloat('time','y','x'); % 31680 elements |
|
26 nc{'SST'}.missing_value = ncfloat(9999); |
|
27 nc{'SST'}.FillValue_ = ncfloat(9999); |
|
28 nc{'SST'}.units = ncchar('degC'); |
|
29 nc{'SST'}.long_name = ncchar('Sea Surface Temperature'); |
|
30 nc{'SST'}.coordinates = ncchar('lat lon'); |
|
31 |
|
32 % global attributes |
|
33 |
|
34 nc{'SST'}(:) = permute(data,[3 2 1]); |
10535
|
35 close(nc) |
|
36 |
|
37 |
|
38 % Copyright (C) 2012 Alexander Barth <barth.alexander@gmail.com> |
|
39 % |
|
40 % This program is free software; you can redistribute it and/or modify |
|
41 % it under the terms of the GNU General Public License as published by |
|
42 % the Free Software Foundation; either version 2 of the License, or |
|
43 % (at your option) any later version. |
|
44 % |
|
45 % This program is distributed in the hope that it will be useful, |
|
46 % but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
47 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
48 % GNU General Public License for more details. |
|
49 % |
|
50 % You should have received a copy of the GNU General Public License |
|
51 % along with this program; If not, see <http://www.gnu.org/licenses/>. |
|
52 |