forked from pressel/pycles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBomex_plotting.py
132 lines (107 loc) · 4.43 KB
/
Bomex_plotting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import netCDF4 as nc
import numpy as np
import pylab as plt
import glob
import os
my_i = np.arange(700,720,1) # which profiles to include
n_i = np.shape(my_i)[0]
nkr = 32 #75
vars = ['temperature_mean','u_mean','v_mean','s_mean','viscosity_mean','diffusivity_mean' ,'wind_speed', 'wind_angle', 'theta_mean']
colors = ['White','White','LightPink','PowderBlue','HotPink','SkyBlue','MediumVioletRed','RoyalBlue','Maroon','Navy','White','Black']
dirs = glob.glob('./Output.Bomex.f827b*')
#--------MEANS
for dir in dirs:
file = glob.glob(dir+'/stats/*')[0]
data = nc.Dataset(file,'r')
for var in vars:
string = file[-5:-3]
if string[0]=='_':
string = string[1]
print(string)
if string == '3':
pass
else:
title = var
plt.figure(title)
reg1 = np.zeros(nkr)
for t in my_i:
for k in np.arange(nkr):
reg1[k] += data.groups['profiles'].variables[var][t,k]/float(n_i)
plt.plot(reg1, data.groups['profiles'].variables['z'][:], linewidth = 2,label = string, color=colors[int(string)])
for var in vars:
plt.figure(var)
plt.xlabel(var)
plt.ylabel('z, m',fontsize=14 )
plt.grid(True)
plt.legend()
#----VARIANCES
variances = ['horizontal_velocity_variance','vertical_velocity_variance','resolved_tke','resolved_theta_variance']
for dir in dirs:
file = glob.glob(dir+'/stats/*')[0]
data = nc.Dataset(file,'r')
string = file[-5:-3]
if string[0]=='_':
string = string[1]
print(string)
if string == '3' :
pass
else:
reg1 = np.zeros(nkr)
reg1w = np.zeros(nkr)
regth = np.zeros(nkr)
for t in my_i:
for k in np.arange(nkr):
reg1[k] += data.groups['profiles'].variables['u_mean2'][t,k]/float(n_i)-data.groups['profiles'].variables['u_mean'][t,k]**2/float(n_i)
reg1[k] += data.groups['profiles'].variables['v_mean2'][t,k]/float(n_i)-data.groups['profiles'].variables['v_mean'][t,k]**2/float(n_i)
reg1w[k] += data.groups['profiles'].variables['w_mean2'][t,k]/float(n_i)-data.groups['profiles'].variables['w_mean'][t,k]**2/float(n_i)
regth[k] += data.groups['profiles'].variables['theta_mean2'][t,k]/float(n_i)-data.groups['profiles'].variables['theta_mean'][t,k]**2/float(n_i)
plt.figure('horizontal_velocity_variance')
plt.plot(reg1, data.groups['profiles'].variables['z'][:], linewidth = 2,label = string, color=colors[int(string)])
plt.figure('vertical_velocity_variance')
plt.plot(reg1w, data.groups['profiles'].variables['z'][:], linewidth = 2,label = string, color=colors[int(string)])
plt.figure('resolved_tke')
plt.plot((reg1[:]+reg1w[:])*0.5, data.groups['profiles'].variables['z'][:], linewidth = 2,label = string, color=colors[int(string)])
plt.figure('resolved_theta_variance')
plt.plot(regth, data.groups['profiles'].variables['z'][:], linewidth = 2,label = string, color=colors[int(string)])
for var in variances:
plt.figure(var)
plt.title(var)
plt.ylabel('z, m',fontsize=14 )
plt.xlabel(var, fontsize=14)
plt.grid(True)
plt.legend()
vars = ['b_flux_surface_mean', 'viscosity_max', 'viscosity_min','w_max', 'w_min', 'obukhov_length_mean','friction_velocity_mean']
for dir in dirs:
file = glob.glob(dir+'/stats/*')[0]
data = nc.Dataset(file,'r')
for var in vars:
string = file[-5:-3]
if string[0]=='_':
string = string[1]
print(string)
if string == '3':
pass
else:
title = var
plt.figure(title)
plt.plot(data.groups['timeseries'].variables['t'][:],data.groups['timeseries'].variables[var][:],linewidth = 2,label = string, color=colors[int(string)])
for var in vars:
plt.figure(var)
plt.title(var)
plt.ylabel(var,fontsize=14 )
plt.xlabel('time', fontsize=14)
plt.grid(True)
plt.legend()
# vars = ['friction_velocity_mean']
#
#
# for var in vars:
# nfig +=1
# plt.figure(nfig)
# plt.title(var+'_square')
# plt.plot(smag.groups['timeseries'].variables['t'][:],smag.groups['timeseries'].variables[var][:]**2,'-b')
# plt.plot(tke.groups['timeseries'].variables['t'][:],tke.groups['timeseries'].variables[var][:]**2,'-r')
# plt.plot(m2.groups['timeseries'].variables['t'][:],m2.groups['timeseries'].variables[var][:]**2,'-g')
#
#
plt.show()