Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Go to an OPeNDAP server (e.g. http://opendap.deltares.nl) and pick a netCDF file by copying the contents of the Data URL box.
  2. Define the associated url you just copied.

    Code Block
    url_grid = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/vaklodingen/vaklodingenKB116_4544.nc'
    url_time = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/waterbase/concentration_of_suspended_matter_in_water/id410-DELFZBTHVN.nc'
    

    and select the variable you want to plot by looking at the file contents

    Code Block
    ncdisp(url_grid)
    ncdisp(url_time)
    
  3. Define the data subset to get. Not until you issue the nc_varget you will actually get the data. Even if when the underlying file would be a hundreds of GB, this step can be pretty fast provided the subset you chose is not too big. Only when you make too big a selection, Matlab will take long. This will happen for instance with the 100 + years of tidal elevation dataset at station DelftZijl Buitenhaven. This selection step is the essential difference with the approach of downloading a netCDF file and then using Matlab to view that local file from your harddisk. With OPeNDAP you do not have to download an entire file before you can view it, because you can request only a specific slice, or a subset of a matrix.

    Code Block
    G.x = ncread(url_grid,'x');
    G.y = ncread(url_grid,'y');
    G.z = ncread(url_grid,'z',[1 1 1],[Inf Inf 1]); % get only one timestep (here: 1st), but all x and y, note: ncread is zero based. note: matlab has different dimension order than other netCDF tools: t is last here
    
    Code Block
    T.t   = ncread_cf_time(url_time,'time'); % adapt reference date of 1970 in netCDF to Matlab reference date of 0000
    T.eta = ncread(url_time,'concentration_of_suspended_matter_in_water');
    
  4. plot ...

    Code Block
    pcolorcorcen(G.x,G.y,G.z')
    axis equal
    axis tight
    tickmap('xy')
    grid on
    xlabel('x')
    ylabel('y')
    colorbarwithtitle('z')
    
    Code Block
    figure
    plot(T.t,T.eta)
    datetick('x')
    grid on
    
  5. et voila

...