You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Introduction

This page gives an overview of the exercise with reading and creating CF compliant netcdf files presented on November 1th, 2013 by Kees den Heijer.

Data

The exercise deals with bathymetry data of the Dutch coast. Here is the link to browse the netcdf file of concern with your browser:
http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/vaklodingen/vaklodingenKB118_3736.nc.html
The first link on this page (OPENDAP), goes to a page the shows all the meta information and file structure of a file.
The second link (HTTPServer) can be used to download the whole file to your local hard drive.

Both in Matlab and in Python, the link to netcdf file can be specified as follows:

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

Exercise

  • 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 manual)

Code suggestions

Matlab (native)

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

Matlab (OET)

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

Python

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