Ticket #679: nc.py

File nc.py, 632 bytes (added by warrick, 4 years ago)

Test script for CF 1.0

Line 
1
2#modules to read in which are generic python modules
3import matplotlib.pyplot as plt
4import netCDF4 as nc
5
6import collections
7d = collections.OrderedDict()
8
9#define location of data
10dir = '/path/to/data/'
11filename = 'IT-IO-03_o.nc'
12my_example_nc_file = dir + filename
13
14
15ds = nc.Dataset(my_example_nc_file, mode='r')
16
17# name the variables for plotting
18x = ds.variables['temp'][:] #extracts the temperature data
19y = ds.variables['press'][:] #extracts the pressure data
20
21x = x - 273.15 # Convert to degrees C
22
23plt.plot(x[0],y[0])
24
25plt.xlabel('Temperature (K)')
26plt.ylabel('Pressure (hPa)')
27plt.yscale('log')
28plt.show() #show plot
29