annotate extra/ncArray/inst/ncarray_example_file.m @ 12682:e97980ace11d octave-forge

add example of using ncArray
author abarth93
date Mon, 24 Aug 2015 08:51:53 +0000
parents extra/ncArray/inst/private/ncarray_example_file.m@34b88e26cfd2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12682
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
1 % create an example NetCDF file with the name filename and given data
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
2
10478
03f260c80c1e initial import of ncArray
abarth93
parents:
diff changeset
3 function ncarray_example_file(filename,data)
03f260c80c1e initial import of ncArray
abarth93
parents:
diff changeset
4
12193
34b88e26cfd2 new functions
abarth93
parents: 11998
diff changeset
5 dtype = 'double';
12682
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
6 sz = size(data);
12193
34b88e26cfd2 new functions
abarth93
parents: 11998
diff changeset
7
11998
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
8 % Variables
12193
34b88e26cfd2 new functions
abarth93
parents: 11998
diff changeset
9 nccreate(filename,'lon','Format','classic','Datatype',dtype,...
12682
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
10 'Dimensions',{'x',sz(1), 'y',sz(2)});
11998
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
11 ncwriteatt(filename,'lon','long_name','Longitude')
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
12 ncwriteatt(filename,'lon','units','degrees_east')
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
13
12682
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
14 nccreate(filename,'lat','Datatype',dtype,'Dimensions',{'x',sz(1), 'y',sz(2)});
11998
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
15 ncwriteatt(filename,'lat','long_name','Latitude')
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
16 ncwriteatt(filename,'lat','units','degrees_north')
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
17
12193
34b88e26cfd2 new functions
abarth93
parents: 11998
diff changeset
18 nccreate(filename,'time','Datatype',dtype,'Dimensions',{'time',1});
11998
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
19 ncwriteatt(filename,'time','long_name','Time')
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
20 ncwriteatt(filename,'time','units','days since 1858-11-17 00:00:00 GMT')
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
21
12193
34b88e26cfd2 new functions
abarth93
parents: 11998
diff changeset
22 nccreate(filename,'SST','Datatype',dtype,'Dimensions',...
12682
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
23 {'x',sz(1), 'y',sz(2), 'time',1});
11998
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
24 ncwriteatt(filename,'SST','missing_value',single(9999))
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
25 ncwriteatt(filename,'SST','_FillValue',single(9999))
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
26 ncwriteatt(filename,'SST','units','degC')
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
27 ncwriteatt(filename,'SST','long_name','Sea Surface Temperature')
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
28 ncwriteatt(filename,'SST','coordinates','lat lon')
10478
03f260c80c1e initial import of ncArray
abarth93
parents:
diff changeset
29
11998
b86d8743bf43 improve compatability with matlab
abarth93
parents: 10535
diff changeset
30 ncwrite(filename,'SST',data);
10478
03f260c80c1e initial import of ncArray
abarth93
parents:
diff changeset
31
12682
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
32 % Copyright (C) 2012,2013,2015 Alexander Barth <barth.alexander@gmail.com>
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
33 %
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
34 % This program is free software; you can redistribute it and/or modify
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
35 % it under the terms of the GNU General Public License as published by
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
36 % the Free Software Foundation; either version 2 of the License, or
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
37 % (at your option) any later version.
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
38 %
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
39 % This program is distributed in the hope that it will be useful,
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
40 % but WITHOUT ANY WARRANTY; without even the implied warranty of
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
41 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
42 % GNU General Public License for more details.
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
43 %
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
44 % You should have received a copy of the GNU General Public License
e97980ace11d add example of using ncArray
abarth93
parents: 12193
diff changeset
45 % along with this program; If not, see <http://www.gnu.org/licenses/>.
10478
03f260c80c1e initial import of ncArray
abarth93
parents:
diff changeset
46