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