]> Creatis software - CreaPhase.git/blob - octave_packages/octcdf-1.1.4/example_opendap.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / octcdf-1.1.4 / example_opendap.m
1 %% Copyright (C) 2005 Alexander Barth
2 %%
3 %% This program is free software; you can redistribute it and/or modify
4 %% it under the terms of the GNU General Public License as published by
5 %% the Free Software Foundation; either version 2 of the License, or
6 %% (at your option) any later version.
7 %%
8 %% This program is distributed in the hope that it will be useful,
9 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
10 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 %% GNU General Public License for more details.
12 %%
13 %% You should have received a copy of the GNU General Public License
14 %% along with this program; If not, see <http://www.gnu.org/licenses/>.
15
16 % Example for loading a dataset from an OPeNDAP server
17
18 nc = netcdf('http://hycom.coaps.fsu.edu/thredds/dodsC/atl_ops','r');
19
20 lat = nc{'Latitude'}(:);
21 lon = nc{'Longitude'}(:);
22 time = nc{'MT'}(end);
23
24 disp(['SSH forecast for part of the North Atlantic for ' datestr(datenum(1900,12,31) + time)]);
25
26 %
27 % Select the SSH for part of the North Atlantic
28
29
30 i = find(-92 < lon & lon < -51);
31 j = find(23 < lat & lat < 45);   
32
33 x = lon(i);
34 y = lat(j);
35
36 % download data
37
38 ssh = nc{'ssh'}(end,j,i);
39
40 fillval = nc{'ssh'}._FillValue;
41 ssh(ssh == fillval) = NaN;
42
43 % With autonan, i.e. every _FillValue is replaced by a NaN
44 % nv = ncautonan(nc{'ssh'},1);
45 % ssh = nv(end,j,i);
46
47 ssh = squeeze(ssh);
48
49 close(nc);
50
51 colormap(hsv);
52 axis xy
53 iamgesc(ssh); 
54
55 % or with yapso
56 % pcolor(ssh);
57