Versions Compared

Key

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

...

  • Read bathymetry data (variable 'z') from the above mentioned netcdf file.
  • Extract the latest time slice only
  • Create the new file with this latest time slice, using the netCDF Kickstarter (for further info see the netCDF kickstarter)

...

Basic code elements

Code Block

ncdisp(ncfile)
info = ncinfo(ncfile)
z = ncread(ncfile, 'z');

Example pcolor plot of the most recent available measurement

Code Block

ncfile = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/vaklodingen/vaklodingenKB118_3736.nc';

x = ncread(ncfile, 'x');
y = ncread(ncfile, 'y');
z = ncread(ncfile, 'z');

[X, Y] = meshgrid(x, y);

Z = squeeze(z(:,:,end))';

pcolor(X,Y,Z)
shading interp
axis image

Matlab (OET)

Code Block

nc_dump(ncfile)
info = nc_info(ncfile)
z = nc_varget(ncfile, 'z');

...

Basic code elements

Code Block
languagepython

import netCDF4
ds = netCDF4.Dataset(ncfile)
print ds
z = ds.variables['z']
ds.close()

Example pcolor plot of the most recent available measurement

Code Block
languagepython

from netCDF4 import Dataset
import matplotlib.pyplot as plt
import numpy as np

ncfile = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/vaklodingen/vaklodingenKB118_3736.nc'

ds = Dataset(ncfile)
x = ds.variables['x'][:]
y = ds.variables['y'][:]
z = ds.variables['z'][-1,]
ds.close()

X,Y = np.meshgrid(x,y)
fig,ax = plt.subplots(nrows=1, ncols=1, subplot_kw=dict(aspect='equal'))
ax.pcolor(X, Y, z)
fig.savefig('plot.png')

...