forked from davegill/SCRIPTS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrd_l2_norm.py
More file actions
33 lines (27 loc) · 830 Bytes
/
rd_l2_norm.py
File metadata and controls
33 lines (27 loc) · 830 Bytes
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
from netCDF4 import Dataset
import numpy as np
import sys
# override boolean warning
from warnings import filterwarnings
filterwarnings(action='ignore', category=DeprecationWarning, message='`np.bool` is a deprecated alias')
o = Dataset(str(sys.argv[1]))
list_of_vars = o.variables.keys()
if 'THM' in list_of_vars:
u = o.variables["U"][1,:,:,:]
v = o.variables["V"][1,:,:,:]
t = o.variables["THM"][1,:,:,:]
q = o.variables["QVAPOR"][1,:,:,:]
elif 'T' in list_of_vars:
u = o.variables["U"][1,:,:,:]
v = o.variables["V"][1,:,:,:]
t = o.variables["T"][1,:,:,:]
q = o.variables["Q"][1,:,:,:]
u = u**2
v = v**2
t = t**2
sum = np.sum(q)
print ('Qv = ' + str('{:3.12e}'.format(sum)) )
sum = np.sum(t)
print ('T = ' + str('{:3.12e}'.format(sum)) )
sum = np.sum(u) + np.sum(v)
print ('UV = ' + str('{:3.12e}'.format(sum)) )