-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathval_runoff.py
More file actions
53 lines (40 loc) · 8.05 KB
/
Copy pathval_runoff.py
File metadata and controls
53 lines (40 loc) · 8.05 KB
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
from netCDF4 import *
from numpy import *
# Validate that no runoff is occuring over land cells.
# Input: base_dir = full path to simulation output directory in single quotes
# Example: run val_runoff('/short/v45/pas561/mom/archive/gfdl_nyf_1080/'
def val_runoff (grid_file,data_file):
data_file = '/short/v45/pas561/mom/input/mom01v2/runoff_fixed.nc'
grid_file = '/short/v45/pas561/mom/archive/mom01v4/output065/ocean.nc'
print 'Reading temp from output' + grid_file
input1 = Dataset(grid_file, 'r')
temp = input1.variables['temp'][:]
print '\nshape temp=\n ',temp.shape
km=temp.shape[1]
jm=temp.shape[2]
im=temp.shape[3]
print 'km,jm,im',km,jm,im
print 'Reading runoff from' + data_file
input2 = Dataset(data_file, 'r')
runoff = input2.variables['runoff'][:]
print '\nshape runoff=\n ',runoff.shape
tm=runoff.shape[0]
jm=runoff.shape[1]
im=runoff.shape[2]
print 'tm,jm,im',tm,jm,im
#set land vals to 0
index=temp.mask
temp[index]=999
for t in range(0,tm):
print 'time level', t
cnt=0
#range from 1 to im -1 with 0 start index
for i in range(0,im):
for j in range(0,jm):
#check for land mask here
#if ww.mask[j,i]=FALSE??? ...maybe not needed caused zerod
#if temp[0,0,j,i] > 99 and runoff[t,j,i] > 0:
if runoff[t,j,i] > 1:# or runoff[t,j,i]>1:
cnt=cnt+1
print cnt, i, j, t, runoff[t,j,i]