Canoe
Comprehensive Atmosphere N' Ocean Engine
make_plots.py
Go to the documentation of this file.
1 #! /usr/bin/env python3
2 import matplotlib
3 matplotlib.use('Agg')
4 from netCDF4 import Dataset
5 from pylab import *
6 
7 case = 'straka-test-main'
8 data = Dataset('%s.nc' % case, 'r')
9 time = data['time'][:]
10 x1 = data['x1'][:]/1.E3
11 x2 = data['x2'][:]/1.E3
12 
13 tslice = [0., 300., 600., 900.]
14 Rd = 287.
15 cp = 1004.
16 p0 = 1.E5
17 Ts = 300.
18 
19 # plot potential temperature
20 fig, axs = subplots(4, 1, figsize = (10, 12), sharex = True, sharey = True)
21 subplots_adjust(hspace = 0.08)
22 X, Y = meshgrid(x2, x1)
23 clines = hstack((arange(-17., 0.), arange(1., 5.)))
24 
25 for i, t in enumerate(tslice):
26  j = where(time >= t)[0][0]
27  theta = data['theta'][j,:,:,0]
28  theta -= Ts
29  print('time = %.2f, theta min = %.2f, theta max = %.2f' % (time[j], theta.min(), theta.max()))
30  ax = axs[i]
31  ax.contour(X, Y, theta, clines, colors = 'k', linestyles = '-')
32  #ax.contour(X, Y, theta.T, clines, colors = 'k')
33  ax.set_xlim([0., 19.2])
34  ax.set_ylim([0., 4.8])
35  ax.text(14., 4.4, 'time = %.1f ' % time[j], fontsize = 12)
36  ax.text(14., 4.0, '%.2f m' % (1.E3*(max(x2) - min(x2))/len(x2),),
37  fontsize = 12)
38  ax.text(14., 3.6, 'min T = %.2f K' % theta.min(), fontsize = 12)
39  ax.text(14., 3.2, 'max T = %.2f K' % theta.max(), fontsize = 12)
40  ax.set_ylabel('Z (km)', fontsize = 15)
41 ax.set_xlabel('X (km)', fontsize = 15)
42 savefig('2d.straka-theta.png' % case, bbox_inches = 'tight')
43 close()
double min(double x1, double x2, double x3)
Definition: core.h:16
double max(double x1, double x2, double x3)
Definition: core.h:19