This example shows how to write  a NetCDF / CF compliant file using python.

We use the Scientific.IO.NetCDF library:

from Scientific.IO.NetCDF import NetCDFFile as Dataset

The example shows the creation of a U and V file for ocean currents. You can see how we add the CF convention attributes for each variable:

Time:

  • long_name = time
  • standard_name = time
  • units = days since 1858-11-17 00:00:00 // another example seconds since 1970-01-01 00:00:00

Latitude:

  • long_name = nodal latitude // You can use latitude also
  • standard_name = latitude
  • units = degrees_north

Longitude:

  • long_name = nodal longitude
  • standard_name = longitude
  • units = degrees_east

U:

  • long_name = Eastward Water Velocity
  • standard_name = eastward_water_velocity
  • units = meters s-1

V:

  • long_name = Northward Water Velocity
  • standard_name = northward_water_velocity
  • units = meters s-1

 

You can see the code here

codePython: